Skip to content

Commit

Permalink
Card theme title parity and margin fix (#704)
Browse files Browse the repository at this point in the history
Adjustments for the look of card titles.
  • Loading branch information
snide authored Apr 25, 2018
1 parent 2eb26b6 commit f932145
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Bug fixes**

- Fixed inherited `line-height` of inputs and buttons ([#702](https://github.com/elastic/eui/pull/702))
- Fixed card title sizing in K6 theme. ([#704](https://github.com/elastic/eui/pull/704))

## [`0.0.43`](https://github.com/elastic/eui/tree/v0.0.43)

Expand Down
3 changes: 0 additions & 3 deletions src/components/card/__snapshots__/card.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ exports[`EuiCard is rendered 1`] = `
class="euiCard euiCard--centerAligned testClass1 testClass2"
data-test-subj="test subject string"
>
<span
class="euiCard__top"
/>
<span
class="euiCard__content"
>
Expand Down
11 changes: 8 additions & 3 deletions src/components/card/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import "../panel/mixins";

$euiCardSpacing: map-get($euiPanelPaddingModifiers, "paddingMedium");
$euiCardTitleSize: 18px; // Hardcoded pixel value for theme parity.

// Start with a base of EuiPanel styles
@include euiPanel($selector: 'euiCard');
Expand Down Expand Up @@ -79,14 +80,18 @@ $euiCardSpacing: map-get($euiPanelPaddingModifiers, "paddingMedium");
}
}

// If an icon or image exists, add some space
.euiCard__top + .euiCard__content {
margin-top: $euiCardSpacing;
}

.euiCard__content {
flex-grow: 1; /* 1 */

.euiCard__title {
display: block;
margin-top: $euiCardSpacing;
@include euiTitle($euiFontSizeM);
font-weight: $euiFontWeightRegular;
@include euiTitle($euiCardTitleSize);
font-weight: $euiFontWeightMedium;
}

.euiCard__description {
Expand Down
16 changes: 12 additions & 4 deletions src/components/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,25 @@ export const EuiCard = ({
OuterElement = 'button';
}

let optionalCardTop;
if (image || icon) {
optionalCardTop = (
<span className="euiCard__top">
{imageNode}
{iconNode}
</span>
);
}

return (
<OuterElement
onClick={onClick}
className={classes}
href={href}
{...rest}
>
<span className="euiCard__top">
{imageNode}
{iconNode}
</span>

{optionalCardTop}

<span className="euiCard__content">
<EuiTitle className="euiCard__title">
Expand Down

0 comments on commit f932145

Please sign in to comment.