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

EuiColorStops #2360

Merged
merged 33 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1e06162
WIP
thompsongl Sep 20, 2019
317c77d
WIP: scaling clean up
thompsongl Sep 23, 2019
68c21ef
reverse up/down keys
thompsongl Sep 23, 2019
efce438
add left/right movement
thompsongl Sep 23, 2019
7dbf922
update test
thompsongl Sep 23, 2019
6a10f68
doubleClick addStop; clean up; tests removal
thompsongl Sep 23, 2019
44e74ee
use more range components directly
thompsongl Sep 23, 2019
90c338c
Firefox cleanup
thompsongl Sep 23, 2019
9719b81
i18n; refactor
thompsongl Sep 23, 2019
2ce45d0
Merge branch 'master' into eui-color-stops
thompsongl Sep 24, 2019
83fc325
WIP: add new stop via click
thompsongl Sep 24, 2019
3b77831
clean up
thompsongl Sep 24, 2019
006ba4e
better keyboard interaction
thompsongl Sep 25, 2019
d188f7d
add stop styles
ryankeairns Sep 25, 2019
6907a02
Merge pull request #8 from ryankeairns/eui-color-stops
thompsongl Sep 25, 2019
a1ce7cf
empty set; backspace fix; drag handle fix
thompsongl Sep 25, 2019
f51cf46
readOnly and disabled
thompsongl Sep 25, 2019
b61bed9
screen reader
thompsongl Sep 26, 2019
3f0b89d
more i18n
thompsongl Sep 26, 2019
4f8efd5
cleanup of thumbs
snide Sep 27, 2019
a57ceff
Merge pull request #9 from snide/design/stop
thompsongl Sep 30, 2019
dd8b9c9
Update src/components/color_picker/color_stops/color_stop_thumb.tsx
thompsongl Sep 30, 2019
cd35b46
thumb title
thompsongl Sep 30, 2019
783574c
required label
thompsongl Sep 30, 2019
d078fc8
misc feeback
thompsongl Sep 30, 2019
32c7209
update zIndex for active thumb
thompsongl Sep 30, 2019
f6c0411
Merge branch 'master' into eui-color-stops
thompsongl Oct 1, 2019
020a44b
docs refactor
thompsongl Oct 1, 2019
90f6cf4
util; basic snapshot tests
thompsongl Oct 1, 2019
7259d1a
color stops tests
thompsongl Oct 1, 2019
5285b90
thumb snapshot tests
thompsongl Oct 1, 2019
42ce462
CL
thompsongl Oct 1, 2019
6b94aa5
use sorted array for add via keyboard location
thompsongl Oct 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 176 additions & 38 deletions src-docs/src/views/color_picker/color_picker_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import { EuiCode, EuiColorPicker, EuiText } from '../../../../src/components';
import {
EuiCode,
EuiColorPicker,
EuiColorStops,
EuiSpacer,
EuiText,
} from '../../../../src/components';

import { ColorPicker } from './color_picker';
const colorPickerSource = require('!!raw-loader!./color_picker');
Expand All @@ -17,6 +23,36 @@ const colorPickerSnippet = `<EuiColorPicker
/>
`;

import { ColorStops } from './color_stops';
const colorStopsSource = require('!!raw-loader!./color_stops');
const colorStopsHtml = renderToHtml(ColorStops);
const colorStopsSnippetStandard = `<EuiColorStops
label="Standard"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
/>`;

const colorStopsSnippetAdd = `<EuiColorStops
label="Custom add color"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
addColor={colorToAddToNewStops}
/>`;

const colorStopsSnippetFixed = `<EuiColorStops
label="Fixed color segments"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
stopType="fixed"
/>
`;

import { CustomSwatches } from './custom_swatches';
const customSwatchesSource = require('!!raw-loader!./custom_swatches');
const customSwatchesHtml = renderToHtml(CustomSwatches);
Expand All @@ -31,6 +67,20 @@ const customSwatchesSnippet = `<EuiColorPicker
'#999',
'#CCC',
]}
/>`;

const stopCustomSwatchesSnippet = `<EuiColorStops
label="Swatches"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
swatches={[
'#333',
'#666',
'#999',
'#CCC',
]}
/>
`;

Expand Down Expand Up @@ -83,6 +133,26 @@ const modesPickerSnippet = `// Gradient map only
mode="picker"
/>
`;
const stopModesSwatchSnippet = `// Swatches only
<EuiColorStops
label="Swatch"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
mode="swatch"
/>
`;
const stopModesPickerSnippet = `// Gradient map only
<EuiColorStops
label="Picker"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
mode="picker"
/>
`;

import { Inline } from './inline';
const inlineSource = require('!!raw-loader!./inline');
Expand Down Expand Up @@ -120,30 +190,60 @@ const kitchenSinkSnippet = `<EuiColorPicker
]}
/>
`;
const stopKitchenSinkSnippet = `<EuiColorStops
label="All the things"
onChange={handleChange}
colorStops={colorStops}
min={0}
max={100}
mode="default"
addStop={#FFF}
swatches={[
'#333',
'#666',
'#999',
'#CCC',
'#FFF',
]}
/>
`;

