Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paddingSize prop to EuiCard and display example to docs #3638

Merged
merged 15 commits into from
Jul 2, 2020
Merged
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `26.3.0`.
- Added `paddingSize` prop to `EuiCard` ([#3638](https://github.com/elastic/eui/pull/3638))

## [`26.3.0`](https://github.com/elastic/eui/tree/v26.3.0)

Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/card/card_beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ const cardNodes = icons.map(function(item, index) {
);
});

export default () => <EuiFlexGroup gutterSize="l">{cardNodes}</EuiFlexGroup>;
export default () => <EuiFlexGroup gutterSize="l">{cardNodes} </EuiFlexGroup>;
48 changes: 48 additions & 0 deletions src-docs/src/views/card/card_display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';

import {
EuiCard,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiSpacer,
} from '../../../../src/components';

export default () => (
<div>
<EuiSpacer size="s" />
<EuiFlexGroup gutterSize="l">
<EuiFlexItem>
<EuiCard
layout="horizontal"
icon={<EuiIcon size="xl" type="logoLogging" />}
onClick={() => {}}
title="Logs"
display="plain"
description="The Elastic Stack is the most popular open source logging platform."
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xl" type="logoLogging" />}
title="Logs"
display="plain"
description="The Elastic Stack is the most popular open source logging platform."
onClick={() => {}}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
layout="horizontal"
icon={<EuiIcon size="xl" type="logoLogging" />}
title="Logs"
display="plain"
description="The Elastic Stack is the most popular open source logging platform."
betaBadgeLabel="Beta"
betaBadgeTooltipContent="This module is not GA. Please help us by reporting any bugs."
onClick={() => {}}
/>
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
40 changes: 40 additions & 0 deletions src-docs/src/views/card/card_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ import CardCheckable from './card_checkable';
const cardCheckableSource = require('!!raw-loader!./card_checkable');
const cardCheckableHtml = renderToHtml(CardCheckable);

import CardDisplay from './card_display';
const cardDisplaySource = require('!!raw-loader!./card_display');
const cardDisplayHtml = renderToHtml(CardDisplay);

export const CardExample = {
title: 'Card',
sections: [
Expand Down Expand Up @@ -367,5 +371,41 @@ export const CardExample = {
</EuiText>
</EuiCard>`,
},
{
title: 'Plain cards',
source: [
{
type: GuideSectionTypes.JS,
code: cardDisplaySource,
},
{
type: GuideSectionTypes.HTML,
code: cardDisplayHtml,
},
],
text: (
<Fragment>
<p>
If you need a card with no borders or shadows pass{' '}
<EuiCode language="ts">{'display="plain"'}</EuiCode>. This is a good
option to avoid nested panels. Adding an interaction to the card
will provide the clickable styling on hover. Note that{' '}
<EuiCode>plain</EuiCode> display is not available for
<EuiCode>selectable</EuiCode> cards.
</p>
<p>
For non-interactive cards, reduce or eliminate the padding as needed
to suit your layout with the prop <EuiCode>paddingSize</EuiCode>.
</p>
</Fragment>
),
props: { EuiCard },
demo: <CardDisplay />,
snippet: `<EuiCard
title="title"
description="description"
display="plain"
/>`,
},
],
};
124 changes: 112 additions & 12 deletions src/components/card/__snapshots__/card.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`EuiCard is rendered 1`] = `
<div
aria-label="aria-label"
class="euiCard euiCard--centerAligned testClass1 testClass2"
class="euiCard euiCard--paddingMedium euiCard--centerAligned testClass1 testClass2"
data-test-subj="test subject string"
>
<div
Expand All @@ -29,7 +29,7 @@ exports[`EuiCard is rendered 1`] = `

exports[`EuiCard props a null icon 1`] = `
<div
class="euiCard euiCard--centerAligned"
class="euiCard euiCard--paddingMedium euiCard--centerAligned"
>
<div
class="euiCard__content"
Expand All @@ -54,7 +54,7 @@ exports[`EuiCard props a null icon 1`] = `

exports[`EuiCard props children 1`] = `
<div
class="euiCard euiCard--centerAligned euiCard--hasChildren"
class="euiCard euiCard--paddingMedium euiCard--centerAligned euiCard--hasChildren"
>
<div
class="euiCard__content"
Expand All @@ -80,7 +80,7 @@ exports[`EuiCard props children 1`] = `

exports[`EuiCard props display 1`] = `
<div
class="euiCard euiCard--plain euiCard--centerAligned"
class="euiCard euiCard--paddingMedium euiCard--plain euiCard--centerAligned"
>
<div
class="euiCard__content"
Expand All @@ -105,7 +105,7 @@ exports[`EuiCard props display 1`] = `

exports[`EuiCard props footer 1`] = `
<div
class="euiCard euiCard--centerAligned"
class="euiCard euiCard--paddingMedium euiCard--centerAligned"
>
<div
class="euiCard__content"
Expand Down Expand Up @@ -137,7 +137,7 @@ exports[`EuiCard props footer 1`] = `

exports[`EuiCard props horizontal 1`] = `
<div
class="euiCard euiCard--centerAligned euiCard--horizontal"
class="euiCard euiCard--paddingMedium euiCard--centerAligned euiCard--horizontal"
>
<div
class="euiCard__content"
Expand Down Expand Up @@ -167,7 +167,7 @@ exports[`EuiCard props href supports href as a link 1`] = `
title="Hoi"
>
<div
className="euiCard euiCard--centerAligned euiCard--isClickable"
className="euiCard euiCard--paddingMedium euiCard--centerAligned euiCard--isClickable"
onClick={[Function]}
>
<div
Expand Down Expand Up @@ -213,7 +213,7 @@ exports[`EuiCard props href supports href as a link 1`] = `

exports[`EuiCard props icon 1`] = `
<div
class="euiCard euiCard--centerAligned euiCard--hasIcon"
class="euiCard euiCard--paddingMedium euiCard--centerAligned euiCard--hasIcon"
>
<div
class="euiCard__top"
Expand Down Expand Up @@ -244,9 +244,109 @@ exports[`EuiCard props icon 1`] = `
</div>
`;

exports[`EuiCard props paddingSize l is applied 1`] = `
<div
class="euiCard euiCard--paddingLarge euiCard--centerAligned"
>
<div
class="euiCard__content"
>
<span
class="euiTitle euiTitle--small euiCard__title"
id="generated-idTitle"
>
Card title
</span>
<div
class="euiText euiText--small euiCard__description"
id="generated-idDescription"
>
<p>
Card description
</p>
</div>
</div>
</div>
`;

exports[`EuiCard props paddingSize m is applied 1`] = `
<div
class="euiCard euiCard--paddingMedium euiCard--centerAligned"
>
<div
class="euiCard__content"
>
<span
class="euiTitle euiTitle--small euiCard__title"
id="generated-idTitle"
>
Card title
</span>
<div
class="euiText euiText--small euiCard__description"
id="generated-idDescription"
>
<p>
Card description
</p>
</div>
</div>
</div>
`;

exports[`EuiCard props paddingSize none is applied 1`] = `
<div
class="euiCard euiCard--paddingNone euiCard--centerAligned"
>
<div
class="euiCard__content"
>
<span
class="euiTitle euiTitle--small euiCard__title"
id="generated-idTitle"
>
Card title
</span>
<div
class="euiText euiText--small euiCard__description"
id="generated-idDescription"
>
<p>
Card description
</p>
</div>
</div>
</div>
`;

exports[`EuiCard props paddingSize s is applied 1`] = `
<div
class="euiCard euiCard--paddingSmall euiCard--centerAligned"
>
<div
class="euiCard__content"
>
<span
class="euiTitle euiTitle--small euiCard__title"
id="generated-idTitle"
>
Card title
</span>
<div
class="euiText euiText--small euiCard__description"
id="generated-idDescription"
>
<p>
Card description
</p>
</div>
</div>
</div>
`;

exports[`EuiCard props selectable 1`] = `
<div
class="euiCard euiCard--centerAligned euiCard--isClickable euiCard--isSelectable euiCard--isSelectable--text"
class="euiCard euiCard--paddingMedium euiCard--centerAligned euiCard--isClickable euiCard--isSelectable euiCard--isSelectable--text"
>
<div
class="euiCard__content"
Expand Down Expand Up @@ -288,7 +388,7 @@ exports[`EuiCard props selectable 1`] = `

exports[`EuiCard props textAlign 1`] = `
<div
class="euiCard euiCard--rightAligned"
class="euiCard euiCard--paddingMedium euiCard--rightAligned"
>
<div
class="euiCard__content"
Expand All @@ -313,7 +413,7 @@ exports[`EuiCard props textAlign 1`] = `

exports[`EuiCard props titleElement 1`] = `
<div
class="euiCard euiCard--centerAligned"
class="euiCard euiCard--paddingMedium euiCard--centerAligned"
>
<div
class="euiCard__content"
Expand All @@ -338,7 +438,7 @@ exports[`EuiCard props titleElement 1`] = `

exports[`EuiCard props titleSize 1`] = `
<div
class="euiCard euiCard--centerAligned"
class="euiCard euiCard--paddingMedium euiCard--centerAligned"
>
<div
class="euiCard__content"
Expand Down
Loading