Skip to content

Commit 4b8c1ee

Browse files
authored
refactor(ui5-badge): rename Badge ui5-badge to Tag ui5-tag (#8884)
Rename Badge to Tag - tags, styles, classes to match with the SAP Design Tag concept. BREAKING CHANGE: Badge web component has been renamed to Tag. If you have previously used the `ui5-badge`: ```html <ui5-badge></ui5-badge> ``` Now use `ui5-tag` instead: ```html <ui5-tag></ui5-tag> ``` Related to: #8461
1 parent edfb381 commit 4b8c1ee

File tree

156 files changed

+2446
-2430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+2446
-2430
lines changed

docs/3-customizing/01-styles.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ One of the core principles of Web Components is the encapsulation. The HTML and
66

77

88
## Styles on Tag Level
9-
We designed some components such as Title, Label, Badge, Button, Input, and a few more in such a way that it is possible to set styles/classes on the custom elements that will take effect.
9+
We designed some components such as Title, Label, Tag, Button, Input, and a few more in such a way that it is possible to set styles/classes on the custom elements that will take effect.
1010

1111
<b>For example:</b>
1212
```css

docs/5-development/04-understanding-hbs-templates.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Examples:
354354

355355
```handlebars
356356
{{#if hasText}}
357-
<label class="ui5-badge-text"><bdi><slot></slot></bdi></label>
357+
<label class="ui5-tag-text"><bdi><slot></slot></bdi></label>
358358
{{/if}}
359359
```
360360

docs/Migrating to version 2.0 guide.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ import "@ui5/webcomponents-icons/dist/Assets.js"
5858

5959
## Main package (@ui5/webcomponents)
6060

61+
### ui5-badge
62+
63+
| Changed item | Old | New |
64+
|-------------------------------|-------------------|--------------|
65+
| tag | `ui5-badge` | `ui5-tag` |
66+
67+
- The Badge `ui5-badge` has been renamed to Tag `ui5-tag`. If you have previously used the `ui5-badge`:
68+
```html
69+
<ui5-badge></ui5-badge>
70+
```
71+
Now use `ui5-tag` instead:
72+
```html
73+
<ui5-tag></ui5-tag>
74+
```
75+
76+
6177
### ui5-breadcrumbs
6278

6379
| Changed item | Old | New |
@@ -75,7 +91,6 @@ Now use `separators` instead:
7591
<ui5-breadcrumbs separators="Slash">
7692
```
7793

78-
7994
### ui5-busy-indicator
8095

8196
| Changed item | Old | New |

packages/fiori/test/pages/DynamicSideContent.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ <h1>Side Content</h1>
3838

3939
<div slot="footer">
4040
<ui5-bar design="FloatingFooter">
41-
<ui5-badge class="breakpointBadge" id="breakpointS" color-scheme="5" slot="startContent">S</ui5-badge>
42-
<ui5-badge class="breakpointBadge" id="breakpointM" color-scheme="6" slot="startContent">M</ui5-badge>
43-
<ui5-badge class="breakpointBadge" id="breakpointL" color-scheme="7" slot="startContent">L</ui5-badge>
44-
<ui5-badge class="breakpointBadge" id="breakpointXL" color-scheme="8" slot="startContent">XL</ui5-badge>
41+
<ui5-tag class="breakpointTag" id="breakpointS" color-scheme="5" slot="startContent">S</ui5-tag>
42+
<ui5-tag class="breakpointTag" id="breakpointM" color-scheme="6" slot="startContent">M</ui5-tag>
43+
<ui5-tag class="breakpointTag" id="breakpointL" color-scheme="7" slot="startContent">L</ui5-tag>
44+
<ui5-tag class="breakpointTag" id="breakpointXL" color-scheme="8" slot="startContent">XL</ui5-tag>
4545
<ui5-switch id="hideMainContent" class="hide-on-S" text-on="M +" text-off="M -" title="MainContent" checked></ui5-switch>
4646
<ui5-switch id="hideSideContent" class="hide-on-S" text-on="S +" text-off="S -" title="SideContent" checked></ui5-switch>
4747
<ui5-switch id="equalSplit" class="hide-on-S" text-on="EQ" text-off="! EQ" title="equalSplit"></ui5-switch>
@@ -113,7 +113,7 @@ <h1>Side Content</h1>
113113
var breakpoint = event.detail.currentBreakpoint,
114114
disp = breakpoint === "S" ? "none" : "block";
115115

116-
document.querySelectorAll('.breakpointBadge').forEach(function(elem) { elem.style.display = "none"; });
116+
document.querySelectorAll('.breakpointTag').forEach(function(elem) { elem.style.display = "none"; });
117117
document.querySelector("#breakpoint" + breakpoint).style.display="block";
118118
document.querySelectorAll('.hide-on-S').forEach(function(elem) { elem.style.display = disp; });
119119
toggleButton.style.display = breakpoint !== "S" || dynamicSideContent.sideContentVisibility === "AlwaysShow" ? "none" : "block";

packages/fiori/test/pages/styles/DynamicSideContent.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body, html {
1313
padding: 0.5rem;
1414
}
1515

16-
.breakpointBadge {
16+
.breakpointTag {
1717
display: none;
1818
}
1919

packages/main/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Provides general purpose UI building blocks such as buttons, labels, inputs and
1313
|--------------------------|-----------------------------|------------------------------------------------------------|
1414
| Avatar | `ui5-avatar` | `import "@ui5/webcomponents/dist/Avatar.js";` |
1515
| Avatar Group | `ui5-avatar-group` | `import "@ui5/webcomponents/dist/AvatarGroup.js";` |
16-
| Badge | `ui5-badge` | `import "@ui5/webcomponents/dist/Badge.js";` |
16+
| Tag | `ui5-tag` | `import "@ui5/webcomponents/dist/Tag.js";` |
1717
| Bar | `ui5-bar` | `import "@ui5/webcomponents/dist/Bar.js";` |
1818
| Breadcrumbs | `ui5-breadcrumbs` | `import "@ui5/webcomponents/dist/Breadcrumbs.js";` |
1919
| Breadcrumbs Item | `ui5-breadcrumbs-item` | comes with `ui5-breadcrumbs` |
20-
| Badge | `ui5-badge` | `import "@ui5/webcomponents/dist/Badge.js";` |
20+
| Tag | `ui5-tag` | `import "@ui5/webcomponents/dist/Tag.js";` |
2121
| Busy Indicator | `ui5-busy-indicator` | `import "@ui5/webcomponents/dist/BusyIndicator.js";` |
2222
| Button | `ui5-button` | `import "@ui5/webcomponents/dist/Button.js";` |
2323
| Calendar | `ui5-calendar` | `import "@ui5/webcomponents/dist/Calendar.js";` |

packages/main/src/Avatar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class Avatar extends UI5Element implements ITabbable, IAvatarGroupItem {
218218
* Defines the optional badge that will be used for visual affordance.
219219
*
220220
* **Note:** While the slot allows for custom badges, to achieve
221-
* the Fiori design, please use `ui5-badge` with `ui5-icon`
221+
* the Fiori design, you can use the `ui5-tag` with `ui5-icon`
222222
* in the corresponding `icon` slot, without text nodes.
223223
* @public
224224
* @since 1.7.0

packages/main/src/Badge.hbs packages/main/src/Tag.hbs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{#if interactive}}
2-
<button class="ui5-badge-root"
2+
<button class="ui5-tag-root"
33
title="{{_title}}"
44
aria-roledescription="{{_roleDescription}}"
55
aria-description="{{_valueState}}"
@@ -8,7 +8,7 @@
88
{{> content}}
99
</button>
1010
{{else}}
11-
<div class="ui5-badge-root"
11+
<div class="ui5-tag-root"
1212
title="{{_title}}">
1313
{{> content}}
1414
</div>
@@ -17,11 +17,11 @@
1717
{{#*inline "content"}}
1818
<slot name="icon"></slot>
1919
{{#if this._semanticIconName}}
20-
<ui5-icon class="ui5-badge-semantic-icon" name="{{_semanticIconName}}"></ui5-icon>
20+
<ui5-icon class="ui5-tag-semantic-icon" name="{{_semanticIconName}}"></ui5-icon>
2121
{{/if}}
22-
<span class="ui5-hidden-text">{{badgeDescription}}</span>
22+
<span class="ui5-hidden-text">{{tagDescription}}</span>
2323
{{#if hasText}}
24-
<span class="ui5-badge-text"><bdi><slot></slot></bdi></span>
24+
<span class="ui5-tag-text"><bdi><slot></slot></bdi></span>
2525
{{/if}}
2626
{{/inline}}
2727

packages/main/src/Badge.ts packages/main/src/Tag.ts

+50-50
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ import "@ui5/webcomponents-icons/dist/error.js";
1818
import "@ui5/webcomponents-icons/dist/alert.js";
1919
import "@ui5/webcomponents-icons/dist/information.js";
2020
import WrappingType from "./types/WrappingType.js";
21-
import BadgeDesign from "./types/BadgeDesign.js";
22-
import BadgeSize from "./types/BadgeSize.js";
21+
import TagDesign from "./types/TagDesign.js";
22+
import TagSize from "./types/TagSize.js";
2323
// Template
24-
import BadgeTemplate from "./generated/templates/BadgeTemplate.lit.js";
24+
import TagTemplate from "./generated/templates/TagTemplate.lit.js";
2525

2626
import {
27-
BADGE_DESCRIPTION_BADGE,
28-
BADGE_DESCRIPTION_TAG,
29-
BADGE_ROLE_DESCRIPTION,
30-
BADGE_ERROR,
31-
BADGE_WARNING,
32-
BADGE_SUCCESS,
33-
BADGE_INFORMATION,
27+
TAG_DESCRIPTION_BADGE,
28+
TAG_DESCRIPTION_TAG,
29+
TAG_ROLE_DESCRIPTION,
30+
TAG_ERROR,
31+
TAG_WARNING,
32+
TAG_SUCCESS,
33+
TAG_INFORMATION,
3434
} from "./generated/i18n/i18n-defaults.js";
3535

3636
// Styles
37-
import badgeCss from "./generated/themes/Badge.css.js";
37+
import tagCss from "./generated/themes/Tag.css.js";
3838

3939
/**
4040
* @class
4141
* ### Overview
4242
*
43-
* The `ui5-badge` is a component which serves
43+
* The `ui5-tag` is a component which serves
4444
* the purpose to attract the user attention to some piece
4545
* of information (state, quantity, condition, etc.).
4646
* It can contain icon and text information, and its design can be chosen from specific design types.
@@ -52,40 +52,40 @@ import badgeCss from "./generated/themes/Badge.css.js";
5252
*
5353
* ### ES6 Module Import
5454
*
55-
* `import "@ui5/webcomponents/dist/Badge.js";`
55+
* `import "@ui5/webcomponents/dist/Tag.js";`
5656
* @constructor
5757
* @extends UI5Element
58-
* @since 0.12.0
58+
* @since 2.0.0
5959
* @public
6060
*/
6161
@customElement({
62-
tag: "ui5-badge",
62+
tag: "ui5-tag",
6363
languageAware: true,
6464
renderer: litRender,
65-
template: BadgeTemplate,
66-
styles: badgeCss,
65+
template: TagTemplate,
66+
styles: tagCss,
6767
dependencies: [
6868
Icon,
6969
],
7070
})
7171

7272
/**
73-
* Fired when the user clicks on an interactive badge.
73+
* Fired when the user clicks on an interactive tag.
7474
*
7575
* **Note:** The event will be fired if the `interactive` property is `true`
7676
* @public
7777
* @since 1.22.0
7878
*/
7979
@event("click")
80-
class Badge extends UI5Element {
80+
class Tag extends UI5Element {
8181
/**
8282
* Defines the design type of the component.
8383
* @default "Neutral"
8484
* @public
8585
* @since 1.22.0
8686
*/
87-
@property({ defaultValue: BadgeDesign.Neutral })
88-
design!: `${BadgeDesign}`;
87+
@property({ defaultValue: TagDesign.Neutral })
88+
design!: `${TagDesign}`;
8989

9090
/**
9191
* Defines the color scheme of the component.
@@ -109,8 +109,8 @@ class Badge extends UI5Element {
109109
/**
110110
* Defines if the component is interactive (focusable and pressable).
111111
*
112-
* **Note:** The badge cannot be `interactive`
113-
* when `design` property is `BadgeDesign.Set3`
112+
* **Note:** The tag cannot be `interactive`
113+
* when `design` property is `TagDesign.Set3`
114114
* @default false
115115
* @public
116116
* @since 1.22.0
@@ -136,25 +136,25 @@ class Badge extends UI5Element {
136136
* @public
137137
* @since 2.0
138138
*/
139-
@property({ type: BadgeSize, defaultValue: BadgeSize.S })
140-
size!: `${BadgeSize}`;
139+
@property({ type: TagSize, defaultValue: TagSize.S })
140+
size!: `${TagSize}`;
141141

142142
/**
143-
* Defines if the badge has an icon.
143+
* Defines if the tag has an icon.
144144
* @private
145145
*/
146146
@property({ type: Boolean })
147147
_hasIcon!: boolean;
148148

149149
/**
150-
* Defines if the badge has only an icon (and no text).
150+
* Defines if the tag has only an icon (and no text).
151151
* @private
152152
*/
153153
@property({ type: Boolean })
154154
_iconOnly!: boolean;
155155

156156
/**
157-
* Defines if the badge has "Tag" design type.
157+
* Defines if the tag has "Tag" design type.
158158
* @private
159159
*/
160160
@property({ type: Boolean })
@@ -179,7 +179,7 @@ class Badge extends UI5Element {
179179
static i18nBundle: I18nBundle;
180180

181181
static async onDefine() {
182-
Badge.i18nBundle = await getI18nBundle("@ui5/webcomponents");
182+
Tag.i18nBundle = await getI18nBundle("@ui5/webcomponents");
183183
}
184184

185185
onEnterDOM() {
@@ -191,23 +191,23 @@ class Badge extends UI5Element {
191191
onBeforeRendering() {
192192
this._hasIcon = this.hasIcon || !!this._semanticIconName;
193193
this._iconOnly = this.iconOnly;
194-
this._isTagDesign = this.design !== BadgeDesign.Set3;
194+
this._isTagDesign = this.design !== TagDesign.Set3;
195195
}
196196

197197
get _roleDescription() {
198-
return Badge.i18nBundle.getText(BADGE_ROLE_DESCRIPTION);
198+
return Tag.i18nBundle.getText(TAG_ROLE_DESCRIPTION);
199199
}
200200

201201
get _valueState() {
202202
switch (this.design) {
203-
case BadgeDesign.Positive:
204-
return Badge.i18nBundle.getText(BADGE_SUCCESS);
205-
case BadgeDesign.Negative:
206-
return Badge.i18nBundle.getText(BADGE_ERROR);
207-
case BadgeDesign.Critical:
208-
return Badge.i18nBundle.getText(BADGE_WARNING);
209-
case BadgeDesign.Information:
210-
return Badge.i18nBundle.getText(BADGE_INFORMATION);
203+
case TagDesign.Positive:
204+
return Tag.i18nBundle.getText(TAG_SUCCESS);
205+
case TagDesign.Negative:
206+
return Tag.i18nBundle.getText(TAG_ERROR);
207+
case TagDesign.Critical:
208+
return Tag.i18nBundle.getText(TAG_WARNING);
209+
case TagDesign.Information:
210+
return Tag.i18nBundle.getText(TAG_INFORMATION);
211211
}
212212

213213
return undefined;
@@ -229,17 +229,17 @@ class Badge extends UI5Element {
229229
return this.title || undefined;
230230
}
231231

232-
get badgeDescription() {
232+
get tagDescription() {
233233
if (this.interactive) {
234234
return undefined;
235235
}
236236

237-
if (this.design === BadgeDesign.Set3) {
238-
return Badge.i18nBundle.getText(BADGE_DESCRIPTION_BADGE);
237+
if (this.design === TagDesign.Set3) {
238+
return Tag.i18nBundle.getText(TAG_DESCRIPTION_BADGE);
239239
}
240240

241241
const valueState = this._valueState;
242-
let description = Badge.i18nBundle.getText(BADGE_DESCRIPTION_TAG);
242+
let description = Tag.i18nBundle.getText(TAG_DESCRIPTION_TAG);
243243

244244
if (valueState) {
245245
description = `${description} ${valueState}`;
@@ -254,15 +254,15 @@ class Badge extends UI5Element {
254254
}
255255

256256
switch (this.design) {
257-
case BadgeDesign.Neutral:
257+
case TagDesign.Neutral:
258258
return "sys-help-2";
259-
case BadgeDesign.Positive:
259+
case TagDesign.Positive:
260260
return "sys-enter-2";
261-
case BadgeDesign.Negative:
261+
case TagDesign.Negative:
262262
return "error";
263-
case BadgeDesign.Critical:
263+
case TagDesign.Critical:
264264
return "alert";
265-
case BadgeDesign.Information:
265+
case TagDesign.Information:
266266
return "information";
267267
default:
268268
return null;
@@ -274,6 +274,6 @@ class Badge extends UI5Element {
274274
}
275275
}
276276

277-
Badge.define();
277+
Tag.define();
278278

279-
export default Badge;
279+
export default Tag;

packages/main/src/bundle.esm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ import * as defaultTexts from "./generated/i18n/i18n-defaults.js";
9898

9999
import Avatar from "./Avatar.js";
100100
import AvatarGroup from "./AvatarGroup.js";
101-
import Badge from "./Badge.js";
102101
import Bar from "./Bar.js";
103102
import Breadcrumbs from "./Breadcrumbs.js";
104103
import BusyIndicator from "./BusyIndicator.js";
@@ -144,10 +143,11 @@ import MessageStrip from "./MessageStrip.js";
144143
import MultiComboBox from "./MultiComboBox.js";
145144
import ProgressIndicator from "./ProgressIndicator.js";
146145
import RatingIndicator from "./RatingIndicator.js";
147-
import Text from "./Text.js";
146+
import Tag from "./Tag.js";
148147
import TabContainer from "./TabContainer.js";
149148
import Tab from "./Tab.js";
150149
import TabSeparator from "./TabSeparator.js";
150+
import Text from "./Text.js";
151151
import TextArea from "./TextArea.js";
152152
import TimePicker from "./TimePicker.js";
153153
import TimePickerClock from "./TimePickerClock.js";

0 commit comments

Comments
 (0)