1
1
import * as React from 'react'
2
- import styled , { css } from 'styled-components'
2
+ import styled , { css , InterpolationValue } from 'styled-components'
3
3
import Icon from './icon'
4
4
import { MarginPadding , GlobalSizes } from '../commons'
5
5
import * as CSS from 'csstype'
6
6
7
7
type OverlayType = 'gradient' | 'dark'
8
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
+
9
22
const IMAGE_HEIGHT_OPTIONS : Partial < Record < GlobalSizes , string > > = {
10
23
mini : '80px' ,
11
24
small : '110px' ,
@@ -65,6 +78,8 @@ const ImageOverlay = styled.div<{
65
78
border-radius: ${ ( { borderRadius } ) =>
66
79
borderRadius === 0 ? 0 : borderRadius || 6 } px;
67
80
81
+ ${ ( { overlayType = 'gradient' } ) => OverlayStyle [ overlayType ] }
82
+
68
83
${ ( { overlayPadding } ) =>
69
84
overlayPadding &&
70
85
css `
@@ -73,23 +88,6 @@ const ImageOverlay = styled.div<{
73
88
padding-left : ${ overlayPadding . left || 0 } px;
74
89
padding-right : ${ overlayPadding . right || 0 } px;
75
90
` } ;
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
- ` } ;
93
91
`
94
92
95
93
const IconContainer = styled . div `
0 commit comments