@gitlab/ui 99.1.0 → 101.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  // Component names
2
- const NAME_BADGE = 'BBadge';
3
2
  const NAME_BREADCRUMB = 'BBreadcrumb';
4
3
  const NAME_BREADCRUMB_ITEM = 'BBreadcrumbItem';
5
4
  const NAME_BREADCRUMB_LINK = 'BBreadcrumbLink';
@@ -72,4 +71,4 @@ const NAME_TRANSITION = 'BVTransition';
72
71
  const NAME_TRANSPORTER = 'BVTransporter';
73
72
  const NAME_TRANSPORTER_TARGET = 'BVTransporterTarget';
74
73
 
75
- export { NAME_BADGE, NAME_BREADCRUMB, NAME_BREADCRUMB_ITEM, NAME_BREADCRUMB_LINK, NAME_BUTTON, NAME_BUTTON_CLOSE, NAME_BUTTON_GROUP, NAME_COL, NAME_COLLAPSE, NAME_COLLAPSE_HELPER, NAME_DROPDOWN, NAME_DROPDOWN_DIVIDER, NAME_DROPDOWN_FORM, NAME_DROPDOWN_GROUP, NAME_DROPDOWN_HEADER, NAME_DROPDOWN_ITEM, NAME_DROPDOWN_ITEM_BUTTON, NAME_DROPDOWN_TEXT, NAME_FORM, NAME_FORM_BUTTON_LABEL_CONTROL, NAME_FORM_CHECKBOX, NAME_FORM_CHECKBOX_GROUP, NAME_FORM_GROUP, NAME_FORM_INPUT, NAME_FORM_INVALID_FEEDBACK, NAME_FORM_RADIO, NAME_FORM_RADIO_GROUP, NAME_FORM_RATING_STAR, NAME_FORM_ROW, NAME_FORM_SELECT, NAME_FORM_SELECT_OPTION, NAME_FORM_SELECT_OPTION_GROUP, NAME_FORM_TEXT, NAME_FORM_TEXTAREA, NAME_FORM_VALID_FEEDBACK, NAME_INPUT_GROUP, NAME_INPUT_GROUP_ADDON, NAME_INPUT_GROUP_APPEND, NAME_INPUT_GROUP_PREPEND, NAME_INPUT_GROUP_TEXT, NAME_LINK, NAME_MODAL, NAME_NAV, NAME_NAV_ITEM, NAME_NAV_ITEM_DROPDOWN, NAME_POPOVER, NAME_POPOVER_HELPER, NAME_POPOVER_TEMPLATE, NAME_POPPER, NAME_TAB, NAME_TABLE, NAME_TABLE_CELL, NAME_TABLE_LITE, NAME_TABLE_SIMPLE, NAME_TABS, NAME_TAB_BUTTON_HELPER, NAME_TBODY, NAME_TFOOT, NAME_TH, NAME_THEAD, NAME_TOAST, NAME_TOASTER, NAME_TOAST_POP, NAME_TOOLTIP, NAME_TOOLTIP_HELPER, NAME_TOOLTIP_TEMPLATE, NAME_TR, NAME_TRANSITION, NAME_TRANSPORTER, NAME_TRANSPORTER_TARGET };
74
+ export { NAME_BREADCRUMB, NAME_BREADCRUMB_ITEM, NAME_BREADCRUMB_LINK, NAME_BUTTON, NAME_BUTTON_CLOSE, NAME_BUTTON_GROUP, NAME_COL, NAME_COLLAPSE, NAME_COLLAPSE_HELPER, NAME_DROPDOWN, NAME_DROPDOWN_DIVIDER, NAME_DROPDOWN_FORM, NAME_DROPDOWN_GROUP, NAME_DROPDOWN_HEADER, NAME_DROPDOWN_ITEM, NAME_DROPDOWN_ITEM_BUTTON, NAME_DROPDOWN_TEXT, NAME_FORM, NAME_FORM_BUTTON_LABEL_CONTROL, NAME_FORM_CHECKBOX, NAME_FORM_CHECKBOX_GROUP, NAME_FORM_GROUP, NAME_FORM_INPUT, NAME_FORM_INVALID_FEEDBACK, NAME_FORM_RADIO, NAME_FORM_RADIO_GROUP, NAME_FORM_RATING_STAR, NAME_FORM_ROW, NAME_FORM_SELECT, NAME_FORM_SELECT_OPTION, NAME_FORM_SELECT_OPTION_GROUP, NAME_FORM_TEXT, NAME_FORM_TEXTAREA, NAME_FORM_VALID_FEEDBACK, NAME_INPUT_GROUP, NAME_INPUT_GROUP_ADDON, NAME_INPUT_GROUP_APPEND, NAME_INPUT_GROUP_PREPEND, NAME_INPUT_GROUP_TEXT, NAME_LINK, NAME_MODAL, NAME_NAV, NAME_NAV_ITEM, NAME_NAV_ITEM_DROPDOWN, NAME_POPOVER, NAME_POPOVER_HELPER, NAME_POPOVER_TEMPLATE, NAME_POPPER, NAME_TAB, NAME_TABLE, NAME_TABLE_CELL, NAME_TABLE_LITE, NAME_TABLE_SIMPLE, NAME_TABS, NAME_TAB_BUTTON_HELPER, NAME_TBODY, NAME_TFOOT, NAME_TH, NAME_THEAD, NAME_TOAST, NAME_TOASTER, NAME_TOAST_POP, NAME_TOOLTIP, NAME_TOOLTIP_HELPER, NAME_TOOLTIP_TEMPLATE, NAME_TR, NAME_TRANSITION, NAME_TRANSPORTER, NAME_TRANSPORTER_TARGET };
@@ -2,7 +2,6 @@ import { installFactory } from './utils/plugins';
2
2
  import { componentsPlugin } from './components';
