Skip to content

Commit

Permalink
add back color limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogiampieri committed Nov 14, 2024
1 parent 6c7fb75 commit c5eacec
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/app/components/sidebar/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Button, Checkbox, CheckboxGroup} from '@radix-ui/themes';
import {styled} from '@stitches/react';
import * as RadioGroup from '@radix-ui/react-radio-group';
import {blackA} from '@radix-ui/colors';
import {useMapStore} from '@/app/store/mapStore';

type ColorPickerProps<T extends boolean = false> = T extends true
? {
Expand All @@ -27,6 +28,8 @@ export const ColorPicker = <T extends boolean>({
colorArray,
multiple,
}: ColorPickerProps<T>) => {
const mapDocument = useMapStore(state => state.mapDocument);

if (multiple) {
return (
<div>
Expand Down Expand Up @@ -63,11 +66,12 @@ export const ColorPicker = <T extends boolean>({
value={value !== undefined ? colorArray[value] : undefined}
defaultValue={colorArray[defaultValue]}
>
{colorArray.map((color, i) => (
<RadioGroupItem key={i} style={{backgroundColor: color}} value={color}>
<RadioGroupIndicator />
</RadioGroupItem>
))}
{mapDocument &&
colorArray.slice(0, mapDocument.num_districts ?? 0).map((color, i) => (
<RadioGroupItem key={i} style={{backgroundColor: color}} value={color}>
<RadioGroupIndicator />
</RadioGroupItem>
))}
</RadioGroupRoot>
</div>
);
Expand Down

0 comments on commit c5eacec

Please sign in to comment.