Skip to content

Commit 8df2a85

Browse files
authored
Merge pull request #7 from titicacadev/feature/triple-image-carousel
💫 Image에 overlayType 추가
2 parents 5770b3a + baaa010 commit 8df2a85

File tree

1 file changed

+32
-9
lines changed
  • packages/triple-design-system/src/elements

1 file changed

+32
-9
lines changed

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

+32-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +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

7+
type OverlayType = 'gradient' | 'dark'
8+
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+
722
const IMAGE_HEIGHT_OPTIONS: Partial<Record<GlobalSizes, string>> = {
823
mini: '80px',
924
small: '110px',
@@ -52,20 +67,19 @@ const SourceUrl = styled.div`
5267
const ImageOverlay = styled.div<{
5368
borderRadius?: number
5469
overlayPadding?: MarginPadding
70+
overlayType?: OverlayType
5571
}>`
5672
box-sizing: border-box;
5773
position: absolute;
5874
top: 0;
5975
width: 100%;
6076
height: 100%;
61-
background-image: linear-gradient(
62-
to bottom,
63-
rgba(0, 0, 0, 0.6),
64-
rgba(0, 0, 0, 0)
65-
);
77+
6678
border-radius: ${({ borderRadius }) =>
6779
borderRadius === 0 ? 0 : borderRadius || 6}px;
6880
81+
${({ overlayType = 'gradient' }) => OverlayStyle[overlayType]}
82+
6983
${({ overlayPadding }) =>
7084
overlayPadding &&
7185
css`
@@ -91,14 +105,16 @@ const ImageFrameContent = ({
91105
ImageSource,
92106
overlay,
93107
overlayPadding,
108+
overlayType,
94109
withLinkIndicator,
95110
}: {
96111
imageUrl?: string
97112
borderRadius?: number
98113
sourceUrl?: string
99114
ImageSource?: any
100-
overlay?: boolean
115+
overlay?: React.ReactNode
101116
overlayPadding?: MarginPadding
117+
overlayType?: OverlayType
102118
withLinkIndicator?: boolean
103119
}) => (
104120
<>
@@ -115,7 +131,11 @@ const ImageFrameContent = ({
115131
</SourceUrl>
116132
)}
117133
{overlay && (
118-
<ImageOverlay borderRadius={borderRadius} overlayPadding={overlayPadding}>
134+
<ImageOverlay
135+
borderRadius={borderRadius}
136+
overlayPadding={overlayPadding}
137+
overlayType={overlayType}
138+
>
119139
{overlay}
120140
</ImageOverlay>
121141
)}
@@ -208,6 +228,7 @@ function Image({
208228
ImageSource,
209229
overlay,
210230
overlayPadding,
231+
overlayType,
211232
withLinkIndicator,
212233
onClick,
213234
floated,
@@ -223,8 +244,9 @@ function Image({
223244
frame?: GlobalSizes
224245
size?: GlobalSizes
225246
ImageSource?: any
226-
overlay?: boolean
247+
overlay?: React.ReactNode
227248
overlayPadding?: MarginPadding
249+
overlayType?: OverlayType
228250
withLinkIndicator?: boolean
229251
onClick?: (e?: React.SyntheticEvent) => any
230252
floated?: CSS.FloatProperty
@@ -278,6 +300,7 @@ function Image({
278300
ImageSource={ImageSource}
279301
overlay={overlay}
280302
overlayPadding={overlayPadding}
303+
overlayType={overlayType}
281304
withLinkIndicator={withLinkIndicator}
282305
/>
283306
)}

0 commit comments

Comments
 (0)