diff --git a/cypress/e2e/badge.cy.js b/cypress/e2e/badge.cy.js index 309c39ad8d0f3bcad41bbab664011c32f25828ce..364ada196062a916f8338d4ec153a4f20ca1e6d5 100644 --- a/cypress/e2e/badge.cy.js +++ b/cypress/e2e/badge.cy.js @@ -9,12 +9,6 @@ describe('GlBadge', () => { }); } - function checkA11yTextOnlyState() { - cy.visitStory('base/badge', { - story: 'sizes', - }); - } - function checkA11yBadgeHoverState() { cy.visitStory('base/badge', { story: 'actionable', @@ -41,7 +35,6 @@ describe('GlBadge', () => { cy.glRunA11yTests({ checkA11YDefaultState, checkA11yIconOnlyState, - checkA11yTextOnlyState, checkA11yBadgeHoverState, checkA11yBadgeSelectedState, checkA11yIconWithTextState, diff --git a/src/components/base/avatar_labeled/avatar_labeled.stories.js b/src/components/base/avatar_labeled/avatar_labeled.stories.js index 1cf39264c245cc8f2b528cc9f777865cbec122e2..3b6b321d19a8467d1cd43170a87b9d8408442166 100644 --- a/src/components/base/avatar_labeled/avatar_labeled.stories.js +++ b/src/components/base/avatar_labeled/avatar_labeled.stories.js @@ -102,10 +102,10 @@ export const WithBadges = (args, { argTypes }) => ({ > diff --git a/src/components/base/badge/badge.scss b/src/components/base/badge/badge.scss index 823365894e3f5405f0ad89b90ad0348640042801..fb97dc46cd862596c48bdf7c775e12327635975c 100644 --- a/src/components/base/badge/badge.scss +++ b/src/components/base/badge/badge.scss @@ -1,3 +1,6 @@ +$badge-padding-horizontal: 0.75 * $grid-size; +$badge-min-width: 2.5 * $grid-size; + @mixin gl-badge-variant( $variant, $color, @@ -15,7 +18,6 @@ color: $color; .gl-badge-icon { - color: $icon-color; transition: inherit; } } @@ -66,29 +68,18 @@ .gl-badge { @include gl-display-inline-flex; @include gl-align-items-center; + @include gl-justify-content-center; @include gl-font-sm; @include gl-font-weight-normal; @include gl-line-height-normal; - @include gl-py-2; - @include gl-px-3; + gap: $gl-spacing-scale-2; + padding: $gl-spacing-scale-1 $badge-padding-horizontal; + min-width: $badge-min-width; @media (forced-colors: active) { border: 1px solid; } - &.sm { - @include gl-py-0; - } - - &.md { - @include gl-py-2; - } - - &.lg { - @include gl-py-3; - @include gl-font-base; - } - .gl-badge-icon { @include gl-h-5; @include gl-w-5; @@ -193,4 +184,11 @@ // overriding Bootstap's `.btn .badge {top: -1px}` as the badge is not vertically centered otherwise .gl-button .gl-badge { top: 0; + @include gl-py-0; + @include gl-px-2; +} + +.gl-new-dropdown-contents .gl-badge, +.gl-tab-nav-item .gl-badge { + @include gl-my-n1; } diff --git a/src/components/base/badge/badge.spec.js b/src/components/base/badge/badge.spec.js index 1bc7f06c99c4313834cbc41040d05e233f259d78..670c0b5cbf48b9e6e9a88adf836be82f89bc65c3 100644 --- a/src/components/base/badge/badge.spec.js +++ b/src/components/base/badge/badge.spec.js @@ -40,12 +40,6 @@ describe('badge', () => { expect(icon.props('name')).toBe(iconName); }); - it('with correct class', () => { - const icon = findIcon(); - - expect(icon.classes('gl-mr-2')).toBe(hasSlot); - }); - it('with correct size', () => { expect(findIcon().props('size')).toBe(expectedIconSize); }); diff --git a/src/components/base/badge/badge.stories.js b/src/components/base/badge/badge.stories.js index 4187954fbe6da49924f9c18620935bcbf218c362..bc80545a1c65032fda2eb284afd1ca56b12a035f 100644 --- a/src/components/base/badge/badge.stories.js +++ b/src/components/base/badge/badge.stories.js @@ -1,9 +1,5 @@ import iconSpriteInfo from '@gitlab/svgs/dist/icons.json'; -import { - badgeSizeOptions, - badgeVariantOptions, - badgeIconSizeOptions, -} from '../../../utils/constants'; +import { badgeVariantOptions, badgeIconSizeOptions } from '../../../utils/constants'; import { disableControls } from '../../../utils/stories_utils'; import GlBadge from './badge.vue'; import readme from './badge.md'; @@ -12,9 +8,8 @@ const template = ` {{ content }} `; @@ -22,14 +17,12 @@ const defaultValue = (prop) => GlBadge.props[prop].default; const generateProps = ({ variant = defaultValue('variant'), - size = defaultValue('size'), href = '', content = 'TestBadge', icon = '', iconSize = defaultValue('iconSize'), } = {}) => ({ variant, - size, href, content, icon, @@ -56,7 +49,6 @@ export const Variants = (args, { argTypes }) => ({ :key="variant" :href="href" :variant="variant" - :size="size" :icon="icon" :iconSize="iconSize" class="gl-mr-3" @@ -80,7 +72,6 @@ export const Actionable = (args, { argTypes }) => ({ :key="variant" :href="href" :variant="variant" - :size="size" :icon="icon" :iconSize="iconSize" class="gl-mr-3" @@ -96,37 +87,15 @@ Actionable.args = generateProps({ Actionable.tags = ['skip-visual-test']; Actionable.argTypes = disableControls(['content', 'variant']); -export const Sizes = (args, { argTypes }) => ({ - components: { GlBadge }, - props: Object.keys(argTypes), - template: ` -
- {{ size }} -
- `, - badgeSizeOptions, -}); -Sizes.args = generateProps({ - variant: badgeVariantOptions.danger, -}); -Sizes.argTypes = disableControls(['content', 'size']); - export const BadgeIcon = (args, { argTypes }) => ({ components: { GlBadge }, props: Object.keys(argTypes), template: `
- 16px icon - 12px icon + With icon + With status open + With status closed + With sm icon
`, }); @@ -140,7 +109,6 @@ export const IconOnly = (args, { argTypes }) => ({ @@ -168,10 +136,6 @@ export default { options: Object.keys(badgeVariantOptions), control: 'select', }, - size: { - options: Object.keys(badgeSizeOptions), - control: 'select', - }, icon: { options: ['', ...iconSpriteInfo.icons], control: 'select', diff --git a/src/components/base/badge/badge.vue b/src/components/base/badge/badge.vue index 2b886a6a892cb2318f8f76c44ad6d5999c1cb836..650e53eab86febdf71828944f941a41ec1b35b6b 100644 --- a/src/components/base/badge/badge.vue +++ b/src/components/base/badge/badge.vue @@ -1,11 +1,7 @@