export const ColorPickerExample = {
title: 'Color Picker',
title: 'Color Selection',
intro: (
<React.Fragment>
<EuiText>
<p>
Color input component allowing for multiple methods of entry and
selection.
</p>
<p>
Direct text entry will only match hexadecimal (hex) colors, and output
values only return hex values. Spatial selection involves HSV
manipulaton, which is converted to hex.
</p>
<p>
Swatches allow consumers to predefine preferred or suggested choices.
The swatches must also be entered in hex format.
Two components exist to aid color selection:{' '}
<EuiCode>EuiColorPicker</EuiCode> and <EuiCode>EuiColorStops</EuiCode>
.
</p>
</EuiText>
<EuiSpacer />
</React.Fragment>
),
sections: [
{
title: 'Color picker',
text: (
<React.Fragment>
<EuiText>
<p>
Color input component allowing for multiple methods of entry and
selection.
</p>
<p>
Direct text entry will only match hexadecimal (hex) colors, and
output values only return hex values. Spatial selection involves
HSV manipulaton, which is converted to hex.
</p>
<p>
Swatches allow consumers to predefine preferred or suggested
choices. The swatches must also be entered in hex format.
</p>
</EuiText>
</React.Fragment>
),
source: [
{
type: GuideSectionTypes.JS,
Expand All @@ -158,6 +258,38 @@ export const ColorPickerExample = {
snippet: colorPickerSnippet,
demo: <ColorPicker />,
},
{
title: 'Color stops',
text: (
<React.Fragment>
<EuiText>
<p>
Use <EuiCode>EuiColorStops</EuiCode> to define color stops for
data driven styling. Stops are numbers within the provided range.
The color segment spans from the given stop number (inclusive) to
the next stop number (exclusive).
</p>
</EuiText>
</React.Fragment>
),
source: [
{
type: GuideSectionTypes.JS,
code: colorStopsSource,
},
{
type: GuideSectionTypes.HTML,
code: colorStopsHtml,
},
],
props: { EuiColorStops },
snippet: [
colorStopsSnippetStandard,
colorStopsSnippetAdd,
colorStopsSnippetFixed,
],
demo: <ColorStops />,
},
{
title: 'Custom color swatches',
source: [
Expand All @@ -177,54 +309,59 @@ export const ColorPickerExample = {
the <EuiCode>swatches</EuiCode> prop.
</p>
),
snippet: customSwatchesSnippet,
snippet: [customSwatchesSnippet, stopCustomSwatchesSnippet],
demo: <CustomSwatches />,
},
{
title: 'Custom button',
title: 'Limited selection modes',
source: [
{
type: GuideSectionTypes.JS,
code: customButtonSource,
code: modesSource,
},
{
type: GuideSectionTypes.HTML,
code: customButtonHtml,
code: modesHtml,
},
],
text: (
<p>
You can optionally use a custom button as the trigger for selection
using the <EuiCode>button</EuiCode> prop. Please remember to add
accessibility to this component, using proper button markup and aria
labeling.
By default, both swatch selection and the gradient color map will be
rendered. Use the <EuiCode>mode</EuiCode> prop to pass `swatch` for
swatch-only selection, or pass `picker` for gradient map and hue
slider selection without swatches.
</p>
),
snippet: [customButtonSnippet, customBadgeSnippet],
demo: <CustomButton />,
snippet: [
modesSwatchSnippet,
modesPickerSnippet,
stopModesSwatchSnippet,
stopModesPickerSnippet,
],
demo: <Modes />,
},
{
title: 'Limited selection modes',
title: 'Custom button',
source: [
{
type: GuideSectionTypes.JS,
code: modesSource,
code: customButtonSource,
},
{
type: GuideSectionTypes.HTML,
code: modesHtml,
code: customButtonHtml,
},
],
text: (
<p>
By default, both swatch selection and the gradient color map will be
rendered. Use the <EuiCode>mode</EuiCode> prop to pass `swatch` for
swatch-only selection, or pass `picker` for gradient map and hue
slider selection without swatches.
Available only in <EuiCode>EuiColorPicker</EuiCode>. You can
optionally use a custom button as the trigger for selection using the{' '}
<EuiCode>button</EuiCode> prop. Please remember to add accessibility
to this component, using proper button markup and aria labeling.
</p>
),
snippet: [modesSwatchSnippet, modesPickerSnippet],
demo: <Modes />,
snippet: [customButtonSnippet, customBadgeSnippet],
demo: <CustomButton />,
},
{
title: 'Inline',
Expand All @@ -240,8 +377,9 @@ export const ColorPickerExample = {
],
text: (
<p>
Set the <EuiCode>display</EuiCode> prop to `inline` to display the
color picker without an input or popover. Note that the{' '}
Available only in <EuiCode>EuiColorPicker</EuiCode>. Set the{' '}
<EuiCode>display</EuiCode> prop to `inline` to display the color
picker without an input or popover. Note that the{' '}
<EuiCode>button</EuiCode> prop will be ignored in this case.
</p>
),
Expand All @@ -262,15 +400,15 @@ export const ColorPickerExample = {
],
text: (
<p>
Demonstrating that <EuiCode>EuiColorPicker</EuiCode> can exist in
portal containers and that its popover position works in nested
Demonstrating that both color selection components can exist in portal
containers and that their popover positioning works in nested
contexts.
</p>
),
demo: <Containers />,
},
{
title: 'Kitchen sink',
title: 'Option toggling',
source: [
{
type: GuideSectionTypes.JS,
Expand All @@ -281,7 +419,7 @@ export const ColorPickerExample = {
code: kitchenSinkHtml,
},
],
snippet: kitchenSinkSnippet,
snippet: [kitchenSinkSnippet, stopKitchenSinkSnippet],
demo: <KitchenSink />,
},
],
Expand Down
Loading