Skip to content

Commit

Permalink
fix js errors, tweak coloring, make badges default to span
Browse files Browse the repository at this point in the history
  • Loading branch information
snide committed Mar 12, 2018
1 parent fe9d522 commit ac5f9f2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 43 deletions.
32 changes: 13 additions & 19 deletions src-docs/src/views/guidelines/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ const allowedColors = [
'euiColorAccent',
]

function renderPaletteColor(color) {
return (
<EuiFlexItem>
<div style={{ background: lightColors[color].rgba, height: 32 }} />
<div style={{ padding: '16px 16px 32px 16px' }}>
<p><strong>{color}</strong></p>
<EuiSpacer size="s" />
<p>RGB {lightColors[color].r}, {lightColors[color].g}, {lightColors[color].b}</p>
<EuiSpacer size="xs" />
<p>HEX {rgbToHex(lightColors[color].rgba).toUpperCase()}</p>
</div>
</EuiFlexItem>
);
}

export default() => (
<GuidePage title="Color guidelines">
<EuiText>
Expand All @@ -76,7 +61,16 @@ export default() => (

<EuiFlexGrid columns={3}>
{allowedColors.map(function(color, index) {
return renderPaletteColor(color);
<EuiFlexItem key={index}>
<div style={{ background: lightColors[color].rgba, height: 32 }} />
<div style={{ padding: '16px 16px 32px 16px' }}>
<p><strong>{color}</strong></p>
<EuiSpacer size="s" />
<p>RGB {lightColors[color].r}, {lightColors[color].g}, {lightColors[color].b}</p>
<EuiSpacer size="xs" />
<p>HEX {rgbToHex(lightColors[color].rgba).toUpperCase()}</p>
</div>
</EuiFlexItem>
})}
</EuiFlexGrid>

Expand Down Expand Up @@ -115,7 +109,7 @@ export default() => (
<div>
{allowedColors.map(function(color, index) {
return (
<Fragment>
<Fragment key={index}>
<EuiFlexGroup gutterSize="none">
{allowedColors.map(function(color2, index) {
const contrast = (
Expand All @@ -133,14 +127,14 @@ export default() => (
<EuiBadge color="#000">AAA</EuiBadge>
</div>
);
} else if (contrast > 4.5) {
} else if (contrast > 4.4) {
contrastRating = (
<div>
<EuiSpacer size="xs" />
<EuiBadge color="#333">AA</EuiBadge>
</div>
);
} else if (contrast > 3) {
} else if (contrast >= 2.9) {
contrastRating = (
<div>
<EuiSpacer size="xs" />
Expand Down
40 changes: 20 additions & 20 deletions src/components/badge/__snapshots__/badge.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiBadge is rendered 1`] = `
<div
<span
aria-label="aria-label"
class="euiBadge euiBadge--default testClass1 testClass2"
data-test-subj="test subject string"
Expand All @@ -13,11 +13,11 @@ exports[`EuiBadge is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color accent is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--accent"
>
<span
Expand All @@ -27,11 +27,11 @@ exports[`EuiBadge props color accent is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color danger is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--danger"
>
<span
Expand All @@ -41,11 +41,11 @@ exports[`EuiBadge props color danger is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color default is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--default"
>
<span
Expand All @@ -55,11 +55,11 @@ exports[`EuiBadge props color default is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color primary is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--primary"
>
<span
Expand All @@ -69,11 +69,11 @@ exports[`EuiBadge props color primary is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color secondary is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--secondary"
>
<span
Expand All @@ -83,11 +83,11 @@ exports[`EuiBadge props color secondary is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props color warning is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--warning"
>
<span
Expand All @@ -97,11 +97,11 @@ exports[`EuiBadge props color warning is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props iconSide left is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--default"
>
<span
Expand Down Expand Up @@ -129,11 +129,11 @@ exports[`EuiBadge props iconSide left is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props iconSide right is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--iconRight euiBadge--default"
>
<span
Expand Down Expand Up @@ -161,11 +161,11 @@ exports[`EuiBadge props iconSide right is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;

exports[`EuiBadge props iconType is rendered 1`] = `
<div
<span
class="euiBadge euiBadge--default"
>
<span
Expand Down Expand Up @@ -193,5 +193,5 @@ exports[`EuiBadge props iconType is rendered 1`] = `
Content
</span>
</span>
</div>
</span>
`;
4 changes: 2 additions & 2 deletions src/components/badge/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const EuiBadge = ({
);
} else {
return (
<div
<span
className={classes}
style={optionalCustomStyles}
{...rest}
Expand All @@ -109,7 +109,7 @@ export const EuiBadge = ({
{children}
</span>
</span>
</div>
</span>
);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/global_styling/variables/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
// Core

$euiColorPrimary: #0079a5 !default;
$euiColorSecondary: #018277 !default;
$euiColorSecondary: #017F75 !default;
$euiColorAccent: #DD0A73 !default;
$euiColorHighlight: #FFFBF1 !default;
$euiColorGhost: #FFF !default;

// Status
$euiColorSuccess: $euiColorSecondary !default;
$euiColorDanger: #A30000 !default;
$euiColorWarning: darken(#D95221, 3%) !default;
$euiColorWarning: #C34A1E !default;

// Grays
$euiColorEmptyShade: #FFF !default;
Expand Down

0 comments on commit ac5f9f2

Please sign in to comment.