-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components: introducing ColorSwatch
and updating existing color-related components
#33820
Comments
Notes from the initial round of feedback: For the primitive component that represents a color, we proposed the name When it comes to those higher-level components, the Global Styles designs still call for something like ColorPalette/CircularOptionPicker. However, where those components appear and what responsibilities they assume will change. We noted that the custom color and clear/reset features of ColorPalette may be assumed by other components like the newly introduced ToolsPanel. And rather than rendering a palette of color options directly in the sidebar, we’ll be moving toward using ItemGroup to group color attributes (e.g. “Background Color”, “Text Color”, “Border Color”). In Global Styles, clicking an Item will drill-down to another sheet displaying the available color options and related components. In block sidebars, this action will likely result in a popover with similar controls. In the context of these ItemGroup components, we’ll have to consider how the current color selection is communicated to screen reader users and color blind users. |
ColorCircle
with existing componentsColorSwatch
and updating existing color-related components
To visualize this, there are some good mockups in #34574 that illustrate the behavior above. Instead of duplicating all available color palettes for each a single item in a group is shown as a swatch plus a label: Click an item in the group drills down to a dedicated subpanel showing all available color tools: |
Here's an additional mockup that shows how the full flow for collapsible color swatches could work when used in editor inspector panels: Please note that the precise visuals are subject to change per further work in #34574, so definitely defer to that ticket as the source of truth. Essentially, multiple color properties are grouped together in an ItemGroup, as swatch+label.
|
Closing in favour of #35093 |
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: