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

[EuiCard & friends] Convert to Emotion #6110

Merged
merged 13 commits into from
Aug 22, 2022
File renamed without changes.
13 changes: 10 additions & 3 deletions src-docs/src/views/card/card_beta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export default () => (
title="Dashboards"
description="Example of a card's description. Stick to one or two sentences."
onClick={() => {}}
betaBadgeProps={{
label: 'Beta',
tooltipContent:
'This module is not GA. Please help us by reporting any bugs.',
}}
/>
</EuiFlexItem>
<EuiFlexItem>
Expand All @@ -23,9 +28,10 @@ export default () => (
title="Monitoring"
description="Example of a card's description. Stick to one or two sentences."
betaBadgeProps={{
label: 'Beta',
label: 'Accent',
color: 'accent',
tooltipContent:
'This module is not GA. Please help us by reporting any bugs.',
'You can change the badge color using betaBadgeProps.color.',
}}
onClick={() => {}}
/>
Expand All @@ -40,7 +46,8 @@ export default () => (
href: 'http://www.elastic.co/subscriptions',
target: '_blank',
label: 'Basic',
tooltipContent: 'This feature requires a Basic License',
tooltipContent:
'Disabled cards with still clickable badges will stay hollow.',
}}
onClick={() => {}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
EuiRadioGroup,
EuiTitle,
EuiFormFieldset,
} from '../../../../src/components';

import { useGeneratedHtmlId } from '../../../../src/services';
useGeneratedHtmlId,
} from '../../../../src';

export default () => {
const radioGroupId = useGeneratedHtmlId({ prefix: 'radioGroup' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState } from 'react';

import { EuiCheckableCard } from '../../../../src/components';

import { useGeneratedHtmlId } from '../../../../src/services';
import { EuiCheckableCard, useGeneratedHtmlId } from '../../../../src';

export default () => {
const [checkbox, setCheckbox] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
EuiText,
EuiButton,
EuiCode,
} from '../../../../src/components';
} from '../../../../src';

const radios = [
{
Expand Down
14 changes: 12 additions & 2 deletions src-docs/src/views/card/card_display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
EuiFlexItem,
EuiIcon,
EuiSpacer,
} from '../../../../src/components';
} from '../../../../src';

export default () => (
<div>
<EuiSpacer size="s" />
<EuiFlexGroup gutterSize="l">
<EuiFlexGroup gutterSize="l" wrap>
<EuiFlexItem>
<EuiCard
layout="horizontal"
Expand Down Expand Up @@ -46,6 +46,16 @@ export default () => (
onClick={() => {}}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xl" type="logoLogging" />}
title="Bordered"
display="plain"
hasBorder
description="This one has a plain background color and border."
onClick={() => {}}
/>
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
EuiLink,
EuiSpacer,
EuiText,
} from '../../../../src/components';
} from '../../../../src';

export default () => (
<EuiFlexGroup gutterSize="l">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
} from '../../../../src/components';

const cardFooterContent = (
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton>Go for it</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
);
} from '../../../../src';

export default () => (
<EuiFlexGroup gutterSize="l">
Expand All @@ -31,7 +23,13 @@ export default () => (
}
title="Elastic in Nature"
description="Example of a card's description. Stick to one or two sentences."
footer={cardFooterContent}
footer={
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButton>Go for it</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
}
/>
</EuiFlexItem>
<EuiFlexItem>
Expand All @@ -40,7 +38,7 @@ export default () => (
image="https://source.unsplash.com/400x200/?Water"
title="Elastic in Water"
description="Example of a card's description. Stick to one or two sentences."
footer={cardFooterContent}
isDisabled
/>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import React from 'react';

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

export default () => (
<EuiFlexGroup gutterSize="l">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
EuiIcon,
EuiFlexGroup,
EuiFlexItem,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [card1Selected, setCard1] = useState(true);
Expand All @@ -20,7 +20,7 @@ export default () => {
setCard2(!card2Selected);
};

const detailsClicked = (e) => {
const detailsClicked = (e: { stopPropagation: () => void }) => {
e.stopPropagation();
};

Expand Down
6 changes: 5 additions & 1 deletion src/components/badge/beta_badge/_beta_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
text-align: center;
white-space: nowrap;
cursor: default;
overflow: hidden;
text-overflow: ellipsis;

&:focus {
@include euiFocusRing;
Expand Down Expand Up @@ -70,9 +72,11 @@
}

.euiBetaBadge--hollow {
background-color: $euiColorEmptyShade;

&.euiBetaBadge-isClickable {
$backgroundColor: tint($euiColorLightShade, 30%);
color: chooseLightOrDarkText($backgroundColor, $euiColorGhost, $euiColorInk);
color: chooseLightOrDarkText($euiColorEmptyShade, $euiColorGhost, $euiColorInk);
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/components/badge/beta_badge/beta_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { CommonProps, ExclusiveUnion, keysOf } from '../../common';

import { getSecureRelForTarget } from '../../../services';

import { EuiToolTip, ToolTipPositions } from '../../tool_tip';
import { EuiToolTip, EuiToolTipProps, ToolTipPositions } from '../../tool_tip';

import { EuiIcon, IconType } from '../../icon';

Expand Down Expand Up @@ -108,6 +108,11 @@ type BadgeProps = {
*/
tooltipPosition?: ToolTipPositions;

/**
* Passes onto the span wrapping the badge
*/
anchorProps?: EuiToolTipProps['anchorProps'];

/**
* Optional title will be supplied as tooltip title or title attribute
* otherwise the label will be used
Expand All @@ -133,6 +138,7 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({
color = 'hollow',
tooltipContent,
tooltipPosition = 'top',
anchorProps,
title,
iconType,
onClick,
Expand Down Expand Up @@ -211,6 +217,7 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({
position={tooltipPosition}
content={tooltipContent}
title={title || label}
anchorProps={anchorProps}
>
{content}
</EuiToolTip>
Expand All @@ -225,6 +232,7 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({
position={tooltipPosition}
content={tooltipContent}
title={title || label}
anchorProps={anchorProps}
>
<span tabIndex={0} className={classes} role="button" {...rest}>
{icon || label}
Expand Down
Loading