Components: integrate g2 ColorCircle
with existing components
#33820
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the context of working on the Global Styles Sidebar, we're looking to move the prototype over to Gutenberg. One component that is used in the prototype is the g2
ColorCircle
component, which currently only exists in theg2
repository.The current situation
I had a look at
ColorCircle
in order to understand what functionality it packs.ColorCircle
visually represents a single color, and can also be interactive. The component has a few props:color
prop (obviously), which internally seems to be any value that thetinycolor2
library can parsevariant
prop has 2 values: whendefault
, the component will be in the shape of a circle. Whenpill
, the component will stretch to fill 100% of the available width (while keeping rounded ends)size
prop (small, medium, large)isInteractive
prop. When interactive, the cursor changes to a pointer, and visually reacts to being clicked/pressed and focusedisActive
prop is true, it displays a "tick" icon in the middleonClick
, which in the prototype is used to open aColorPicker
popover)After that, I looked at what components with a similar "scope" are currently available in Gutenberg, and I found a few components of interest. In particular:
ColorIndicator
: a very simple component, which as of now just shows a color inside a little rectangular<span />
. It doesn't offer any interactivity out of the box either.CircularOptionPicker
: this seems to be what is currently being used in Gutenberg for color swatches. I'm not particularly a fan of this "family" of components for a few reasons:CircularOptionPicker
is quite an opinionated and high-level componentColorCirle
, its name hints at the circular shape, which makes it much less flexible in terms of design updates. It also doesn't hint at all at the fact that it's mainly used for colors either (and therefore difficult to discover in the library<CircularOptionPicker.Option >
, which is not in line with other families of componentsThe next steps
Given all of the above, I'm not certain on what is the best way forward here:
ColorCircle
component over to Gutenberg would introduce too much overlap with existing components. On top of that, I don't believe thatColorCircle
is a good name either, since it will prevent the component from ever taking a different visual shape.ColorIndicator
by replacing its implementation with the one from g2'sColorCirlce
. We could tweak thevariant
prop and make thedefault
value look and behave like the current implementation of the component (and introduce acircle
variant, in addition topill
). But this would then introduce a significant overlap with theCircularOptionPicker
component.ColorCircle
in the prototype withCircularOptionPicker.Option
— although I'm not a fan at all of theCircularOptionPicker
components “family”, as highlighted above.ColorIndicator
andCircularOptionPicker
(as suggested by @griffbrad). We could either leave them as-is or refactor them to useColorCircle
internally (I doubt they're widely used outside of the higher-level palette and color picker components, so it's unlikely to both many 3rd-party devs)...or any other approach that I haven't listed! What do folks think is the best way forward?
The text was updated successfully, but these errors were encountered: