-
Notifications
You must be signed in to change notification settings - Fork 843
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
EuiColorStops #2360
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
1e06162
WIP
thompsongl 317c77d
WIP: scaling clean up
thompsongl 68c21ef
reverse up/down keys
thompsongl efce438
add left/right movement
thompsongl 7dbf922
update test
thompsongl 6a10f68
doubleClick addStop; clean up; tests removal
thompsongl 44e74ee
use more range components directly
thompsongl 90c338c
Firefox cleanup
thompsongl 9719b81
i18n; refactor
thompsongl 2ce45d0
Merge branch 'master' into eui-color-stops
thompsongl 83fc325
WIP: add new stop via click
thompsongl 3b77831
clean up
thompsongl 006ba4e
better keyboard interaction
thompsongl d188f7d
add stop styles
ryankeairns 6907a02
Merge pull request #8 from ryankeairns/eui-color-stops
thompsongl a1ce7cf
empty set; backspace fix; drag handle fix
thompsongl f51cf46
readOnly and disabled
thompsongl b61bed9
screen reader
thompsongl 3f0b89d
more i18n
thompsongl 4f8efd5
cleanup of thumbs
snide a57ceff
Merge pull request #9 from snide/design/stop
thompsongl dd8b9c9
Update src/components/color_picker/color_stops/color_stop_thumb.tsx
thompsongl cd35b46
thumb title
thompsongl 783574c
required label
thompsongl d078fc8
misc feeback
thompsongl 32c7209
update zIndex for active thumb
thompsongl f6c0411
Merge branch 'master' into eui-color-stops
thompsongl 020a44b
docs refactor
thompsongl 90f6cf4
util; basic snapshot tests
thompsongl 7259d1a
color stops tests
thompsongl 5285b90
thumb snapshot tests
thompsongl 42ce462
CL
thompsongl 6b94aa5
use sorted array for add via keyboard location
thompsongl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { DisplayToggles } from '../form_controls/display_toggles'; | ||
import { | ||
EuiColorStops, | ||
EuiFormRow, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export const ColorStops = () => { | ||
const generateRandomColor = () => | ||
// https://www.paulirish.com/2009/random-hex-color-code-snippets/ | ||
`#${Math.floor(Math.random() * 16777215).toString(16)}`; | ||
|
||
const [addColor, setAddColor] = useState(generateRandomColor()); | ||
const [colorStops, setColorStops] = useState([ | ||
{ | ||
stop: 0, | ||
color: '#ff0000', | ||
}, | ||
{ | ||
stop: 25, | ||
color: '#FFFF00', | ||
}, | ||
{ | ||
stop: 45, | ||
color: '#008000', | ||
}, | ||
]); | ||
|
||
const handleChange = colorStops => { | ||
setColorStops(colorStops); | ||
setAddColor(generateRandomColor()); | ||
}; | ||
|
||
const [extendedColorStops, setExtendedColorStops] = useState([ | ||
{ | ||
stop: 100, | ||
color: '#ff0000', | ||
}, | ||
{ | ||
stop: 250, | ||
color: '#FFFF00', | ||
}, | ||
{ | ||
stop: 350, | ||
color: '#008000', | ||
}, | ||
]); | ||
|
||
const handleExtendedChange = colorStops => { | ||
setExtendedColorStops(colorStops); | ||
}; | ||
|
||
const [emptyColorStops, setEmptyColorStops] = useState([]); | ||
|
||
const handleEmptyChange = colorStops => { | ||
setEmptyColorStops(colorStops); | ||
}; | ||
|
||
const changeProps = () => { | ||
setColorStops([ | ||
{ | ||
stop: 0, | ||
color: '#ff0000', | ||
}, | ||
{ | ||
stop: 25, | ||
color: '#FFFF00', | ||
}, | ||
{ | ||
stop: 45, | ||
color: '#008000', | ||
}, | ||
]); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<button onClick={changeProps}>Prop Change</button> | ||
<EuiFormRow label="Empty start"> | ||
<EuiColorStops | ||
onChange={handleEmptyChange} | ||
colorStops={emptyColorStops} | ||
min={0} | ||
max={100} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Standard"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
fullWidth={true} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Random new color"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
addColor={addColor} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Extended range"> | ||
<EuiColorStops | ||
onChange={handleExtendedChange} | ||
colorStops={extendedColorStops} | ||
min={100} | ||
max={400} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Swatch-only mode"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
mode="swatch" | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Picker-only mode"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
mode="picker" | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Custom swatches"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
swatches={['#333', '#666', '#999', '#CCC']} | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Fixed color segments"> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
stopType="fixed" | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="xxl" /> | ||
|
||
<DisplayToggles canLoading={false}> | ||
<EuiColorStops | ||
onChange={handleChange} | ||
colorStops={colorStops} | ||
min={0} | ||
max={100} | ||
/> | ||
</DisplayToggles> | ||
</React.Fragment> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
@import 'color_picker_swatch'; | ||
@import 'hue'; | ||
@import 'saturation'; | ||
@import 'color_stops/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@import '../../form/range/_variables'; | ||
|
||
.euiColorStops:not(.euiColorStops-isDisabled) { | ||
&:focus { | ||
outline: 2px solid $euiFocusRingColor; | ||
} | ||
} | ||
|
||
.euiColorStops__addContainer { | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 50%; | ||
height: $euiRangeThumbHeight; | ||
margin-top: $euiRangeThumbHeight * -.5; | ||
|
||
&:hover:not(.euiColorStops__addContainer-isDisabled) { | ||
cursor: pointer; | ||
|
||
.euiColorStops__addTarget { | ||
opacity: .7; | ||
} | ||
} | ||
} | ||
|
||
.euiColorStops__addTarget { | ||
@include euiCustomControl($type: 'round'); | ||
@include euiRangeThumbStyle; | ||
position: absolute; | ||
top: 0; | ||
height: $euiRangeThumbHeight; | ||
width: $euiRangeThumbHeight; | ||
background-color: $euiColorLightestShade; | ||
pointer-events: none; | ||
opacity: 0; | ||
transition: opacity $euiAnimSpeedFast; | ||
} | ||
|
||
.euiColorStop { | ||
width: $euiColorPickerWidth; | ||
} | ||
|
||
.euiColorStopPopover.euiPopover { | ||
position: absolute; | ||
top: 50%; | ||
width: $euiRangeThumbWidth; | ||
height: $euiRangeThumbHeight; | ||
margin-top: $euiRangeThumbHeight * -.5; | ||
} | ||
|
||
.euiColorStopPopover__anchor { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.euiColorStopThumb.euiRangeThumb:not(:disabled) { | ||
top: 0; | ||
margin-top: 0; | ||
pointer-events: auto; | ||
cursor: grab; | ||
|
||
&:active { | ||
cursor: grabbing; | ||
} | ||
} | ||
|
||
.euiColorStops.euiColorStops-isDragging:not(.euiColorStops-isDisabled):not(.euiColorStops-isReadOnly) { | ||
cursor: grabbing; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'color_stops'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the
EuiFormRow
this components just floats on the page with no label and feels offThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the props weren't passed down correctly when I originally tried with a form row. I'll look again when I get to formal docs