Skip to content

Commit 3b773b7

Browse files
authored
feat: FilterChip 컴포넌트의 일부 디자인 속성을 변경한다 (#1029)
* feat: 필터칩의 일부 디자인 속성을 변경한다 * test: 스냅샷 테스트를 추가한다
1 parent baf8b64 commit 3b773b7

File tree

4 files changed

+119
-25
lines changed

4 files changed

+119
-25
lines changed

packages/vibrant-components/src/lib/FilterChip/FilterChip.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ describe('<FilterChip />', () => {
1818
it('should render link with href attribute', () => {
1919
expect(renderer.getByRole('link').getAttribute('href')).toBe('https://www.vibrant-design.com');
2020
});
21+
22+
it('match snapshot', () => {
23+
expect(renderer.container).toMatchSnapshot();
24+
});
2125
});
2226
});

packages/vibrant-components/src/lib/FilterChip/FilterChip.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ export const FilterChip = withFilterChipVariation(
2222
testId={testId}
2323
flexGrow={0}
2424
flexShrink={0}
25-
rounded="xl"
2625
maxWidth={maxWidth}
2726
flexDirection="row"
2827
alignItems="center"
28+
alignSelf="flex-start"
2929
{...props}
3030
>
3131
{startIcon && (
32-
<Box as="span" mr={spacing}>
32+
<Box as="span" mr={spacing} ml={2}>
3333
{cloneElement(startIcon, { size: iconSize, fill: color })}
3434
</Box>
3535
)}
3636
<Body level={bodyLevel} color={color} lineLimit={lineLimit} wordBreak={lineLimit ? 'break-all' : 'normal'}>
3737
{children}
3838
</Body>
3939
{endIcon && (
40-
<Box as="span" ml={spacing}>
40+
<Box as="span" ml={spacing} mr={2}>
4141
{cloneElement(endIcon, { size: iconSize, fill: color })}
4242
</Box>
4343
)}

packages/vibrant-components/src/lib/FilterChip/FilterChipProps.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { ReactElement, Ref } from 'react';
22
import type { ResponsiveValue, TextChildren } from '@vibrant-ui/core';
33
import { propVariant, withVariation } from '@vibrant-ui/core';
4-
import { isDefined } from '@vibrant-ui/utils';
54
import type { PressableProps } from '../Pressable';
65

76
export type FilterChipProps = {
@@ -32,27 +31,26 @@ export const withFilterChipVariation = withVariation<FilterChipProps>('FilterChi
3231
},
3332
{ name: 'endIcon', keep: true },
3433
],
35-
variants: ({ size, startIcon, endIcon }) => {
34+
variants: ({ size }) => {
3635
if (size === 'sm') {
3736
return {
3837
bodyLevel: 4,
3938
iconSize: 14,
4039
minHeight: 30,
41-
pl: isDefined(startIcon) ? 9 : 11,
42-
pr: isDefined(endIcon) ? 9 : 11,
43-
py: 6,
44-
spacing: 4,
40+
px: 8,
41+
py: 7,
42+
spacing: 3,
43+
rounded: 'lg',
4544
} as const;
4645
}
4746

4847
return {
4948
bodyLevel: 2,
5049
iconSize: 16,
5150
minHeight: 38,
52-
pl: isDefined(startIcon) ? 11 : 15,
53-
pr: isDefined(endIcon) ? 11 : 15,
54-
py: 9,
55-
spacing: 6,
51+
p: 10,
52+
spacing: 4,
53+
rounded: 'xl',
5654
} as const;
5755
},
5856
}),
@@ -68,23 +66,23 @@ export const withFilterChipVariation = withVariation<FilterChipProps>('FilterChi
6866
keep: true,
6967
},
7068
],
71-
variants: ({ selected, disabled }) => {
69+
variants: ({
70+
selected,
71+
disabled,
72+
}: {
73+
selected: FilterChipProps['selected'];
74+
disabled: FilterChipProps['disabled'];
75+
}) => {
7276
if (disabled) {
7377
return {
7478
color: 'onView3',
75-
borderWidth: 1,
76-
borderStyle: 'solid',
77-
borderColor: 'outlineDisable',
78-
backgroundColor: selected ? 'disable' : 'transparent',
79+
backgroundColor: selected ? 'disable' : 'surface1',
7980
} as const;
8081
}
8182

8283
if (selected) {
8384
return {
8485
color: 'onInverseSurface',
85-
borderWidth: 1,
86-
borderStyle: 'solid',
87-
borderColor: 'outlineNeutral',
8886
backgroundColor: 'inverseSurface',
8987
overlayColor: 'onView1',
9088
interactions: ['hover', 'focus', 'active'],
@@ -93,10 +91,7 @@ export const withFilterChipVariation = withVariation<FilterChipProps>('FilterChi
9391

9492
return {
9593
color: 'onView1',
96-
borderWidth: 1,
97-
borderStyle: 'solid',
98-
borderColor: 'outline1',
99-
backgroundColor: 'background',
94+
backgroundColor: 'surface1',
10095
overlayColor: 'onView1',
10196
interactions: ['hover', 'focus', 'active'],
10297
} as const;
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<FilterChip /> when href provided match snapshot 1`] = `
4+
.emotion-0 {
5+
display: -webkit-box;
6+
display: -webkit-flex;
7+
display: -ms-flexbox;
8+
display: flex;
9+
-webkit-align-content: stretch;
10+
-ms-flex-line-pack: stretch;
11+
align-content: stretch;
12+
-webkit-flex-shrink: 0;
13+
-ms-flex-negative: 0;
14+
flex-shrink: 0;
15+
-webkit-flex-direction: row;
16+
-ms-flex-direction: row;
17+
flex-direction: row;
18+
box-sizing: border-box;
19+
position: relative;
20+
overflow: hidden;
21+
cursor: pointer;
22+
-webkit-align-items: center;
23+
-webkit-box-align: center;
24+
-ms-flex-align: center;
25+
align-items: center;
26+
z-index: 0;
27+
-webkit-box-flex: 0;
28+
-webkit-flex-grow: 0;
29+
-ms-flex-positive: 0;
30+
flex-grow: 0;
31+
max-width: 100%;
32+
-webkit-align-self: flex-start;
33+
-ms-flex-item-align: flex-start;
34+
align-self: flex-start;
35+
min-height: 38px;
36+
padding: 10px;
37+
border-radius: 16px;
38+
background-color: #00000008;
39+
}
40+
41+
.emotion-1 {
42+
text-align: left;
43+
color: #0c0c0c;
44+
-webkit-text-fill-color: #0c0c0c;
45+
text-fill-color: #0c0c0c;
46+
word-break: normal;
47+
font-size: 0.875rem;
48+
line-height: 1.125rem;
49+
font-weight: 400;
50+
}
51+
52+
.emotion-2 {
53+
display: -webkit-box;
54+
display: -webkit-flex;
55+
display: -ms-flexbox;
56+
display: flex;
57+
-webkit-align-content: stretch;
58+
-ms-flex-line-pack: stretch;
59+
align-content: stretch;
60+
-webkit-flex-shrink: 1;
61+
-ms-flex-negative: 1;
62+
flex-shrink: 1;
63+
-webkit-flex-direction: column;
64+
-ms-flex-direction: column;
65+
flex-direction: column;
66+
box-sizing: border-box;
67+
position: absolute;
68+
left: 0;
69+
right: 0;
70+
top: 0;
71+
bottom: 0;
72+
background-color: #0c0c0c;
73+
pointer-events: none;
74+
}
75+
76+
<div>
77+
<a
78+
class="emotion-0"
79+
data-testid="pressable"
80+
href="https://www.vibrant-design.com"
81+
style="opacity: 1; transition-property: opacity; transition-duration: 200ms; transition-timing-function: cubic-bezier(0.5, 1, 0.89, 1);"
82+
>
83+
<span
84+
class="emotion-1"
85+
data-testid="body"
86+
>
87+
Click me
88+
</span>
89+
<span
90+
class="emotion-2"
91+
style="opacity: 0; transition-property: opacity; transition-duration: 200ms; transition-timing-function: cubic-bezier(0.5, 1, 0.89, 1);"
92+
/>
93+
</a>
94+
</div>
95+
`;

0 commit comments

Comments
 (0)