3
3
  export { BVConfigPlugin as BVConfig, BVConfigPlugin } from './bv-config';
4
4
  export { BVToastPlugin } from './components/toast/helpers/bv-toast';
5
- export { BBadge } from './components/badge/badge';
6
5
  export { BBreadcrumb } from './components/breadcrumb/breadcrumb';
7
6
  export { BBreadcrumbItem } from './components/breadcrumb/breadcrumb-item';
8
7
  export { BButton } from './components/button/button';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "99.1.0",
3
+ "version": "101.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -90,7 +90,6 @@
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@gitlab/svgs": "^1.116.0 || ^2.0.0 || ^3.0.0",
93
- "bootstrap": ">=4.5.3 <=4.6.2",
94
93
  "dompurify": ">=2.5.2 <3.0.0 || >=3.1.2",
95
94
  "emoji-regex": ">=10.0.0",
96
95
  "pikaday": "^1.8.0",
@@ -145,8 +144,7 @@
145
144
  "axe-core": "^4.2.3",
146
145
  "babel-jest": "29.0.1",
147
146
  "babel-loader": "^8.0.5",
148
- "bootstrap": "4.6.2",
149
- "cypress": "13.15.0",
147
+ "cypress": "13.15.1",
150
148
  "cypress-axe": "^1.4.0",
151
149
  "cypress-real-events": "^1.11.0",
152
150
  "dompurify": "^3.1.2",
@@ -23,16 +23,8 @@ badge for best accessibility.
23
23
  <gl-badge icon="eye" aria-label="Mark as confidential" />
