Skip to content

Commit

Permalink
Implement ColorPickerField
Browse files Browse the repository at this point in the history
  • Loading branch information
veej committed Oct 2, 2023
1 parent 5bd6395 commit 5939682
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function ColorPickerField(props: Props) {

const state = useSelectState({
...props,
<<<<<<< HEAD
selectedKey: props.value,
isDisabled: props.disabled,
children: getColorItems(props.colors),
Expand All @@ -94,6 +95,12 @@ export function ColorPickerField(props: Props) {
if (item) {
props.onChange(item.textValue);
}
=======
isDisabled: props.disabled,
children: getColorItems(props.colors),
onSelectionChange: (key) => {
props.onChange(state.collection.getItem(key)!.textValue);
>>>>>>> e2d57964 (Implement ColorPickerField)
},
});

Expand Down Expand Up @@ -145,7 +152,11 @@ export function ColorPickerField(props: Props) {
>
<Box {...valueProps} flexGrow={1} textAlign="left">
<Body size={inputConfig.fontSize} color={props.disabled ? "disabled" : "primary"}>
<<<<<<< HEAD
{state.selectedItem ? state.selectedItem.rendered : ""}
=======
{props.value}
>>>>>>> e2d57964 (Implement ColorPickerField)
</Body>
</Box>
<Box paddingLeft={16} aria-hidden="true">
Expand All @@ -157,7 +168,17 @@ export function ColorPickerField(props: Props) {
</Box>
{state.isOpen && (
<Popover triggerRef={ref} onClose={state.close}>
<<<<<<< HEAD
<PalettesDropdown colors={props.colors} state={state} menuProps={menuProps} />
=======
<PalettesDropdown
colors={props.colors}
value={props.value}
onChange={props.onChange}
state={state}
menuProps={menuProps}
/>
>>>>>>> e2d57964 (Implement ColorPickerField)
</Popover>
)}
</Field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Card, Divider, Inline, Label, Stack } from "@buildo/bento-design-system";
<<<<<<< HEAD
import { ThemeConfig, useConfiguratorStatusContext } from "../ConfiguratorStatusContext";
import { colorBoxRecipe } from "./PalettesDropdown.css";
import { SelectState } from "@react-stately/select";
Expand All @@ -10,6 +11,19 @@ import { PaletteName, getPalette, getPaletteKeyColor } from "../utils/paletteUti

type Props = {
colors: ThemeConfig["colors"];
=======
import { ThemeConfig } from "../ConfiguratorStatusContext";
import { colorBoxRecipe } from "./PalettesDropdown.css";
import { SelectState } from "@react-stately/select";
import { AriaListBoxOptions, useListBox, useOption } from "@react-aria/listbox";
import { Key, useRef } from "react";
import { useTranslation } from "react-i18next";

type Props = {
colors: ThemeConfig["colors"];
value: string | null;
onChange: (value: string) => void;
>>>>>>> e2d57964 (Implement ColorPickerField)
state: SelectState<object>;
menuProps: AriaListBoxOptions<object>;
};
Expand Down

0 comments on commit 5939682

Please sign in to comment.