Skip to content

Commit 4cf0219

Browse files
authored
fix: css fixes for tag (#626)
1 parent 18ea367 commit 4cf0219

File tree

2 files changed

+62
-70
lines changed

2 files changed

+62
-70
lines changed

src/components/tag/tag.js

+61-69
Original file line numberDiff line numberDiff line change
@@ -42,81 +42,72 @@ const getWrapperBackgroundColor = type =>
4242
? vars.backgroundColorTagWarning
4343
: vars.backgroundColorTagPristine;
4444

45-
const getClickableContentWrapperStyles = ({ type, isRemoveable }) =>
45+
const getClickableContentWrapperStyles = ({ type }) =>
4646
type === 'warning'
47-
? [
48-
css`
49-
&:hover {
50-
border-color: ${vars.borderColorTagWarningHover};
51-
border-right: 1px solid ${vars.borderColorTagPristine};
52-
}
53-
`,
54-
isRemoveable &&
55-
css`
56-
border-right: 1px solid ${vars.borderColorTagWarning};
57-
`,
58-
]
47+
? []
5948
: [
6049
css`
6150
&:hover {
6251
border-color: ${vars.borderColorTagFocus};
6352
}
6453
`,
54+
];
55+
56+
export const TagLinkBody = props => {
57+
const isRemoveable = Boolean(props.onRemove);
58+
return (
59+
<div
60+
css={[
61+
getContentWrapperStyles(props),
62+
!props.isDisabled &&
63+
css`
64+
cursor: pointer;
65+
`,
66+
!props.isDisabled &&
67+
isRemoveable &&
68+
css`
69+
padding-right: ${vars.spacing8};
70+
`,
71+
!props.isDisabled &&
72+
getClickableContentWrapperStyles({
73+
type: props.type,
74+
}),
6575
isRemoveable &&
6676
css`
67-
&:hover {
68-
border-right: 1px solid ${vars.borderColorTagPristine};
69-
}
77+
border-right: 0;
78+
border-top-right-radius: 0;
79+
border-bottom-right-radius: 0;
7080
`,
71-
];
72-
73-
export const TagLinkBody = props => (
74-
<div
75-
css={[
76-
getContentWrapperStyles(props),
77-
!props.isDisabled &&
78-
css`
79-
cursor: pointer;
80-
`,
81-
!props.isDisabled &&
82-
Boolean(props.onRemove) &&
83-
css`
84-
padding-right: ${vars.spacing8};
85-
`,
86-
!props.isDisabled &&
87-
getClickableContentWrapperStyles({
88-
type: props.type,
89-
isRemoveable: Boolean(props.onRemove),
90-
}),
91-
]}
92-
>
93-
{!props.isDisabled ? (
94-
<Link
95-
onClick={props.onClick}
96-
to={props.linkTo}
97-
css={css`
98-
text-decoration: none;
99-
`}
100-
>
81+
]}
82+
>
83+
{!props.isDisabled ? (
84+
<Link
85+
onClick={props.onClick}
86+
to={props.linkTo}
87+
css={css`
88+
text-decoration: none;
89+
`}
90+
>
91+
<Text.Detail
92+
css={css`
93+
color: ${getTextDetailColor(props.isDisabled)};
94+
`}
95+
>
96+
{props.children}
97+
</Text.Detail>
98+
</Link>
99+
) : (
101100
<Text.Detail
102101
css={css`
103102
color: ${getTextDetailColor(props.isDisabled)};
104103
`}
105104
>
106105
{props.children}
107106
</Text.Detail>
108-
</Link>
109-
) : (
110-
<Text.Detail
111-
css={css`
112-
color: ${getTextDetailColor(props.isDisabled)};
113-
`}
114-
>
115-
{props.children}
116-
</Text.Detail>
117-
)}
118-
</div>
119-
);
107+
)}
108+
</div>
109+
);
110+
};
120111

121112
TagLinkBody.displayName = 'TagLinkBody';
122113
TagLinkBody.propTypes = {
@@ -135,6 +126,9 @@ export const TagNormalBody = props => (
135126
Boolean(props.onRemove) &&
136127
css`
137128
padding-right: ${vars.spacing8};
129+
border-right: 0;
130+
border-top-right-radius: 0;
131+
border-bottom-right-radius: 0;
138132
`,
139133
!props.isDisabled &&
140134
Boolean(props.onClick) &&
@@ -208,29 +202,27 @@ const Tag = props => (
208202
onClick={props.isDisabled ? undefined : props.onRemove}
209203
css={[
210204
css`
211-
border-color: ${vars.borderColorTagPristine};
205+
border-color: ${props.type === 'warning'
206+
? vars.borderColorTagWarning
207+
: vars.borderColorTagPristine};
212208
padding: 0 ${vars.spacing4};
213209
border-radius: 0 ${vars.borderRadiusTag} ${vars.borderRadiusTag} 0;
214210
display: flex;
215211
align-items: center;
216212
background: inherit;
217213
border-style: solid;
218-
border-width: 1px 1px 1px 0;
214+
border-width: 1px 1px 1px 1px;
219215
&:hover {
220-
background-color: ${vars.backgroundColorTagNormalHover};
221-
box-shadow: ${vars.shadowBoxTagHover};
216+
border-color: ${vars.borderColorTagWarning};
217+
218+
> svg * {
219+
fill: ${vars.borderColorTagWarning};
220+
}
222221
}
223222
> svg * {
224223
fill: ${vars.fontColorDefault};
225224
}
226225
`,
227-
props.type === 'warning' &&
228-
css`
229-
border-color: ${vars.borderColorTagWarning};
230-
&:hover {
231-
background-color: ${vars.borderColorTagWarningHover};
232-
}
233-
`,
234226
props.isDisabled &&
235227
css`
236228
&:hover {

src/components/tag/tag.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Story = () => (
1212
<Section>
1313
<Tag
1414
type={select('type', ['normal', 'warning'], 'normal')}
15-
linkTo={select('linkTo', ['/foo', undefined], '/foo')}
15+
linkTo={select('linkTo', ['/foo', null], '/foo')}
1616
isDisabled={boolean('isDisabled', false)}
1717
onClick={boolean('onClick', false) ? action('onClick') : undefined}
1818
horizontalConstraint={select(

0 commit comments

Comments
 (0)