Skip to content

Commit 255d84f

Browse files
committed
feat(ui-tag): remove the inline variant from Tag v2
BREAKING CHANGE: the inline variant and the variant prop have been removed from Tag v2. Refs: INSTUI-5127
1 parent bcfd452 commit 255d84f

6 files changed

Lines changed: 16 additions & 115 deletions

File tree

docs/upgrading/upgrade-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,7 @@ type: embed
15831583
### Tag
15841584

15851585
- Previously deprecated `title` prop has been removed.
1586+
- The `inline` variant has been removed along with the `variant` prop.
15861587

15871588
```js
15881589
---

packages/ui-tag/src/Tag/v2/README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ type: example
8282
/>
8383
```
8484

85-
### Inline variant
86-
87-
This variant is designed to look similar to the surrounding text.
88-
89-
```js
90-
---
91-
type: example
92-
---
93-
<Text as="p">
94-
This is an
95-
<Tag
96-
dismissible
97-
onClick={() => alert('Tag dismissed')}
98-
size="large"
99-
text={<AccessibleContent alt="Remove 'inline'">
100-
inline
101-
</AccessibleContent>}
102-
variant="inline"
103-
/>
104-
tag.
105-
</Text>
106-
```
107-
10885
### Guidelines
10986

11087
```js

packages/ui-tag/src/Tag/v2/index.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Tag extends Component<TagProps> {
5050
static defaultProps = {
5151
size: 'medium',
5252
dismissible: false,
53-
variant: 'default',
5453
disabled: false,
5554
readOnly: false
5655
}
@@ -105,11 +104,7 @@ class Tag extends Component<TagProps> {
105104
}
106105

107106
getIconSize = () => {
108-
const { size, variant } = this.props
109-
110-
if (variant === 'inline') {
111-
return 'xs'
112-
}
107+
const { size } = this.props
113108

114109
const sizeMap = {
115110
small: 'xs',
@@ -129,8 +124,7 @@ class Tag extends Component<TagProps> {
129124
text,
130125
onClick,
131126
margin,
132-
styles,
133-
variant
127+
styles
134128
} = this.props
135129

136130
const passthroughProps = View.omitViewProps(
@@ -142,9 +136,6 @@ class Tag extends Component<TagProps> {
142136
if (disabled) {
143137
return 'mutedColor'
144138
}
145-
if (variant === 'inline') {
146-
return 'inverseColor'
147-
}
148139
return this.state.iconHovered ? 'actionSecondaryHoverColor' : 'baseColor'
149140
}
150141

packages/ui-tag/src/Tag/v2/props.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ type TagOwnProps = {
5959
*/
6060
elementRef?: (element: Element | null) => void
6161
size?: 'small' | 'medium' | 'large'
62-
variant?: 'default' | 'inline'
6362
}
6463

6564
type PropKeys = keyof TagOwnProps
@@ -80,8 +79,7 @@ const allowedProps: AllowedPropKeys = [
8079
'margin',
8180
'onClick',
8281
'elementRef',
83-
'size',
84-
'variant'
82+
'size'
8583
]
8684

8785
export type { TagProps, TagStyle }

packages/ui-tag/src/Tag/v2/styles.ts

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const generateStyle = (
4141
props: TagProps,
4242
sharedTokens: SharedTokens
4343
): TagStyle => {
44-
const { variant, size, dismissible, onClick, disabled } = props
44+
const { size, dismissible, onClick, disabled } = props
4545

4646
const isButton = !!onClick
4747

@@ -118,66 +118,6 @@ const generateStyle = (
118118
}
119119
: {}
120120

121-
const tagVariantVariants = {
122-
default: {
123-
tag: {
124-
backgroundColor: componentTheme.defaultBackground,
125-
border: `${componentTheme.defaultBorderWidth} ${componentTheme.defaultBorderStyle} ${componentTheme.defaultBorderColor}`,
126-
borderRadius: componentTheme.defaultBorderRadius,
127-
color: componentTheme.defaultColor,
128-
...(isButton && {
129-
'&:hover': { backgroundColor: componentTheme.defaultBackgroundHover }
130-
})
131-
},
132-
tagBefore: {
133-
...(isButton && {
134-
borderRadius: componentTheme.defaultBorderRadius
135-
})
136-
}
137-
},
138-
inline: {
139-
tag: {
140-
backgroundColor: componentTheme.inlineBackground,
141-
border: `${componentTheme.inlineBorderWidth} ${componentTheme.inlineBorderStyle} ${componentTheme.inlineBorderColor}`,
142-
borderRadius: componentTheme.inlineBorderRadius,
143-
color: componentTheme.inlineColor,
144-
cursor: 'text',
145-
margin: '0 0.1875rem 0.1875rem',
146-
...(isButton && {
147-
'&:hover': { backgroundColor: componentTheme.inlineBackgroundHover }
148-
})
149-
},
150-
tagBefore: {
151-
...(isButton && {
152-
borderRadius: `calc(${componentTheme.inlineBorderRadius} * 1.5)`
153-
})
154-
}
155-
}
156-
}
157-
158-
const inlineIconVariant =
159-
variant === 'inline' && dismissible
160-
? {
161-
backgroundColor: componentTheme.inlineIconColor,
162-
borderRadius: '50%',
163-
padding: '0.25rem',
164-
position: 'absolute',
165-
insetInlineEnd: 0,
166-
insetInlineStart: 'auto',
167-
top: 0,
168-
transform: 'translate(40%, -40%)',
169-
display: 'flex',
170-
alignItems: 'center',
171-
justifyContent: 'center',
172-
173-
'[class$="-tag"]:hover > &': {
174-
backgroundColor: componentTheme.inlineIconHoverColor
175-
},
176-
177-
'[dir="rtl"] &': { transform: 'translate(-40%, -40%)' }
178-
}
179-
: {}
180-
181121
return {
182122
tag: {
183123
label: 'tag',
@@ -188,13 +128,21 @@ const generateStyle = (
188128
textAlign: 'center',
189129
verticalAlign: 'middle',
190130
userSelect: 'none',
131+
backgroundColor: componentTheme.defaultBackground,
132+
border: `${componentTheme.defaultBorderWidth} ${componentTheme.defaultBorderStyle} ${componentTheme.defaultBorderColor}`,
133+
borderRadius: componentTheme.defaultBorderRadius,
134+
color: componentTheme.defaultColor,
135+
...(isButton && {
136+
'&:hover': { backgroundColor: componentTheme.defaultBackgroundHover }
137+
}),
191138
...sizeVariants[size!].tag,
192139
...buttonVariant.tag,
193-
...tagVariantVariants[variant!].tag,
194140

195141
'&::before': {
196142
...buttonVariant.tagBefore,
197-
...tagVariantVariants[variant!].tagBefore
143+
...(isButton && {
144+
borderRadius: componentTheme.defaultBorderRadius
145+
})
198146
}
199147
},
200148
text: {
@@ -210,8 +158,7 @@ const generateStyle = (
210158
marginInlineStart: componentTheme.iconMargin,
211159
marginInlineEnd: 0,
212160
transition: `all ${componentTheme.transitionTiming}`,
213-
cursor: 'pointer',
214-
...inlineIconVariant
161+
cursor: 'pointer'
215162
}
216163
}
217164
}

regression-test/src/app/small-components/page.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,6 @@ export default function SmallComponentsPage() {
106106
onClick={function () {}}
107107
/>
108108
</div>
109-
<p>
110-
This is an
111-
<Tag
112-
dismissible
113-
onClick={() => alert('Tag dismissed')}
114-
size="large"
115-
text={
116-
<AccessibleContent alt="Remove 'inline'">inline</AccessibleContent>
117-
}
118-
variant="inline"
119-
/>
120-
tag.
121-
</p>
122109
<div>TimeSelect:</div>
123110
<TimeSelect
124111
renderLabel="Choose a time"

0 commit comments

Comments
 (0)