Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankeairns committed Aug 29, 2018
1 parent a44309e commit a4e9593
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
7 changes: 3 additions & 4 deletions src-docs/src/views/stat/stat_colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export default () => (
<EuiFlexItem>
<EuiStat
title="1"
description="Full color"
titleColor="full"
description="Default color"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiStat
title="10"
description="Dark color"
titleColor="dark"
description="Subdued color"
titleColor="subdued"
/>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/stat/stat_combos.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default () => (
<EuiStat
title="8,888"
description="Total widgets"
titleColor="full"
textAlign="right"
>
<EuiIcon type="empty" />
Expand Down
22 changes: 10 additions & 12 deletions src/components/stat/__snapshots__/stat.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ exports[`EuiStat is rendered 1`] = `
class="euiStat euiStat--leftAligned testClass1 testClass2"
data-test-subj="test subject string"
>
<div>
<div
class="euiText euiText--small euiStat__description"
>
<p>
description
</p>
</div>
<p
class="euiTitle euiTitle--large euiStat__title"
>
title
<div
class="euiText euiText--small euiStat__description"
>
<p>
description
</p>
</div>
<p
class="euiTitle euiTitle--large euiStat__title"
>
title
</p>
</div>
`;
19 changes: 10 additions & 9 deletions src/components/stat/_stat.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
.euiStat {
// Modifier naming and colors.
$titleColors: (
dark: $euiColorDarkShade,
full: $euiColorFullShade,
subdued: $euiColorDarkShade,
primary: $euiColorPrimary,
secondary: $euiColorSecondary,
danger: $euiColorDanger,
accent: $euiColorAccent,
);

// Create color classes based upon the map.
@each $name, $color in $titleColors {
&--#{$name} .euiStat__title {
color: $color;
.euiStat__title {
color: $euiColorFullShade;

// Create color classes based upon the map.
@each $name, $color in $titleColors {
&--#{$name} {
color: $color;
}
}
}

color: map-get($titleColors, full);

.eui__description {
.euiStat__description {
color: map-get($titleColors, dark);
}

Expand Down
29 changes: 16 additions & 13 deletions src/components/stat/stat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -7,12 +7,11 @@ import { EuiTitle, TITLE_SIZES } from '../title/title';

const colorToClassNameMap = {
default: null,
dark: 'euiStat--dark',
full: 'euiStat--full',
primary: 'euiStat--primary',
secondary: 'euiStat--secondary',
danger: 'euiStat--danger',
accent: 'euiStat--accent',
subdued: 'euiStat__title--dark',
primary: 'euiStat__title--primary',
secondary: 'euiStat__title--secondary',
danger: 'euiStat__title--danger',
accent: 'euiStat__title--accent',
};

export const COLORS = Object.keys(colorToClassNameMap);
Expand All @@ -39,19 +38,23 @@ export const EuiStat = ({

const classes = classNames(
'euiStat',
colorToClassNameMap[titleColor],
textAlignToClassNameMap[textAlign],
className,
);

const titleClasses = classNames(
'euiStat__title',
colorToClassNameMap[titleColor],
);

const descriptionDisplay = (
<EuiText size="s" className="euiStat__description">
<p>{description}</p>
</EuiText>
);

const titleDisplay = (
<EuiTitle size={titleSize} className="euiStat__title">
<EuiTitle size={titleSize} className={titleClasses}>
<p>{title}</p>
</EuiTitle>
);
Expand All @@ -60,17 +63,17 @@ export const EuiStat = ({

if (reverse) {
statDisplay = (
<div>
<Fragment>
{titleDisplay}
{descriptionDisplay}
</div>
</Fragment>
);
} else {
statDisplay = (
<div>
<Fragment>
{descriptionDisplay}
{titleDisplay}
</div>
</Fragment>
);
}

Expand Down

0 comments on commit a4e9593

Please sign in to comment.