Skip to content

Commit 2a27889

Browse files
committed
refactor(key-value-list-item): key-value-list-item의 height 28px이 고정되는 스타일을 개선
1 parent ca79679 commit 2a27889

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

packages/bezier-react/src/components/KeyValueListItem/KeyValueListItem.common.styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface KeyValueListItemContainerProps {
1616
export const KeyValueListItemContainer = styled.div<KeyValueListItemContainerProps>`
1717
box-sizing: border-box;
1818
display: flex;
19-
align-items: center;
19+
align-items: flex-start;
2020
padding: 4px 6px;
2121
2222
${({ foundation }) => foundation?.rounding?.round6};

packages/bezier-react/src/components/KeyValueListItem/KeyValueListItem.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Meta, Story } from '@storybook/react'
66

77
/* Internal dependencies */
88
import { getTitle } from 'Utils/storyUtils'
9+
import { Button, ButtonColorVariant, ButtonStyleVariant } from 'Components/Button'
910
import KeyValueListItem from './KeyValueListItem'
1011
import KeyValueMultiLineListItem from './KeyValueMultiLineListItem'
1112
import { KeyValueListItemProps } from './KeyValueListItem.types'
@@ -47,6 +48,14 @@ const SingleLineTemplate: Story<KeyValueListItemStorybookProps> = ({ containerWi
4748
actions={Array.from(Array(2)).map(() => ({ icon: 'edit', onClick: console.log, tooltip: '수정하기' }))}
4849
/>
4950
<KeyValueListItem {...otherProps} onClickKey={onClickKey} onClickValue={onClickValue} />
51+
<KeyValueListItem {...otherProps}>
52+
<Button
53+
leftContent="play"
54+
text="높이 테스트"
55+
colorVariant={ButtonColorVariant.Green}
56+
styleVariant={ButtonStyleVariant.Primary}
57+
/>
58+
</KeyValueListItem>
5059
</div>
5160
)
5261

packages/bezier-react/src/components/KeyValueListItem/KeyValueListItem.styled.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ import { KeyValueListItemWrapper, KeyValueListItemContainer } from './KeyValueLi
44

55
export const Wrapper = styled(KeyValueListItemWrapper)`
66
display: flex;
7-
align-items: center;
7+
align-items: flex-start;
88
`
99

1010
export const KeyItemContainer = styled(KeyValueListItemContainer)`
1111
flex: 1;
12-
height: 28px;
1312
${ellipsis()};
1413
`
1514

1615
export const ValueItemContainer = styled(KeyValueListItemContainer)`
1716
flex: 2;
1817
justify-content: space-between;
19-
height: 28px;
18+
min-height: 28px;
2019
${ellipsis()};
2120
`

packages/bezier-react/src/components/KeyValueListItem/KeyValueListItem.test.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('KeyValueListItem', () => {
181181

182182
await user.hover(keyItemContainer as Element)
183183
expect(keyItemContainer).toHaveStyle('display: flex;')
184-
expect(keyItemContainer).toHaveStyle('align-items: center;')
184+
expect(keyItemContainer).toHaveStyle('align-items: flex-start;')
185185
expect(keyItemContainer).toHaveStyle('padding: 4px 6px;')
186186
expect(keyItemContainer).not.toHaveStyle('cursor: pointer;')
187187
// NOTE(@sol): Hovered DOM style test is not working
@@ -200,7 +200,7 @@ describe('KeyValueListItem', () => {
200200

201201
await user.hover(keyItemContainer as Element)
202202
expect(keyItemContainer).toHaveStyle('display: flex;')
203-
expect(keyItemContainer).toHaveStyle('align-items: center;')
203+
expect(keyItemContainer).toHaveStyle('align-items: flex-start;')
204204
expect(keyItemContainer).toHaveStyle('padding: 4px 6px;')
205205
expect(keyItemContainer).toHaveStyle('cursor: pointer;')
206206
// NOTE(@sol): Hovered DOM style test is not working
@@ -234,7 +234,7 @@ describe('KeyValueListItem', () => {
234234

235235
await user.hover(valueItemContainer as Element)
236236
expect(valueItemContainer).toHaveStyle('display: flex;')
237-
expect(valueItemContainer).toHaveStyle('align-items: center;')
237+
expect(valueItemContainer).toHaveStyle('align-items: flex-start;')
238238
expect(valueItemContainer).toHaveStyle('padding: 4px 6px;')
239239
expect(valueItemContainer).not.toHaveStyle('cursor: pointer;')
240240
// NOTE(@sol): Hovered DOM style test is not working
@@ -253,7 +253,7 @@ describe('KeyValueListItem', () => {
253253

254254
await user.hover(valueItemContainer as Element)
255255
expect(valueItemContainer).toHaveStyle('display: flex;')
256-
expect(valueItemContainer).toHaveStyle('align-items: center;')
256+
expect(valueItemContainer).toHaveStyle('align-items: flex-start;')
257257
expect(valueItemContainer).toHaveStyle('padding: 4px 6px;')
258258
expect(valueItemContainer).toHaveStyle('cursor: pointer;')
259259
// NOTE(@sol): Hovered DOM style test is not working
@@ -284,7 +284,7 @@ describe('KeyValueListItem', () => {
284284
const { getByTestId } = renderComponent()
285285
const rendered = getByTestId(TEST_ID_MAP.ROOT)
286286
expect(rendered).toHaveStyle('display: flex;')
287-
expect(rendered).toHaveStyle('align-items: center;')
287+
expect(rendered).toHaveStyle('align-items: flex-start;')
288288
expect(rendered).toHaveStyle('border-radius: 6px;')
289289
expect(rendered).toHaveStyle('transition-delay: 0ms;')
290290
expect(rendered).toHaveStyle('transition-timing-function: cubic-bezier(.3,0,0,1);')
@@ -294,13 +294,11 @@ describe('KeyValueListItem', () => {
294294
const rootKeyContainer = rendered.firstChild
295295
expect(rootKeyContainer).toHaveStyle('display: flex;')
296296
expect(rootKeyContainer).toHaveStyle('flex: 1;')
297-
expect(rootKeyContainer).toHaveStyle('height: 28px;')
298297

299298
const rootValueContainer = rendered.lastChild
300299
expect(rootValueContainer).toHaveStyle('display: flex;')
301300
expect(rootValueContainer).toHaveStyle('flex: 2;')
302301
expect(rootValueContainer).toHaveStyle('justify-content: space-between;')
303-
expect(rootValueContainer).toHaveStyle('height: 28px;')
304302
expect(rootValueContainer).toHaveStyle('overflow: hidden;')
305303
expect(rootValueContainer).toHaveStyle('text-overflow: ellipsis;')
306304
expect(rootValueContainer).toHaveStyle('white-space: nowrap;')

packages/bezier-react/src/components/KeyValueListItem/__snapshots__/KeyValueListItem.test.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ exports[`KeyValueListItem Snapshot > 1`] = `
5656
}
5757
5858
.c9 {
59+
color: #00000066;
5960
font-size: 1.4rem;
6061
line-height: 1.8rem;
6162
overflow: hidden;
@@ -82,10 +83,10 @@ exports[`KeyValueListItem Snapshot > 1`] = `
8283
display: -webkit-flex;
8384
display: -ms-flexbox;
8485
display: flex;
85-
-webkit-align-items: center;
86-
-webkit-box-align: center;
87-
-ms-flex-align: center;
88-
align-items: center;
86+
-webkit-align-items: flex-start;
87+
-webkit-box-align: flex-start;
88+
-ms-flex-align: flex-start;
89+
align-items: flex-start;
8990
padding: 4px 6px;
9091
overflow: hidden;
9192
border-radius: 6px;
@@ -96,17 +97,16 @@ exports[`KeyValueListItem Snapshot > 1`] = `
9697
display: -webkit-flex;
9798
display: -ms-flexbox;
9899
display: flex;
99-
-webkit-align-items: center;
100-
-webkit-box-align: center;
101-
-ms-flex-align: center;
102-
align-items: center;
100+
-webkit-align-items: flex-start;
101+
-webkit-box-align: flex-start;
102+
-ms-flex-align: flex-start;
103+
align-items: flex-start;
103104
}
104105
105106
.c3 {
106107
-webkit-flex: 1;
107108
-ms-flex: 1;
108109
flex: 1;
109-
height: 28px;
110110
overflow: hidden;
111111
text-overflow: ellipsis;
112112
white-space: nowrap;
@@ -120,7 +120,7 @@ exports[`KeyValueListItem Snapshot > 1`] = `
120120
-webkit-justify-content: space-between;
121121
-ms-flex-pack: justify;
122122
justify-content: space-between;
123-
height: 28px;
123+
min-height: 28px;
124124
overflow: hidden;
125125
text-overflow: ellipsis;
126126
white-space: nowrap;

0 commit comments

Comments
 (0)