Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Sep 18, 2024
1 parent c6f5135 commit 766463c
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 581 deletions.
58 changes: 34 additions & 24 deletions src/app/content/highlights/components/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ function nextIdx(idx: number, itemCount: number, key: NavKeys) {
return idx;
}

// tslint:disable-next-line:variable-name
const FSWrapper = styled.fieldset`
border: 0;
display: flex;
flex-direction: row;
`;

// tslint:disable-next-line:variable-name
const ColorPicker = ({className, ...props}: Props) => {
const ref = React.useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -120,36 +127,39 @@ const ColorPicker = ({className, ...props}: Props) => {
React.useEffect(focusOnSelected, [focusOnSelected]);

return (
<fieldset
className={className}
tabIndex={0}
ref={ref}
onKeyDown={handleKeyNavigation}
onFocus={focusOnSelected}
role='radiogroup'
>
<legend>Choose highlight color</legend>
{highlightStyles.map((style) => <ColorButton key={style.label}
name={style.label}
checked={props.multiple ? props.selected.includes(style.label) : props.color === style.label}
style={style}
size={props.size}
tabIndex={-1}
onChange={() => props.multiple
? props.selected.includes(style.label)
? props.onChange(props.selected.filter(not(match(style.label))))
: props.onChange([...props.selected, style.label])
: props.color === style.label
? props.onRemove ? props.onRemove() : null
: props.onChange(style.label)}
/>)}
<FSWrapper>
<legend>Select or clear highlight color</legend>
<fieldset
className={className}
tabIndex={0}
ref={ref}
onKeyDown={handleKeyNavigation}
onFocus={focusOnSelected}
role='radiogroup'
>
<legend>Choose highlight color</legend>
{highlightStyles.map((style) => <ColorButton key={style.label}
name={style.label}
checked={props.multiple ? props.selected.includes(style.label) : props.color === style.label}
style={style}
size={props.size}
tabIndex={-1}
onChange={() => props.multiple
? props.selected.includes(style.label)
? props.onChange(props.selected.filter(not(match(style.label))))
: props.onChange([...props.selected, style.label])
: props.color === style.label
? props.onRemove ? props.onRemove() : null
: props.onChange(style.label)}
/>)}
</fieldset>
{ (!hasOnRemove || props.size === 'small') ? null :
<TrashButton
size={props.size}
onClick={props.onRemove}
/>
}
</fieldset>
</FSWrapper>
);
};

Expand Down
Loading

0 comments on commit 766463c

Please sign in to comment.