forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Allen Short
committed
Jan 14, 2019
1 parent
ee37ff9
commit c5137b1
Showing
6 changed files
with
155 additions
and
26 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
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
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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Select from 'antd/lib/select'; | ||
import 'antd/lib/select/style'; | ||
import { map } from 'lodash'; | ||
|
||
import { ColorPalette } from '@/visualizations/chart/plotly/utils'; | ||
|
||
|
||
const colors = { Automatic: null, ...ColorPalette }; | ||
const colorSelectItem = v => ( | ||
<span | ||
style={{ | ||
width: 12, | ||
height: 12, | ||
backgroundColor: v, | ||
display: 'inline-block', | ||
marginRight: 5, | ||
}} | ||
/>); | ||
const colorOptionItem = (v, k) => <span style={{ textTransform: 'capitalize' }}>{colorSelectItem(v)}{k}</span>; | ||
|
||
|
||
export default function ColorSelect(props) { | ||
return ( | ||
<Select | ||
defaultActiveFirstOption | ||
value={props.value || 'Automatic'} | ||
onChange={props.onChange} | ||
> | ||
{map(colors, (v, k) => <Select.Option key={v}>{colorOptionItem(v, k)}</Select.Option>)} | ||
</Select>); | ||
} | ||
|
||
ColorSelect.propTypes = { | ||
value: PropTypes.string.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
}; |
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