-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from performant-software/feature/atlas4_place…
…_details Atlas #4 - Place details
- Loading branch information
Showing
80 changed files
with
7,466 additions
and
30,200 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# core-data | ||
|
||
## CSS | ||
Depending on whether your application using Tailwind CSS, we'll configure the CSS in one of two ways: | ||
|
||
### WITHOUT Tailwind CSS | ||
Import both exported `styles.css` and `tailwind.css` into your application. | ||
|
||
```javascript | ||
// index.js | ||
|
||
import '@performant-software/core-data/styles.css'; | ||
import '@performant-software/core-data/tailwind.css'; | ||
``` | ||
|
||
### WITH Tailwind CSS | ||
|
||
Import **ONLY** the `styles.css` import your application. | ||
|
||
```javascript | ||
// index.js | ||
|
||
import '@performant-software/core-data/styles.css'; | ||
``` | ||
|
||
Include the `core-data` Tailwind config as a `present`, and update the `content` section to source classes from the `core-data` package. | ||
|
||
```javascript | ||
// tailwind.config.js | ||
|
||
import coreDataConfig from '@performant-software/core-data/tailwind.config'; | ||
|
||
export default { | ||
presets: [ | ||
coreDataConfig | ||
], | ||
content: [ | ||
'../../node_modules/@performant-software/core-data/**/*.{js,jsx,ts,tsx}' | ||
] | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
export default { | ||
plugins: { | ||
'postcss-import': {}, | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
packages/core-data/src/components/CoreDataContextProvider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// @flow | ||
|
||
import React, { type Node, useMemo } from 'react'; | ||
import CoreDataContext from '../context/CoreData'; | ||
|
||
type Props = { | ||
/** | ||
* Core Data base URL. | ||
*/ | ||
baseUrl: string, | ||
|
||
/** | ||
* JSX child elements. | ||
*/ | ||
children: Node, | ||
|
||
/** | ||
* Core Data project IDs. | ||
*/ | ||
projectIds: Array<string> | ||
}; | ||
|
||
/** | ||
* This component renders a context provider to supply the Core Data base URL and project IDs to any child elements. | ||
*/ | ||
const CoreDataContextProvider = ({ baseUrl, children, projectIds }: Props) => { | ||
const value = useMemo(() => ({ baseUrl, projectIds }), [baseUrl, projectIds]); | ||
|
||
return ( | ||
<CoreDataContext.Provider | ||
value={value} | ||
> | ||
{ children } | ||
</CoreDataContext.Provider> | ||
); | ||
}; | ||
|
||
export default CoreDataContextProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @flow | ||
|
||
import React, { type Node } from 'react'; | ||
|
||
type Props = { | ||
/** | ||
* Label for the list. | ||
*/ | ||
label: string, | ||
|
||
/** | ||
* Callback fired to render the list content. | ||
* | ||
* @param attribute | ||
*/ | ||
renderList: (attribute: string) => Node, | ||
}; | ||
|
||
/** | ||
* This component renders a wrapper for a facet list. | ||
*/ | ||
const FacetList = (props: Props) => ( | ||
<div | ||
className='facet-list' | ||
> | ||
<h3 | ||
className='mt-5 font-medium text-sm mb-2 flex items-center' | ||
> | ||
<span> | ||
{ props.label } | ||
</span> | ||
</h3> | ||
{ props.renderList() } | ||
</div> | ||
); | ||
|
||
export default FacetList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// @flow | ||
|
||
import React, { useCallback, type Node } from 'react'; | ||
import _ from 'underscore'; | ||
import FacetList from './FacetList'; | ||
import TypesenseUtils from '../utils/Typesense'; | ||
|
||
type Props = { | ||
/** | ||
* The list of attributes for which to render the lists. | ||
*/ | ||
attributes: Array<string>, | ||
|
||
/** | ||
* Callback fired to render the facet list. | ||
* | ||
* @param attribute | ||
*/ | ||
renderList: (attribute: string) => Node, | ||
|
||
/** | ||
* Returns the label for the passed UUID value. | ||
* | ||
* @param uuid | ||
*/ | ||
resolveLabel: (uuid: string) => string | ||
}; | ||
|
||
/** | ||
* This component renders a set of facet lists for the passed attributes. | ||
*/ | ||
const FacetLists = (props: Props) => { | ||
/** | ||
* Renders the passed attribute. | ||
* | ||
* @type {function(string): *} | ||
*/ | ||
const renderList = useCallback((attribute: string) => { | ||
const uuid = TypesenseUtils.getFieldId(attribute); | ||
|
||
return ( | ||
<FacetList | ||
key={attribute} | ||
label={props.resolveLabel(uuid)} | ||
renderList={() => props.renderList(attribute)} | ||
/> | ||
); | ||
}, [props.renderList, props.resolveLabel]); | ||
|
||
return _.map(props.attributes, renderList); | ||
}; | ||
|
||
export default FacetLists; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// @flow | ||
|
||
import React, { useCallback, useMemo, type Node } from 'react'; | ||
import _ from 'underscore'; | ||
import FacetLists from './FacetLists'; | ||
import TypesenseUtils from '../utils/Typesense'; | ||
|
||
type Props = { | ||
/** | ||
* The list of attributes for which to render the lists. | ||
*/ | ||
attributes: Array<string>, | ||
|
||
/** | ||
* Callback fired to render the facet list. | ||
* | ||
* @param attribute | ||
*/ | ||
renderList: (attribute: string) => Node, | ||
|
||
/** | ||
* Returns the label for the passed UUID value. | ||
* | ||
* @param uuid | ||
*/ | ||
resolveLabel: (uuid: string) => string | ||
}; | ||
|
||
const DEFAULT_ID = 'root'; | ||
|
||
/** | ||
* This component renders a set of facet lists for the passed attributes, grouped by the relationship value. | ||
*/ | ||
const FacetListsGrouped = (props: Props) => { | ||
/** | ||
* Groups the attributes according to the relationship UUID prefix. | ||
*/ | ||
const groupedAttributes = useMemo(() => { | ||
const value = []; | ||
|
||
_.each(props.attributes, (attribute: string) => { | ||
const id = TypesenseUtils.getRelationshipId(attribute) || DEFAULT_ID; | ||
const label = props.resolveLabel(id); | ||
|
||
let group = _.findWhere(value, { id }); | ||
if (!group) { | ||
group = { id, label, items: [] }; | ||
value.push(group); | ||
} | ||
|
||
group.items.push(attribute); | ||
}); | ||
|
||
return _.sortBy(value, 'label'); | ||
}, [props.attributes, props.resolveLabel]); | ||
|
||
/** | ||
* Renders the section for the passed item. An item can contain many facets. | ||
* | ||
* @type {unknown} | ||
*/ | ||
const renderSection = useCallback((item) => ( | ||
<div | ||
className='border-t my-3' | ||
key={item.id} | ||
> | ||
<h1>{ item.label }</h1> | ||
<FacetLists | ||
attributes={item.items} | ||
renderList={props.renderList} | ||
resolveLabel={props.resolveLabel} | ||
/> | ||
</div> | ||
), [props.renderList, props.resolveLabel]); | ||
|
||
return _.map(groupedAttributes, renderSection); | ||
}; | ||
|
||
export default FacetListsGrouped; |
Oops, something went wrong.