-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Emotion] Convert EuiBadgeGroup, EuiBetaBadge, and EuiNotificationBad…
…ge (#6258) * Convert EuiBadgeGroup to Emotion - opinionated refactor: Use `inline-flex` and `gap` instead of inline-block and margins - doing so remove the needs for `euiBadgeGroup__item` * Convert EuiBetaBadge to Emotion - opinionated refactor: simplify `s` font-size to static rem (since .625 doesn't match the ratio of any current font scales) - remove isClickable CSS / classNames - it's not actually being used anywhere that I can tell - add unit tests for badge circle display * [docs] beta badge docs improvement - convert file to TS - improve visuals of clickable examples * Convert EuiNotificationBadge to Emotion + delete all badge SCSS files + update downstream snapshots * changelog * [PR feedback] euiTextTruncate * [PR feedback] Create internal color util for badge colors * [PR feedback] Remove ` `s from beta badge docs
- Loading branch information
Constance
authored
Sep 23, 2022
1 parent
ea38de6
commit 08c4ac4
Showing
31 changed files
with
420 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
|
||
import { EuiBetaBadge, EuiSpacer, EuiTitle } from '../../../../src/components'; | ||
|
||
const colors = ['hollow', 'accent', 'subdued'] as const; | ||
|
||
export default () => ( | ||
<> | ||
<div | ||
css={css` | ||
display: grid; | ||
align-items: flex-start; | ||
grid: repeat(3, max-content) / repeat(6, max-content); | ||
gap: 0.75rem; | ||
`} | ||
> | ||
{colors.map((item) => ( | ||
<> | ||
<EuiBetaBadge | ||
label="Beta" | ||
color={item} | ||
tooltipContent="This module is not GA. Please help us by reporting any bugs." | ||
/> | ||
<EuiBetaBadge | ||
label="Beta" | ||
color={item} | ||
size="s" | ||
tooltipContent="This module is not GA. Please help us by reporting any bugs." | ||
/> | ||
<EuiBetaBadge label="Beta" color={item} iconType="beta" /> | ||
<EuiBetaBadge size="s" label="Beta" color={item} iconType="beta" /> | ||
<EuiBetaBadge label="Lab" color={item} iconType="beaker" /> | ||
<EuiBetaBadge label="Lab" size="s" color={item} iconType="beaker" /> | ||
</> | ||
))} | ||
</div> | ||
<EuiSpacer size="s" /> | ||
<EuiTitle size="s"> | ||
<h3> | ||
Beta badges will also line up nicely with titles | ||
<EuiBetaBadge | ||
label="Lab" | ||
tooltipContent="This module is not GA. Please help us by reporting any bugs." | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer /> | ||
<EuiTitle size="xs"> | ||
<h3>Clickable beta badges</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<div | ||
css={css` | ||
display: flex; | ||
align-items: center; | ||
gap: 0.75rem; | ||
`} | ||
> | ||
<EuiBetaBadge | ||
label="Lens" | ||
iconType="lensApp" | ||
onClick={() => alert('Goes to Lens')} | ||
/> | ||
<EuiBetaBadge | ||
label="Basic" | ||
href="http://www.elastic.co/subscriptions" | ||
target="_blank" | ||
/> | ||
</div> | ||
</> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { css } from '@emotion/react'; | ||
import { logicalCSS } from '../../../global_styling'; | ||
import { UseEuiTheme } from '../../../services'; | ||
|
||
export const euiBadgeGroupStyles = ({ euiTheme }: UseEuiTheme) => { | ||
return { | ||
euiBadgeGroup: css` | ||
display: inline-flex; | ||
flex-wrap: wrap; | ||
${logicalCSS('max-width', '100%')} | ||
// Override the .euiBadge + .euiBadge CSS in badge.styles.ts | ||
.euiBadge { | ||
${logicalCSS('margin-left', 0)} | ||
} | ||
`, | ||
// Gutter sizes | ||
none: css``, | ||
s: css` | ||
gap: ${euiTheme.size.s}; | ||
`, | ||
xs: css` | ||
gap: ${euiTheme.size.xs}; | ||
`, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.