Skip to content

Commit

Permalink
Fixing coloring of a11y badges on colors page
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos committed Feb 21, 2020
1 parent cdcf880 commit 6a25012
Showing 1 changed file with 47 additions and 33 deletions.
80 changes: 47 additions & 33 deletions src-docs/src/views/guidelines/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ const allowedColors = [
'euiColorAccent',
];

const ratingAAA = <EuiBadge color="#000">AAA</EuiBadge>;

const ratingAA = <EuiBadge color="#333">AA</EuiBadge>;

const ratingAA18 = <EuiBadge color="#666">AA18</EuiBadge>;

function renderPaletteColor(palette, color, index, key) {
const hex = key ? palette[color][key] : palette[color];
const name = key && key !== 'graphic' ? `${color}_${key}` : color;
Expand Down Expand Up @@ -95,8 +89,50 @@ function renderPaletteColor(palette, color, index, key) {
export default class extends Component {
constructor(props) {
super(props);
this.state = {
value: '3',
behindTextVariant: false,
};
}

onChange = e => {
this.setState({
value: e.currentTarget.value,
});
};

onBehindTextVariantChange = e => {
this.setState({
behindTextVariant: e.target.checked,
});
};

this.levels = [
render() {
const { value, behindTextVariant } = this.state;
const { selectedTheme } = this.props;

const ratingAAA = (
<EuiBadge color={selectedTheme.includes('dark') ? '#EEE' : '#000'}>
AAA
</EuiBadge>
);
const ratingAA = (
<EuiBadge color={selectedTheme.includes('dark') ? '#666' : '#333'}>
AA
</EuiBadge>
);
const ratingAA18 = (
<EuiBadge color={selectedTheme.includes('dark') ? '#333' : '#666'}>
AA18
</EuiBadge>
);
const ratingAll = (
<EuiBadge color={selectedTheme.includes('dark') ? '#000' : '#EEE'}>
ALL
</EuiBadge>
);

const levels = [
{
min: 0,
max: 2.8,
Expand All @@ -114,10 +150,10 @@ export default class extends Component {
},
];

this.ticks = [
const ticks = [
{
value: 0,
label: <EuiBadge color="#eee">ALL</EuiBadge>,
label: ratingAll,
},
{
value: 3,
Expand All @@ -133,28 +169,6 @@ export default class extends Component {
},
];

this.state = {
value: '3',
behindTextVariant: false,
};
}

onChange = e => {
this.setState({
value: e.currentTarget.value,
});
};

onBehindTextVariantChange = e => {
this.setState({
behindTextVariant: e.target.checked,
});
};

render() {
const { value, behindTextVariant } = this.state;
const { selectedTheme } = this.props;

let palette;
if (selectedTheme === 'amsterdam-dark') {
palette = darkAmsterdamColors;
Expand Down Expand Up @@ -271,8 +285,8 @@ export default class extends Component {
onChange={this.onChange}
showTicks
showValue
levels={this.levels}
ticks={this.ticks}
levels={levels}
ticks={ticks}
valueAppend="+"
/>
</EuiFormRow>
Expand Down

0 comments on commit 6a25012

Please sign in to comment.