Skip to content

Commit 79eae4a

Browse files
authored
v0.1.6
2 parents fed0a40 + 2da74a8 commit 79eae4a

25 files changed

+316
-33
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@channel.io/design-system",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Design System by Channel",
55
"repository": {
66
"type": "git",

src/components/Icon/Icon.stories.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { withKnobs, select, color, number } from '@storybook/addon-knobs'
44
import styled from 'styled-components'
55

66
/* Internal dependencies */
7-
import Pallette from '../../styling/Palette'
7+
import { Text } from '../Text'
8+
import { ThemeProvider, LightTheme } from '../../styling/Theme'
9+
import Palette from '../../styling/Palette'
810
import icons, { IconName } from './generated'
911
import Icon from './Icon'
1012

@@ -38,10 +40,10 @@ const Name = styled.p`
3840

3941
export const AllIcons = () => {
4042
const size = select('size', IconSize, IconSize.Normal)
41-
const selectedColor = color('color', Pallette.grey700)
43+
const selectedColor = color('color', Palette.grey700)
4244

4345
return (
44-
<>
46+
<ThemeProvider theme={LightTheme}>
4547
{ iconList.map((iconName) => (
4648
<IconInfo key={iconName}>
4749
<Icon
@@ -52,14 +54,14 @@ export const AllIcons = () => {
5254
<Name>{ iconName }</Name>
5355
</IconInfo>
5456
)) }
55-
</>
57+
</ThemeProvider>
5658
)
5759
}
5860

5961
export const Primary = () => (
6062
<Icon
6163
name={select('name', iconList, 'zoyi') as IconName}
62-
color={color('color', Pallette.grey700)}
64+
color={color('color', Palette.grey700)}
6365
size={select('size', IconSize, IconSize.Normal)}
6466
marginTop={number('marginTop', 0)}
6567
marginRight={number('marginRight', 0)}
@@ -69,16 +71,19 @@ export const Primary = () => (
6971
)
7072

7173
export const WithText = () => (
72-
<h1>
74+
<Text
75+
style={{
76+
color: color('color', Palette.grey700),
77+
}}
78+
>
7379
<Icon
7480
name={select('name', iconList, 'zoyi') as IconName}
75-
color={color('color', Pallette.grey700)}
7681
size={select('size', IconSize, IconSize.Normal)}
7782
marginTop={number('marginTop', 0)}
7883
marginRight={number('marginRight', 0)}
7984
marginBottom={number('marginBottom', 0)}
8085
marginLeft={number('marginLeft', 0)}
8186
/>
8287
Hello World!
83-
</h1>
88+
</Text>
8489
)

src/components/Icon/Icon.styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function getMargin({
1414
}
1515

1616
const Icon = styled.svg<IconStyledProps>`
17-
fill: ${props => props.color || props.theme?.colors?.iconBase};
17+
color: ${props => props.color || 'inherit'};
1818
margin: ${getMargin};
1919
`
2020

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
3+
function SvgCloseWin(props: React.SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
6+
<path
7+
fill="#A7A7AA"
8+
fillRule="evenodd"
9+
d="M16.5 6.793l.707.707-4.5 4.5 4.5 4.5-.707.707-4.5-4.5-4.5 4.5-.707-.707 4.5-4.5-4.5-4.5.707-.707 4.5 4.5 4.5-4.5z"
10+
/>
11+
</svg>
12+
)
13+
}
14+
15+
export default SvgCloseWin
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
3+
function SvgEnlargeWin(props: React.SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
6+
<path
7+
fill="#A7A7AA"
8+
fillRule="evenodd"
9+
d="M17 7v10H7V7h10zm-1 1H8v8h8V8z"
10+
/>
11+
</svg>
12+
)
13+
}
14+
15+
export default SvgEnlargeWin
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
3+
function SvgMinimizeWin(props: React.SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
6+
<path fill="#A7A7AA" fillRule="evenodd" d="M7 12h10v1H7z" />
7+
</svg>
8+
)
9+
}
10+
11+
export default SvgMinimizeWin
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
3+
function SvgMoreWin(props: React.SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
6+
<path
7+
d="M6 12h2v2H6zm10 0h2v2h-2zm-5 0h2v2h-2z"
8+
fill="#A7A7AA"
9+
fillRule="evenodd"
10+
/>
11+
</svg>
12+
)
13+
}
14+
15+
export default SvgMoreWin

src/components/Icon/generated/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import ChevronUpDouble from './ChevronUpDouble'
9090
import ChevronUp from './ChevronUp'
9191
import Clip from './Clip'
9292
import Clock from './Clock'
93+
import CloseWin from './CloseWin'
9394
import CloudDownload from './CloudDownload'
9495
import CloudUpload from './CloudUpload'
9596
import Code from './Code'
@@ -109,6 +110,7 @@ import Edit from './Edit'
109110
import EmailUnread from './EmailUnread'
110111
import EmailUnsubscribed from './EmailUnsubscribed'
111112
import Email from './Email'
113+
import EnlargeWin from './EnlargeWin'
112114
import ErrorFilled from './ErrorFilled'
113115
import ErrorTriangleFilled from './ErrorTriangleFilled'
114116
import Error from './Error'
@@ -189,11 +191,13 @@ import MarkerPen from './MarkerPen'
189191
import Me from './Me'
190192
import Megaphone from './Megaphone'
191193
import Menu from './Menu'
194+
import MinimizeWin from './MinimizeWin'
192195
import MinusCircleFilled from './MinusCircleFilled'
193196
import MinusCircle from './MinusCircle'
194197
import Mobile from './Mobile'
195198
import MoonFilled from './MoonFilled'
196199
import MoreVertical from './MoreVertical'
200+
import MoreWin from './MoreWin'
197201
import More from './More'
198202
import Mouse from './Mouse'
199203
import Music from './Music'
@@ -412,6 +416,7 @@ const icons = {
412416
'chevron-up': ChevronUp,
413417
'clip': Clip,
414418
'clock': Clock,
419+
'close-win': CloseWin,
415420
'cloud-download': CloudDownload,
416421
'cloud-upload': CloudUpload,
417422
'code': Code,
@@ -431,6 +436,7 @@ const icons = {
431436
'email-unread': EmailUnread,
432437
'email-unsubscribed': EmailUnsubscribed,
433438
'email': Email,
439+
'enlarge-win': EnlargeWin,
434440
'error-filled': ErrorFilled,
435441
'error-triangle-filled': ErrorTriangleFilled,
436442
'error': Error,
@@ -511,11 +517,13 @@ const icons = {
511517
'me': Me,
512518
'megaphone': Megaphone,
513519
'menu': Menu,
520+
'minimize-win': MinimizeWin,
514521
'minus-circle-filled': MinusCircleFilled,
515522
'minus-circle': MinusCircle,
516523
'mobile': Mobile,
517524
'moon-filled': MoonFilled,
518525
'more-vertical': MoreVertical,
526+
'more-win': MoreWin,
519527
'more': More,
520528
'mouse': Mouse,
521529
'music': Music,

src/components/Text/Text.stories.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,31 @@ export default {
1212
decorators: [withKnobs],
1313
}
1414

15-
export const Primary = () => (<Text content={text('content', 'hello')} />)
15+
export const Primary = () => (<Text>{ text('content', 'hello') }</Text>)
1616

1717
export const WithStyle = () => (
1818
<Text
19-
content={text('content', 'hello')}
2019
style={object('style', { color: 'green' })}
21-
/>
20+
>
21+
Text
22+
</Text>
2223
)
2324

2425
export const AlternativeTag = () => (
2526
<Text
26-
content={text('content', 'bye')}
2727
as={select('as', ['h1', 'h2', 'button'], 'button') as React.ElementType}
28-
/>
28+
>
29+
{ text('content', 'bye') }
30+
</Text>
2931
)
3032

3133
export const WithTheme = () => (
3234
<ThemeProvider theme={DarkTheme}>
33-
<Text content={text('content', 'hiiii')} />
35+
<div style={{ backgroundColor: 'black' }}>
36+
<Text>
37+
{ text('content', 'hiiii') }
38+
</Text>
39+
</div>
3440
</ThemeProvider>
3541
)
3642

@@ -46,7 +52,9 @@ export const WithCustomTheme = () => {
4652

4753
return (
4854
<ThemeProvider theme={customTheme}>
49-
<Text content={text('content', 'hello, world')} />
55+
<Text>
56+
{ text('content', 'hello, world') }
57+
</Text>
5058
</ThemeProvider>
5159
)
5260
}

src/components/Text/Text.test.tsx

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,62 @@ import React from 'react'
33
import { render } from '@testing-library/react'
44

55
/* Internal dependencies */
6-
import Text from './Text'
6+
import Typography from '../../styling/Typography'
7+
import Text, { TEXT_TEST_ID } from './Text'
78
import TextProps from './Text.types'
89

9-
describe('Text 컴포넌트 테스트 >', () => {
10+
describe('Text test >', () => {
1011
let props: TextProps
1112

1213
beforeEach(() => {
1314
props = {
14-
content: 'hello, world',
15+
children: 'hello, world',
1516
}
1617
})
1718

18-
const renderComponent = () => render(<Text {...props} />)
19+
const renderComponent = (optionProps?: TextProps) => render(<Text {...props} {...optionProps}/>)
1920

20-
it('props 가 제공되지 않을 경우 기본 style 을 가지고 있다', () => {
21+
it('Text have default style', () => {
2122
const { getByTestId } = renderComponent()
2223

23-
const testComponent = getByTestId('text')
24+
const renderedText = getByTestId(TEXT_TEST_ID)
2425

25-
expect(testComponent).toHaveStyle('font-size: 15px')
26+
expect(renderedText).toHaveStyle('font-size: 15px;')
27+
expect(renderedText).toHaveStyle('font-weight: normal;')
28+
expect(renderedText).toHaveStyle('font-style: normal;')
29+
expect(renderedText).toHaveStyle('color: black;')
30+
})
31+
32+
it('Text recieves bold style', () => {
33+
const { getByTestId } = renderComponent({ bold: true })
34+
35+
const renderedText = getByTestId(TEXT_TEST_ID)
36+
37+
expect(renderedText).toHaveStyle('font-weight: bold;')
38+
})
39+
40+
it('Text recieves bold style', () => {
41+
const { getByTestId } = renderComponent({ italic: true })
42+
43+
const renderedText = getByTestId(TEXT_TEST_ID)
44+
45+
expect(renderedText).toHaveStyle('font-style: italic;')
46+
})
47+
48+
it('Text recieves style object', () => {
49+
const { getByTestId } = renderComponent({ style: { color: 'skyblue' } })
50+
51+
const renderedText = getByTestId(TEXT_TEST_ID)
52+
53+
expect(renderedText).toHaveStyle('color: skyblue;')
54+
})
55+
56+
it('Text recieves typo from styled component css', () => {
57+
const { getByTestId } = renderComponent({ typo: Typography.Size24 })
58+
59+
const renderedText = getByTestId(TEXT_TEST_ID)
60+
61+
expect(renderedText).toHaveStyle('font-size: 24px;')
62+
expect(renderedText).toHaveStyle('line-height: 32px;')
2663
})
2764
})

src/components/Text/Text.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import Typography from '../../styling/Typography'
66
import TextProps from './Text.types'
77
import TextView from './Text.styled'
88

9+
export const TEXT_TEST_ID = 'ch-design-system-text'
10+
911
function Text({
1012
as,
11-
testId = 'text',
12-
content,
13+
testId = TEXT_TEST_ID,
1314
bold = false,
1415
italic = false,
1516
typo = Typography.Size15,
1617
style,
1718
className,
19+
children,
1820
}: TextProps) {
1921
return (
2022
<TextView
@@ -26,7 +28,7 @@ function Text({
2628
typo={typo}
2729
data-testid={testId}
2830
>
29-
{ content }
31+
{ children }
3032
</TextView>
3133
)
3234
}

src/components/Text/Text.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { css } from 'styled-components'
33

44
/* Internal dependencies */
5-
import { ContentComponentProps } from '../../types/ComponentProps'
5+
import { ChildrenComponentProps } from '../../types/ComponentProps'
66

7-
export default interface TextProps extends ContentComponentProps<string> {
7+
export default interface TextProps extends ChildrenComponentProps {
88
bold?: boolean
99
italic?: boolean
1010
typo?: ReturnType<typeof css>

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ export * from './components/Text'
77
/* Layout */
88
export * from './layout/GNB'
99
export * from './layout/Navigation'
10+
export * from './layout/GlobalHeader'
1011

1112
/* Styling */
1213
export { default as Typography } from './styling/Typography'
1314
export * from './styling/Colors'
1415
export * from './styling/Theme'
16+
export { default as Palette } from './styling/Palette'

0 commit comments

Comments
 (0)