Skip to content

Commit

Permalink
enhance(ColorPicker): additional positions for color picker modal layout
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschlapbach committed Aug 30, 2024
1 parent e40a6f5 commit 265a2b0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
42 changes: 32 additions & 10 deletions packages/design-system/src/ColorPicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,38 @@ export const Position = () => {
position prop allows to define different default positions. Others can
be added using the className override.
</div>
<ColorPicker
position="top"
color={color}
onSubmit={(newColor) => {
setColor(newColor)
alert('Color set to ' + newColor)
}}
submitText="Save"
colorLabel="Color"
/>
<div className="flex flex-col gap-4">
<ColorPicker
position="top"
color={color}
onSubmit={(newColor) => {
setColor(newColor)
alert('Color set to ' + newColor)
}}
submitText="Save"
colorLabel="Color"
/>
<ColorPicker
position="top-left"
color={color}
onSubmit={(newColor) => {
setColor(newColor)
alert('Color set to ' + newColor)
}}
submitText="Save"
colorLabel="Color"
/>
<ColorPicker
position="bottom-left"
color={color}
onSubmit={(newColor) => {
setColor(newColor)
alert('Color set to ' + newColor)
}}
submitText="Save"
colorLabel="Color"
/>
</div>
</div>
)
}
Expand Down
4 changes: 3 additions & 1 deletion packages/design-system/src/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ColorPickerProps {
disabled?: boolean
triggerIcon?: IconDefinition
presetColors?: string[]
position?: 'bottom' | 'top'
position?: 'bottom' | 'top' | 'bottom-left' | 'top-left'
submitText: string
colorLabel: string
tooltip?: string | React.ReactNode
Expand Down Expand Up @@ -149,6 +149,8 @@ export function ColorPicker({
'absolute flex h-[10rem] w-[23rem] flex-row rounded-md bg-white p-1 shadow-md outline outline-2 outline-uzh-grey-40',
position === 'bottom' && 'left-10 top-8',
position === 'top' && 'bottom-8 left-10',
position === 'bottom-left' && '-left-[18rem] top-8',
position === 'top-left' && '-left-[18rem] bottom-8',
className?.popover
)}
ref={overlayRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/src/forms/FormikColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface FormikColorPickerProps {
disabled?: boolean
triggerIcon?: IconDefinition
presetColors?: string[]
position?: 'bottom' | 'top'
position?: 'bottom' | 'top' | 'bottom-left' | 'top-left'
submitText: string
colorLabel: string
colorTooltip?: string
Expand Down

0 comments on commit 265a2b0

Please sign in to comment.