24
24
  ```
25
25
 
26
- ## Edge cases
27
-
28
- While this component is based on
29
- [`BBadge`](https://bootstrap-vue.org/docs/components/badge) from
30
- `bootstrap-vue`, it is not a drop-in replacement. Specifically, this component:
31
-
32
- - Has a different set of valid `variant`s. See the examples or props
33
- documentation for those values.
34
- - Always sets the `pill` prop of the underlying
35
- [`BBadge`](https://bootstrap-vue.org/docs/components/badge) to `true`. Any passed
36
- in `pill` prop value is ignored.
37
- - Does _not_ scale itself to match the size of its immediate parent, like
38
- [`BBadge`](https://bootstrap-vue.org/docs/components/badge) does.
26
+ ## Link badges
27
+
28
+ Badges can be made actionable and turn into links by providing the `href` prop,
29
+ which can be used in combination with the props `rel`, `target`, `active`, and `disabled`.
30
+ The prop `tag` will be ignored and the `BLink` component will be used instead.
@@ -27,7 +27,7 @@ $badge-min-width: $gl-spacing-scale-3;
27
27
  }
28
28
  }
29
29
 
30
- a.gl-badge.badge-#{$variant} {
30
+ a.gl-badge.badge-#{$variant}:not(.disabled) {
31
31
  &:hover {
32
32
  color: $hover-color;
33
33
  // Needed to override bootstrap's badge variant background
@@ -117,6 +117,11 @@ $badge-min-width: $gl-spacing-scale-3;
117
117
  }
118
118
  }
119
119
 
120
+ a.gl-badge.disabled {
121
+ cursor: not-allowed;
122
+ }
123
+
124
+
120
125
  /* Variants */
121
126
 
122
127
  @include gl-badge-variant(
@@ -1,16 +1,25 @@
1
1
  <!-- eslint-disable vue/multi-word-component-names -->
2
2
  <script>
3
- import { BBadge } from '../../../vendor/bootstrap-vue/src/components/badge/badge';
3
+ import { BLink } from '../../../vendor/bootstrap-vue/src/components/link/link';
4
4
  import { badgeVariantOptions, badgeIconSizeOptions } from '../../../utils/constants';
5
5
  import GlIcon from '../icon/icon.vue';
6
6
 
7
+ const variantClass = {
8
+ [badgeVariantOptions.muted]: 'badge-muted',
9
+ [badgeVariantOptions.neutral]: 'badge-neutral',
10
+ [badgeVariantOptions.info]: 'badge-info',
11
+ [badgeVariantOptions.success]: 'badge-success',
12
+ [badgeVariantOptions.warning]: 'badge-warning',
13
+ [badgeVariantOptions.danger]: 'badge-danger',
14
+ [badgeVariantOptions.tier]: 'badge-tier',
15
+ };
16
+
7
17
  export default {
8
18
  name: 'GlBadge',
9
19
  components: {
10
- BBadge,
20
+ BLink,
11
21
  GlIcon,
12
22
  },
13
- inheritAttrs: false,
14
23
  props: {
15
24
  /**
16
25
  * The variant of the badge.
@@ -48,6 +57,54 @@ export default {
48
57
  default: false,
49
58
  required: false,
50
59
  },
60
+ /**
61
+ * Custom tag to use (unless `href` is defined)
62
+ */
63
+ tag: {
64
+ type: String,
65
+ required: false,
66
+ default: 'span',
67
+ },
68
+ /**
69
+ * Creates the badge as link (ignores `tag` property)
70
+ */
71
+ href: {
72
+ type: String,
73
+ required: false,
74
+ default: undefined,
75
+ },
76
+ /**
77
+ * Sets the `rel` attributes, when `href` is defined
78
+ */
79
+ rel: {
80
+ type: String,
81
+ required: false,
82
+ default: null,
83
+ },
84
+ /**
85
+ * Sets the `target`, when `href` is defined
86
+ */
87
+ target: {
88
+ type: String,
89
+ required: false,
90
+ default: '_self',
91
+ },
92
+ /**
93
+ * Adds the `active` class, when `href` is defined
94
+ */
95
+ active: {
96
+ type: Boolean,
97
+ required: false,
98
+ default: false,
99
+ },
100
+ /**
101
+ * Disables the link, when `href` is defined
102
+ */
103
+ disabled: {
104
+ type: Boolean,
105
+ required: false,
106
+ default: false,
107
+ },
51
108
  },
52
109
  computed: {
53
110
  hasIconOnly() {
@@ -70,19 +127,38 @@ export default {
70
127
  iconSizeComputed() {
71
128
  return badgeIconSizeOptions[this.iconSize];
72
129
  },
130
+ isLink() {
131
+ return Boolean(this.href);
132
+ },
133
+ computedTag() {
134
+ return this.isLink ? BLink : this.tag;
135
+ },
136
+ computedProps() {
137
+ if (!this.isLink) return {};
138
+
139
+ const { href, rel, target, active, disabled } = this;
140
+ return { href, rel, target, active, disabled };
141
+ },
142
+ classes() {
143
+ return [
144
+ 'gl-badge',
145
+ 'badge',
146
+ 'badge-pill',
147
+ variantClass[this.variant],
148
+ { '!gl-px-2': !this.$scopedSlots.default },
149
+ ];
150
+ },
73
151
  },
74
152
  };
75
153
  </script>
76
154
 
77
155
  <template>
78
- <b-badge
79
- v-bind="$attrs"
80
- :variant="variant"
81
- class="gl-badge"
82
- :class="{ '!gl-px-2': !$scopedSlots.default }"
156
+ <component
157
+ :is="computedTag"
158
+ v-bind="computedProps"
159
+ :class="classes"
83
160
  :role="role"
84
161
  :aria-label="ariaLabel"
85
- pill
86
162
  >
87
163
  <gl-icon
88
164
  v-if="icon"
@@ -95,5 +171,5 @@ export default {
95
171
  <span v-if="$slots.default" class="gl-badge-content">
96
172
  <slot></slot>
97
173
  </span>
98
- </b-badge>
174
+ </component>
99
175
  </template>
@@ -1,34 +1,34 @@
1
1
  @import 'variables';
2
- @import 'bootstrap/scss/functions';
3
- @import 'bootstrap/scss/variables';
4
- @import 'bootstrap/scss/mixins';
5
- @import 'bootstrap/scss/root';
6
- @import 'bootstrap/scss/reboot';
7
- @import 'bootstrap/scss/type';
8
- @import 'bootstrap/scss/images';
9
- @import 'bootstrap/scss/code';
10
- @import 'bootstrap/scss/grid';
11
- @import 'bootstrap/scss/tables';
12
- @import 'bootstrap/scss/forms';
13
- @import 'bootstrap/scss/buttons';
14
- @import 'bootstrap/scss/transitions';
15
- @import 'bootstrap/scss/dropdown';
16
- @import 'bootstrap/scss/button-group';
17
- @import 'bootstrap/scss/input-group';
18
- @import 'bootstrap/scss/custom-forms';
19
- @import 'bootstrap/scss/nav';
20
- @import 'bootstrap/scss/navbar';
21
- @import 'bootstrap/scss/card';
22
- @import 'bootstrap/scss/breadcrumb';
23
- @import 'bootstrap/scss/pagination';
24
- @import 'bootstrap/scss/badge';
25
- @import 'bootstrap/scss/alert';
26
- @import 'bootstrap/scss/progress';
27
- @import 'bootstrap/scss/media';
28
- @import 'bootstrap/scss/list-group';
29
- @import 'bootstrap/scss/close';
30
- @import 'bootstrap/scss/modal';
31
- @import 'bootstrap/scss/tooltip';
32
- @import 'bootstrap/scss/popover';
33
- @import 'bootstrap/scss/utilities';
34
- @import 'bootstrap/scss/print';
2
+ @import '../vendor/bootstrap/scss/functions';
3
+ @import '../vendor/bootstrap/scss/variables';
4
+ @import '../vendor/bootstrap/scss/mixins';
5
+ @import '../vendor/bootstrap/scss/root';
6
+ @import '../vendor/bootstrap/scss/reboot';
7
+ @import '../vendor/bootstrap/scss/type';
8
+ @import '../vendor/bootstrap/scss/images';
9
+ @import '../vendor/bootstrap/scss/code';
10
+ @import '../vendor/bootstrap/scss/grid';
11
+ @import '../vendor/bootstrap/scss/tables';
12
+ @import '../vendor/bootstrap/scss/forms';
13
+ @import '../vendor/bootstrap/scss/buttons';
14
+ @import '../vendor/bootstrap/scss/transitions';
15
+ @import '../vendor/bootstrap/scss/dropdown';
16
+ @import '../vendor/bootstrap/scss/button-group';
17
+ @import '../vendor/bootstrap/scss/input-group';
18
+ @import '../vendor/bootstrap/scss/custom-forms';
19
+ @import '../vendor/bootstrap/scss/nav';
20
+ @import '../vendor/bootstrap/scss/navbar';
21
+ @import '../vendor/bootstrap/scss/card';
22
+ @import '../vendor/bootstrap/scss/breadcrumb';
23
+ @import '../vendor/bootstrap/scss/pagination';
24
+ @import '../vendor/bootstrap/scss/badge';
25
+ @import '../vendor/bootstrap/scss/alert';
26
+ @import '../vendor/bootstrap/scss/progress';
27
+ @import '../vendor/bootstrap/scss/media';
28
+ @import '../vendor/bootstrap/scss/list-group';
29
+ @import '../vendor/bootstrap/scss/close';
30
+ @import '../vendor/bootstrap/scss/modal';
31
+ @import '../vendor/bootstrap/scss/tooltip';
32
+ @import '../vendor/bootstrap/scss/popover';
33
+ @import '../vendor/bootstrap/scss/utilities';
34
+ @import '../vendor/bootstrap/scss/print';
@@ -1,7 +1,4 @@
1
1
  // stylelint-disable scss/at-import-partial-extension-blacklist
2
-
3
- // imports from https://github.com/bootstrap-vue/bootstrap-vue/blob/dev/src/index.scss
4
-
5
2
  @import '../vendor/bootstrap-vue/src/variables.scss';
6
3
  // Disabe Tooltip and Popover colored variants which we do not use / support.
7
4
  $bv-enable-tooltip-variants: false;
@@ -21,4 +18,3 @@ $bv-enable-popover-variants: false;
21
18
  @import '../vendor/bootstrap-vue/src/components/toast/index.scss';
22
19
  @import '../vendor/bootstrap-vue/src/components/tooltip/index.scss';
23
20
 
24
- // @import '../vendor/bootstrap-vue/src/icons/icons.scss';
@@ -7,9 +7,9 @@ $feature-button-border: true;
7
7
  @import 'functions';
8
8
  @import 'variables';
9
9
 
10
- @import 'bootstrap/scss/functions';
11
- @import 'bootstrap/scss/variables';
12
- @import 'bootstrap/scss/mixins';
10
+ @import '../vendor/bootstrap/scss/functions';
11
+ @import '../vendor/bootstrap/scss/variables';
12
+ @import '../vendor/bootstrap/scss/mixins';
13
13
 
14
14
  @import 'bootstrap_vue';
15
15
 
@@ -64,7 +64,6 @@
64
64
  "test:meta": "scripts/check-meta.sh"
65
65
  },
66
66
  "dependencies": {
67
- "bootstrap": "^4.6.1",
68
67
  "popper.js": "^1.16.1",
69
68
  "portal-vue": "^2.1.7",
70
69
  "vue-functional-data-merge": "^3.1.0"
@@ -1,5 +1,4 @@
1
1
  // Component names
2
- export const NAME_BADGE = 'BBadge'
3
2
  export const NAME_BREADCRUMB = 'BBreadcrumb'
4
3
  export const NAME_BREADCRUMB_ITEM = 'BBreadcrumbItem'
5
4
  export const NAME_BREADCRUMB_LINK = 'BBreadcrumbLink'
@@ -51,9 +51,6 @@ export { BVToastPlugin } from './components/toast/helpers/bv-toast'
51
51
 
52
52
  // --- Export all individual components and component group plugins as named exports ---
53
53
 
54
- // export * from './components/badge'
55
- export { BBadge } from './components/badge/badge'
56
-
57
54
  // export * from './components/breadcrumb'
58
55
  export { BBreadcrumb } from './components/breadcrumb/breadcrumb'
59
56
  export { BBreadcrumbItem } from './components/breadcrumb/breadcrumb-item'
@@ -1,53 +0,0 @@
1
- import { extend, mergeData } from '../../vue';
2
- import { NAME_BADGE } from '../../constants/components';
3
- import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props';
4
- import { omit, sortKeys } from '../../utils/object';
5
- import { makePropsConfigurable, makeProp, pluckProps } from '../../utils/props';
6
- import { isLink } from '../../utils/router';
7
- import { props as props$1, BLink } from '../link/link';
8
-
9
- // --- Props ---
10
-
11
- const linkProps = omit(props$1, ['event', 'routerTag']);
12
- delete linkProps.href.default;
13
- delete linkProps.to.default;
14
- const props = makePropsConfigurable(sortKeys({
15
- ...linkProps,
16
- pill: makeProp(PROP_TYPE_BOOLEAN, false),
17
- tag: makeProp(PROP_TYPE_STRING, 'span'),
18
- variant: makeProp(PROP_TYPE_STRING, 'secondary')
19
- }), NAME_BADGE);
20
-
21
- // --- Main component ---
22
-
23
- // @vue/component
24
- const BBadge = /*#__PURE__*/extend({
25
- name: NAME_BADGE,
26
- functional: true,
27
- props,
28
- render(h, _ref) {
29
- let {
30
- props,
31
- data,
32
- children
33
- } = _ref;
34
- const {
35
- active,
36
- disabled
37
- } = props;
38
- const link = isLink(props);
39
- const tag = link ? BLink : props.tag;
40
- const variant = props.variant || 'secondary';
41
- return h(tag, mergeData(data, {
42
- staticClass: 'badge',
43
- class: [`badge-${variant}`, {
44
- 'badge-pill': props.pill,
45
- active,
46
- disabled
47
- }],
48
- props: link ? pluckProps(linkProps, props) : {}
49
- }), children);
50
- }
51
- });
52
-
53
- export { BBadge, props };
@@ -1 +0,0 @@
1
- export { BBadge } from './badge';
@@ -1,126 +0,0 @@
1
- # Badge
2
-
3
- > Small and adaptive tag for adding context to just about any content.
4
-
5
- ## Overview
6
-
7
- Badges scale to match the size of the immediate parent element by using relative font sizing and
8
- `em` units.
9
-
10
- ```html
11
- <div>
12
- <h2>Example heading <b-badge>New</b-badge></h2>
13
- <h3>Example heading <b-badge>New</b-badge></h3>
14
- <h4>Example heading <b-badge>New</b-badge></h4>
15
- <h5>Example heading <b-badge>New</b-badge></h5>
16
- <h6>Example heading <b-badge>New</b-badge></h6>
17
- </div>
18
-
19
- <!-- b-badges.vue -->
20
- ```
21
-
22
- Badges can be used as part of links or buttons to provide a counter (or similar flag).
23
-
24
- ```html
25
- <div class="text-center">
26
- <b-button variant="primary">
27
- Notifications <b-badge variant="light">4</b-badge>
28
- </b-button>
29
- </div>
30
-
31
- <!-- b-badge-button.vue -->
32
- ```
33
-
34
- Note that depending on how they are used, badges may be confusing for users of screen readers and
35
- similar assistive technologies. While the styling of badges provides a visual cue as to their
36
- purpose, these users will simply be presented with the content of the badge. Depending on the
37
- specific situation, these badges may seem like random additional words or numbers at the end of a
38
- sentence, link, or button.
39
-
40
- Unless the context is clear (as with the "Notifications" example, where it is understood that the
41
- "4" is the number of notifications), consider including additional context with a visually hidden
42
- piece of additional text.
43
-
44
- ```html
45
- <div class="text-center">
46
- <b-button variant="primary">
47
- Profile
48
- <b-badge variant="light">9 <span class="sr-only">unread messages</span></b-badge>
49
- </b-button>
50
- </div>
51
-
52
- <!-- b-badge-button-aria.vue -->
53
- ```
54
-
55
- ## Contextual variations
56
-
57
- Add any of the following variants via the `variant` prop to change the appearance of a `<b-badge>`:
58
- `default`, `primary`, `success`, `warning`, `info`, and `danger`. If no variant is specified
59
- `default` will be used.
60
-
61
- ```html
62
- <div>
63
- <b-badge variant="primary">Primary</b-badge>
64
- <b-badge variant="secondary">Secondary</b-badge>
65
- <b-badge variant="success">Success</b-badge>
66
- <b-badge variant="danger">Danger</b-badge>
67
- <b-badge variant="warning">Warning</b-badge>
68
- <b-badge variant="info">Info</b-badge>
69
- <b-badge variant="light">Light</b-badge>
70
- <b-badge variant="dark">Dark</b-badge>
71
- </div>
72
-
73
- <!-- b-badge-variants.vue -->
74
- ```
75
-
76
- ### Conveying meaning to assistive technologies
77
-
78
- Using color to add meaning only provides a visual indication, which will not be conveyed to users of
79
- assistive technologies – such as screen readers. Ensure that information denoted by the color is
80
- either obvious from the content itself (e.g. the visible text), or is included through alternative
81
- means, such as additional text hidden with the `.sr-only` class.
82
-
83
- ## Pill badges
84
-
85
- Use the `pill` prop to make badges more rounded (with a larger border-radius and additional
86
- horizontal padding). Useful if you miss the badges from Bootstrap v3.
87
-
88
- ```html
89
- <div>
90
- <b-badge pill variant="primary">Primary</b-badge>
91
- <b-badge pill variant="secondary">Secondary</b-badge>
92
- <b-badge pill variant="success">Success</b-badge>
93
- <b-badge pill variant="danger">Danger</b-badge>
94
- <b-badge pill variant="warning">Warning</b-badge>
95
- <b-badge pill variant="info">Info</b-badge>
96
- <b-badge pill variant="light">Light</b-badge>
97
- <b-badge pill variant="dark">Dark</b-badge>
98
- </div>
99
-
100
- <!-- b-badge-pill.vue -->
101
- ```
102
-
103
- ## Actionable badges
104
-
105
- Quickly provide actionable badges with hover and focus states by specifying either the `href` prop
106
- (links) or `to` prop (router-links):
107
-
108
- ```html
109
- <div>
110
- <b-badge href="#" variant="primary">Primary</b-badge>
111
- <b-badge href="#" variant="secondary">Secondary</b-badge>
112
- <b-badge href="#" variant="success">Success</b-badge>
113
- <b-badge href="#" variant="danger">Danger</b-badge>
114
- <b-badge href="#" variant="warning">Warning</b-badge>
115
- <b-badge href="#" variant="info">Info</b-badge>
116
- <b-badge href="#" variant="light">Light</b-badge>
117
- <b-badge href="#" variant="dark">Dark</b-badge>
118
- </div>
119
-
120
- <!-- b-badge-action.vue -->
121
- ```
122
-
123
- Refer to the [Router support](?path=/docs/base-link--docs#router-link-support) reference page for
124
- router-link specific props.
125
-
126
- <!-- Component reference added automatically from component package.json -->
@@ -1,55 +0,0 @@
1
- import { extend, mergeData } from '../../vue'
2
- import { NAME_BADGE } from '../../constants/components'
3
- import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props'
4
- import { omit, sortKeys } from '../../utils/object'
5
- import { makeProp, makePropsConfigurable, pluckProps } from '../../utils/props'
6
- import { isLink } from '../../utils/router'
7
- import { BLink, props as BLinkProps } from '../link/link'
8
-
9
- // --- Props ---
10
-
11
- const linkProps = omit(BLinkProps, ['event', 'routerTag'])
12
- delete linkProps.href.default
13
- delete linkProps.to.default
14
-
15
- export const props = makePropsConfigurable(
16
- sortKeys({
17
- ...linkProps,
18
- pill: makeProp(PROP_TYPE_BOOLEAN, false),
19
- tag: makeProp(PROP_TYPE_STRING, 'span'),
20
- variant: makeProp(PROP_TYPE_STRING, 'secondary')
21
- }),
22
- NAME_BADGE
23
- )
24
-
25
- // --- Main component ---
26
-
27
- // @vue/component
28
- export const BBadge = /*#__PURE__*/ extend({
29
- name: NAME_BADGE,
30
- functional: true,
31
- props,
32
- render(h, { props, data, children }) {
33
- const { active, disabled } = props
34
- const link = isLink(props)
35
- const tag = link ? BLink : props.tag
36
- const variant = props.variant || 'secondary'
37
-
38
- return h(
39
- tag,
40
- mergeData(data, {
41
- staticClass: 'badge',
42
- class: [
43
- `badge-${variant}`,
44
- {
45
- 'badge-pill': props.pill,
46
- active,
47
- disabled
48
- }
49
- ],
50
- props: link ? pluckProps(linkProps, props) : {}
51
- }),
52
- children
53
- )
54
- }
55
- })