Skip to content
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

ColorPicker component - Research #31927

Open
ValentinaKozlova opened this issue Jul 4, 2024 · 0 comments
Open

ColorPicker component - Research #31927

ValentinaKozlova opened this issue Jul 4, 2024 · 0 comments

Comments

@ValentinaKozlova
Copy link
Contributor

ValentinaKozlova commented Jul 4, 2024

Intro

The ColorPicker is used to browse through and select colors. By default, it lets people navigate through colors on a color spectrum; or specify a color in either Red-Green-Blue (RGB); or alpha color code; or Hexadecimal textboxes.

Layout variants:

Vertical

When color names and button on the bottom side
image

Horizontal

When color names and buttons from the right side
image

Choosing color on click in React spectrum

image

Props

ColorPicker

  • defaultValue
  • value
  • onChange
  • sliderShape - some partners might want to change a shape

ColorSlider
AlphaChannelSlider
PreviewBox:

  • shape
  • size

Example of existing (V8) ColorPicker

[Add a picture here]

https://developer.microsoft.com/en-us/fluentui#/controls/web/colorpicker
https://learn.microsoft.com/en-us/windows/apps/design/controls/color-picker


Fabric (v8)

import * as React from 'react';
import {
  ColorPicker,
  ChoiceGroup,
  IChoiceGroupOption,
  getColorFromString,
  IColor,
  IColorPickerStyles,
  IColorPickerProps,
} from '@fluentui/react';

const white = getColorFromString('#ffffff')!;

const ColorPickerBasicExample: React.FunctionComponent = () => {
  const [color, setColor] = React.useState(white);
  const [showPreview, setShowPreview] = React.useState(true);
  const [alphaType, setAlphaType] = React.useState<IColorPickerProps['alphaType']>('alpha');

  const updateColor = React.useCallback((ev: any, colorObj: IColor) => setColor(colorObj), []);

  return (
    <div>
      <div id={`${baseId}-circle`}>Simple circle swatch color picker:</div>
      <ColorPicker
        color={color}
        onChange={updateColor}
        alphaType={alphaType}
        showPreview={showPreview}
        styles={colorPickerStyles}
        // The ColorPicker provides default English strings for visible text.
        // If your app is localized, you MUST provide the `strings` prop with localized strings.
        strings={{
          // By default, the sliders will use the text field labels as their aria labels.
          // Previously this example had more detailed instructions in the labels, but this is
          // a bad practice and not recommended. Labels should be concise, and match visible text when possible.
          hueAriaLabel: 'Hue',
        }}
      />
    </div>
  );
};

Component structure

ColorPicker component

Color picker can contain sub-components:

  • Gradient preview
  • Color slider
  • Alpha channel slider
  • Preview box (can have shapes)
  • Color values

Color format:

  • HEX
  • RGB(A)
  • named color

Questions:

Notes:

Resources:

For learning and research I used Adobe DS: https://react-spectrum.adobe.com/react-spectrum/ColorPicker.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant