Skip to content

Commit

Permalink
Merge pull request #302 from performant-software/feature/basira254_sl…
Browse files Browse the repository at this point in the history
…ider_facets

BASIRA #254 - Slider facets
  • Loading branch information
dleadbetter authored Nov 27, 2024
2 parents c78c21b + e4be564 commit 2ed9f39
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 37 deletions.
6 changes: 3 additions & 3 deletions packages/controlled-vocabulary/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/controlled-vocabulary",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand All @@ -23,8 +23,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/semantic-components": "^2.2.16",
"@performant-software/shared-components": "^2.2.16",
"@performant-software/semantic-components": "^2.2.17",
"@performant-software/shared-components": "^2.2.17",
"react": ">= 16.13.1 < 19.0.0",
"react-dom": ">= 16.13.1 < 19.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/core-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/core-data",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of components used with the Core Data platform.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down Expand Up @@ -40,8 +40,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/geospatial": "^2.2.16",
"@performant-software/shared-components": "^2.2.16",
"@performant-software/geospatial": "^2.2.17",
"@performant-software/shared-components": "^2.2.17",
"@peripleo/maplibre": "^0.5.2",
"@peripleo/peripleo": "^0.5.2",
"react": ">= 16.13.1 < 19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/geospatial/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/geospatial",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of components for all things map-related.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/semantic-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/semantic-components",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of shared components based on the Semantic UI Framework.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"zotero-translation-client": "^5.0.1"
},
"peerDependencies": {
"@performant-software/shared-components": "^2.2.16",
"@performant-software/shared-components": "^2.2.17",
"@samvera/clover-iiif": "^2.3.2",
"react": ">= 16.13.1 < 19.0.0",
"react-dnd": "^11.1.3",
Expand Down
38 changes: 16 additions & 22 deletions packages/semantic-ui/src/components/FacetSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Slider from 'rc-slider';
import React, {
forwardRef,
useEffect,
useMemo,
useState
} from 'react';
import { Grid } from 'semantic-ui-react';
Expand All @@ -22,34 +21,28 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
const {
start,
range,
refine,
canRefine = true,
refine
} = useRangeSlider(props);

const [valueView, setValueView] = useState < Array < number >> ([range.min, range.max]);
const { min, max } = range;

/**
* Sets the visibility variable based on the range min and max.
*
* @type {unknown}
*/
const visible = useMemo(() => range.min !== 0 && range.max !== 0, [range.min, range.max]);
const [value, setValue] = useState([min, max]);

const from = Math.max(min, Number.isFinite(start[0]) ? start[0] : min);
const to = Math.min(max, Number.isFinite(start[1]) ? start[1] : max);

/**
* Resets the value and valueView when the current refinement is cleared.
*/
useEffect(() => {
if (start[0] <= range.min && start[1] >= range.max) {
setValueView([range.min, range.max]);
}
}, [range, start]);
setValue([from, to]);
}, [from, to]);

return (
<Facet
defaultActive={props.defaultActive}
divided={props.divided}
innerRef={ref}
title={props.title}
visible={visible}
visible={props.visible}
>
<div
className='facet-slider'
Expand All @@ -60,24 +53,25 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
<Slider
allowCross={false}
defaultValue={start}
disabled={!canRefine}
max={range.max}
min={range.min}
onAfterChange={(v) => refine(v)}
onChange={(v) => setValueView(v)}
onChangeComplete={(v) => refine(v)}
onChange={(v) => setValue(v)}
range
value={valueView}
value={value}
/>
</div>
<Grid
columns={2}
>
<Grid.Column>
{valueView[0]}
{ value[0] }
</Grid.Column>
<Grid.Column
textAlign='right'
>
{valueView[1]}
{ value[1] }
</Grid.Column>
</Grid>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/shared-components",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of shared, framework agnostic, components.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/user-defined-fields/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/user-defined-fields",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand All @@ -23,8 +23,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/semantic-components": "^2.2.16",
"@performant-software/shared-components": "^2.2.16",
"@performant-software/semantic-components": "^2.2.17",
"@performant-software/shared-components": "^2.2.17",
"react": ">= 16.13.1 < 19.0.0",
"react-dom": ">= 16.13.1 < 19.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/visualize/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/visualize",
"version": "2.2.16",
"version": "2.2.17",
"description": "A package of components used for data visualization",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion react-components.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"packages/user-defined-fields",
"packages/visualize"
],
"version": "2.2.16"
"version": "2.2.17"
}

0 comments on commit 2ed9f39

Please sign in to comment.