Skip to content

Commit baaa010

Browse files
committed
🔨css 내 조건 절 처리 리팩토링
1 parent 3e81258 commit baaa010

File tree

1 file changed

+16
-18
lines changed
  • packages/triple-design-system/src/elements

1 file changed

+16
-18
lines changed

packages/triple-design-system/src/elements/image.tsx

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import * as React from 'react'
2-
import styled, { css } from 'styled-components'
2+
import styled, { css, InterpolationValue } from 'styled-components'
33
import Icon from './icon'
44
import { MarginPadding, GlobalSizes } from '../commons'
55
import * as CSS from 'csstype'
66

77
type OverlayType = 'gradient' | 'dark'
88

9+
const OverlayStyle: { [key in OverlayType]: InterpolationValue[] } = {
10+
gradient: css`
11+
background-color: rgba(0, 0, 0, 0.8);
12+
`,
13+
dark: css`
14+
background-image: linear-gradient(
15+
to bottom,
16+
rgba(0, 0, 0, 0.6),
17+
rgba(0, 0, 0, 0)
18+
);
19+
`,
20+
}
21+
922
const IMAGE_HEIGHT_OPTIONS: Partial<Record<GlobalSizes, string>> = {
1023
mini: '80px',
1124
small: '110px',
@@ -65,6 +78,8 @@ const ImageOverlay = styled.div<{
6578
border-radius: ${({ borderRadius }) =>
6679
borderRadius === 0 ? 0 : borderRadius || 6}px;
6780
81+
${({ overlayType = 'gradient' }) => OverlayStyle[overlayType]}
82+
6883
${({ overlayPadding }) =>
6984
overlayPadding &&
7085
css`
@@ -73,23 +88,6 @@ const ImageOverlay = styled.div<{
7388
padding-left: ${overlayPadding.left || 0}px;
7489
padding-right: ${overlayPadding.right || 0}px;
7590
`};
76-
77-
${({ overlayType = 'gradient' }) =>
78-
overlayType === 'gradient' &&
79-
css`
80-
background-image: linear-gradient(
81-
to bottom,
82-
rgba(0, 0, 0, 0.6),
83-
rgba(0, 0, 0, 0)
84-
);
85-
`};
86-
87-
${({ overlayType }) =>
88-
overlayType &&
89-
overlayType === 'dark' &&
90-
css`
91-
background-color: rgba(0, 0, 0, 0.8);
92-
`};
9391
`
9492

9593
const IconContainer = styled.div`

0 commit comments

Comments
 (0)