Skip to content

Commit

Permalink
Merge branch 'master' into shrey15
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos authored Jun 23, 2020
2 parents 553b683 + 70cc30f commit 50b5be3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Exported `EuiCardProps` and `EuiCheckableCardProps` types ([#3640](https://github.com/elastic/eui/pull/3640))
- Added `gutterSize` prop to `EuiFacetGroup` ([#3639](https://github.com/elastic/eui/pull/3639))

## [`26.0.1`](https://github.com/elastic/eui/tree/v26.0.1)
Expand Down
85 changes: 27 additions & 58 deletions src-docs/src/views/elastic_charts/theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EuiSpacer,
EuiFlexGroup,
EuiFlexItem,
EuiSuperSelect,
EuiColorPalettePicker,
} from '../../../../src/components';

import {
Expand All @@ -32,6 +32,7 @@ import {
euiPalettePositive,
euiPaletteGray,
} from '../../../../src/services';

const paletteData = {
euiPaletteColorBlind,
euiPaletteForStatus,
Expand All @@ -43,22 +44,29 @@ const paletteData = {
euiPaletteWarm,
euiPaletteGray,
};

const paletteNames = Object.keys(paletteData);

export const Theming = () => {
const themeContext = useContext(ThemeContext);

/**
* Create palette select
*/
const paletteOptions = paletteNames.map((paletteName, index) =>
createPaletteOption(paletteName, index)
);
const palettes = paletteNames.map((paletteName, index) => {
const options =
index > 0
? 10
: {
sortBy: 'natural',
};

return {
value: paletteName,
title: paletteName,
palette: paletteData[paletteNames[index]](options),
type: 'fixed',
};
});

const [barPalette, setBarPalette] = useState('0');
const onBarPaletteChange = value => {
setBarPalette(value);
};
const [barPalette, setBarPalette] = useState('euiPaletteColorBlind');

/**
* Create data
Expand All @@ -75,12 +83,14 @@ export const Theming = () => {
? EUI_CHARTS_THEME_DARK.theme
: EUI_CHARTS_THEME_LIGHT.theme;

const barPaletteIndex = paletteNames.findIndex(item => item === barPalette);

const customTheme =
Number(barPalette) > 0
barPaletteIndex > 0
? [
{
colors: {
vizColors: paletteData[paletteNames[Number(barPalette)]](5),
vizColors: paletteData[paletteNames[barPaletteIndex]](5),
},
},
theme,
Expand Down Expand Up @@ -113,55 +123,14 @@ export const Theming = () => {
</Chart>
<EuiSpacer size="xxl" />
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiSuperSelect
id="setChartBarColor"
options={paletteOptions}
<EuiFlexItem grow={false} style={{ width: 300 }}>
<EuiColorPalettePicker
palettes={palettes}
onChange={setBarPalette}
valueOfSelected={barPalette}
onChange={onBarPaletteChange}
aria-label="Bars color palette"
style={{ width: 300 }}
/>
</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
);
};

const createPaletteOption = function(paletteName, index) {
const options =
index > 0
? 10
: {
sortBy: 'natural',
};

return {
value: String(index),
inputDisplay: createPalette(paletteData[paletteNames[index]](options)),
dropdownDisplay: (
<Fragment>
<strong>{paletteName}</strong>
<EuiSpacer size="xs" />
{createPalette(paletteData[paletteNames[index]](options))}
</Fragment>
),
};
};

const createPalette = function(palette) {
return (
<EuiFlexGroup
className="guideColorPalette__swatchHolder"
gutterSize="none"
responsive={false}>
{palette.map(hexCode => (
<EuiFlexItem
key={hexCode}
className={'guideColorPalette__swatch--small'}>
<span title={hexCode} style={{ backgroundColor: hexCode }} />
</EuiFlexItem>
))}
</EuiFlexGroup>
);
};
2 changes: 1 addition & 1 deletion src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const displayToClassNameMap: { [display in CardDisplay]: string } = {

export const DISPLAYS = keysOf(displayToClassNameMap);

type EuiCardProps = Omit<CommonProps, 'aria-label'> & {
export type EuiCardProps = Omit<CommonProps, 'aria-label'> & {
/**
* Card's are required to have at least a title and description
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { EuiCard } from './card';
export { EuiCheckableCard } from './checkable_card';
export { EuiCard, EuiCardProps } from './card';
export { EuiCheckableCard, EuiCheckableCardProps } from './checkable_card';

0 comments on commit 50b5be3

Please sign in to comment.