Skip to content

Commit

Permalink
(mostly) fix ColorPicker popover
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Nov 6, 2023
1 parent d7a71dd commit 2e31611
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/components/common/Colors/ColorPicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import _ from 'lodash';
import Popover from 'react-tiny-popover';
import { Popover } from 'react-tiny-popover';
import Icon from 'components/common/Icon/Icon';
import ColorList from './ColorList';

Expand Down Expand Up @@ -84,7 +84,7 @@ const ColorPickerWrapper = ({
onColorSelect(hexColor);
};

const iconToggle = (
const IconToggle = React.forwardRef(() => (
<Icon
height={24}
width={24}
Expand All @@ -93,9 +93,9 @@ const ColorPickerWrapper = ({
}}
bgColor={selectedColor}
/>
);
));

const buttonToggle = (
const ButtonToggle = React.forwardRef(() => (
<button
style={{ gridColumn: 'span 3' }}
type="button"
Expand All @@ -105,16 +105,15 @@ const ColorPickerWrapper = ({
>
{title}
</button>
);

));
return (
<>
<Popover
isOpen={visible}
position={['bottom', 'right', 'left', 'top']}
positions={['bottom', 'right', 'left', 'top']}
padding={25}
onClickOutside={() => {
toggleVisible(!visible);
toggleVisible(true);
}}
containerStyle={{ zIndex: 100, boxShadow: 'black 3px 3px 1px' }}
transitionDuration={0.001}
Expand All @@ -129,8 +128,7 @@ const ColorPickerWrapper = ({
);
}}
>
{type === 'icon' && iconToggle}
{type === 'button' && buttonToggle}
{type === 'icon' ? <IconToggle /> : <ButtonToggle />}
</Popover>
</>
);
Expand Down

0 comments on commit 2e31611

Please sign in to comment.