-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Apr 17, 2019
1 parent
e895556
commit 99e66e1
Showing
10 changed files
with
293 additions
and
123 deletions.
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
58 changes: 58 additions & 0 deletions
58
website/src/components/controls/InheritedColorModifierControl.js
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,58 @@ | ||
/* | ||
* This file is part of the nivo project. | ||
* | ||
* (c) 2016 Raphaël Benitte | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import Select from './Select' | ||
import TextInput from './TextInput' | ||
|
||
const modifierTypes = ['brighter', 'darker', 'opacity'].map(prop => ({ | ||
label: prop, | ||
value: prop, | ||
})) | ||
|
||
const InheritedColorModifierControl = ({ modifier, onChange }) => { | ||
return ( | ||
<Container> | ||
<Select | ||
options={modifierTypes} | ||
value={modifierTypes.find(prop => prop.value === modifier[0])} | ||
onChange={value => onChange([value.value, modifier[1]])} | ||
/> | ||
<TextInput | ||
value={modifier[1]} | ||
isNumber={true} | ||
onChange={event => onChange([modifier[0], event.target.value])} | ||
/> | ||
<input | ||
type="range" | ||
value={modifier[1]} | ||
min={0} | ||
max={2} | ||
step={0.1} | ||
onChange={event => onChange([modifier[0], event.target.value])} | ||
/> | ||
</Container> | ||
) | ||
} | ||
|
||
InheritedColorModifierControl.propTypes = { | ||
modifier: PropTypes.array.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
} | ||
|
||
export default InheritedColorModifierControl | ||
|
||
const Container = styled.div` | ||
display: grid; | ||
grid-template-columns: 110px 40px auto; | ||
margin-bottom: 5px; | ||
align-items: center; | ||
grid-column-gap: 12px; | ||
` |
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
Oops, something went wrong.