-
Notifications
You must be signed in to change notification settings - Fork 861
[EuiBadge] Update styles to match latest design changes #9302
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
Changes from all commits
5bb86e2
74013a2
d58581c
df6b153
20f3816
96c568c
a632cca
e86fe30
f6389ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
tkajtoch marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Updated EuiBadge design to have rounded corners and improved paddings |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,18 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| --euiBadgeBackgroundColor: ${colors.backgroundColor}; | ||
| `; | ||
|
|
||
| const inlinePadding = mathWithUnits( | ||
| // Account for the (usually transparent) border so that the visual | ||
| // padding is of size s | ||
| [euiTheme.size.s, euiTheme.border.width.thin], | ||
| (size, borderWidth) => size - borderWidth | ||
| ); | ||
|
|
||
| return { | ||
| euiBadge: css` | ||
| display: inline-block; | ||
| vertical-align: middle; | ||
| ${logicalShorthandCSS('padding', `0 ${euiTheme.size.s}`)} | ||
| ${logicalShorthandCSS('padding', `0 ${inlinePadding}`)} | ||
| ${logicalCSS('max-width', '100%')} | ||
| font-size: ${euiFontSize(euiThemeContext, 'xs').fontSize}; | ||
| line-height: ${mathWithUnits( | ||
|
|
@@ -46,10 +53,11 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| text-decoration: none; | ||
| cursor: inherit; | ||
| border: ${euiTheme.border.width.thin} solid transparent; | ||
| border-radius: ${mathWithUnits( | ||
| euiTheme.border.radius.medium, | ||
| (x) => x / 2 | ||
| )}; | ||
|
|
||
| /* border radius is intentionally larger to protect against external | ||
| customizations that might affect badge height */ | ||
| border-radius: ${euiTheme.size.l}; | ||
|
|
||
| /* The badge will only ever be as wide as its content | ||
| So, make the text left aligned to ensure all badges line up the same */ | ||
| ${logicalTextAlignCSS('left')} | ||
|
|
@@ -81,6 +89,13 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| ${logicalCSS('margin-left', euiTheme.size.xs)} | ||
| } | ||
| `, | ||
| iconOnly: css` | ||
| padding-inline: ${mathWithUnits( | ||
| // Account for the border | ||
| [euiTheme.size.xs, euiTheme.border.width.thin], | ||
| (size, borderWidth) => size - borderWidth | ||
| )}; | ||
| `, | ||
| clickable: css` | ||
| &:not(:disabled) { | ||
| &:hover, | ||
|
|
@@ -143,6 +158,7 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| text: { | ||
| euiBadge__text: css` | ||
| ${euiTextTruncate()} | ||
| padding-inline: ${euiTheme.size.xxs}; | ||
| cursor: inherit; | ||
| `, | ||
| clickable: css` | ||
|
|
@@ -155,12 +171,12 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| euiBadge__icon: css``, | ||
| right: css` | ||
| &:not(:only-child) { | ||
| ${logicalCSS('margin-left', euiTheme.size.xs)} | ||
| ${logicalCSS('margin-left', euiTheme.size.xxs)} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @tkajtoch, thank you so much for the changes 🙏🏻 Looks perfect, but I have only one question/neat: I know in design it is 8px padding from left/right to the icon. But since here in code the border is counted too, it looks just a liiiittle too much, and I think we could go for 6px from both sider. Would that change be possible?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Fixed in e86fe30
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a token for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's go with it, works for me! A bit of a side question, but I wonder if we should actually introduce those tokens. For smaller elements they might make sense to perfectly balance the composition sometimes... cc @JoseLuisGJ
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally think it could be a little too much in terms of available options considering there are also values above Let me merge this PR as-is then and we can discuss the sizing tokens somewhere else - how about a slack thread? :) |
||
| } | ||
| `, | ||
| left: css` | ||
| &:not(:only-child) { | ||
| ${logicalCSS('margin-right', euiTheme.size.xs)} | ||
| ${logicalCSS('margin-right', euiTheme.size.xxs)} | ||
| } | ||
| `, | ||
| }, | ||
|
|
@@ -180,10 +196,10 @@ export const euiBadgeStyles = (euiThemeContext: UseEuiTheme) => { | |
| } | ||
| `, | ||
| right: css` | ||
| ${logicalCSS('margin-left', euiTheme.size.xs)} | ||
| ${logicalCSS('margin-left', euiTheme.size.xxs)} | ||
| `, | ||
| left: css` | ||
| ${logicalCSS('margin-right', euiTheme.size.xs)} | ||
| ${logicalCSS('margin-right', euiTheme.size.xxs)} | ||
| `, | ||
| }, | ||
|
|
||
|
|
||




Uh oh!
There was an error while loading. Please reload this page.