forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.jss.js
221 lines (202 loc) · 5.14 KB
/
component.jss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import {createUseStyles} from 'react-jss';
const TOP_BAR_HEIGHT = 56;
const DEFAULT_DIMENSION = 24;
const DEFAULT_PADDING = 16;
const TOP_BAR_HEIGHT_LARGE = 80;
const DEFAULT_DIMENSION_LARGE = 40;
const DEFAULT_PADDING_LARGE = 20;
const DEFAULT_GRID_PADDING = 5;
export const PADDING_ALLOWANCE = 40;
const gallery = {
position: 'absolute !important',
left: '0 !important',
right: '0 !important',
top: '0 !important',
height: '100%',
width: '100%',
bottom: '0 !important',
overflow: 'auto !important',
};
const controlsPanel = {
position: 'absolute !important',
height: `${TOP_BAR_HEIGHT}px !important`,
width: '100% !important',
zIndex: '1',
background: 'linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0))',
'@media (min-width:1024px)': {
height: `${TOP_BAR_HEIGHT_LARGE}px !important`,
},
};
const lightbox = {
'&$showControls $control': {
animationTimingFunction: 'ease-in',
animationName: '$fadeIn',
},
'&$hideControls $control': {
animationTimingFunction: 'linear',
animationName: '$fadeOut',
},
};
const grid = {
display: 'grid !important',
justifyContent: 'center !important',
gridGap: `${DEFAULT_GRID_PADDING}px !important`,
gridTemplateColumns: 'repeat(3, 1fr)',
gridAutoRows: 'min-content !important',
padding: `0px ${DEFAULT_GRID_PADDING}px !important`,
top: `${TOP_BAR_HEIGHT}px !important`,
height: `calc(100% - ${TOP_BAR_HEIGHT}px) !important`,
width: 'calc(100% - 10px) !important',
'@media (min-width: 1024px)': {
gridTemplateColumns: `repeat(4, calc(1024px/4 - ${DEFAULT_GRID_PADDING}px * 5 / 4))`,
top: `${TOP_BAR_HEIGHT_LARGE}px !important`,
height: `calc(100% - ${TOP_BAR_HEIGHT_LARGE}px) !important`,
},
};
const thumbnail = {
position: 'relative !important',
paddingTop: '100% !important',
'& > img': {
width: '100% !important',
height: '100% !important',
position: 'absolute !important',
top: '0 !important',
objectFit: 'cover !important',
cursor: 'pointer !important',
},
};
const showControls = {};
const hideControls = {};
const control = {
animationFillMode: 'forwards',
animationDuration: '400ms',
position: 'absolute !important',
boxSizing: 'content-box',
cursor: 'pointer !important',
zIndex: '2',
};
const topControl = {
width: DEFAULT_DIMENSION,
height: DEFAULT_DIMENSION,
padding: DEFAULT_PADDING,
'@media (min-width:1024px)': {
width: DEFAULT_DIMENSION_LARGE,
height: DEFAULT_DIMENSION_LARGE,
padding: DEFAULT_PADDING_LARGE,
},
};
const auto = {};
const clip = {};
const expanded = {};
const caption = {
bottom: 0,
boxSizing: 'border-box !important',
color: '#ffffff',
textShadow: '1px 0 5px rgba(0, 0, 0, 0.4) !important',
maxHeight: 'calc(80px + 3rem) !important',
transition: 'max-height ease-out 0.3s !important',
pointerEvents: 'none !important',
/*
* Make sure we do not overlap with the buttons. This is not applied to
* `captionText` to avoid expanding the hit area when
* collapsed.
*/
paddingTop: `${PADDING_ALLOWANCE}px !important`,
overflow: 'hidden',
'&$auto': {
cursor: 'auto !important',
},
'&$clip': {
/* Fade out the text, using an approximated exponential gradient. */
maskImage: `linear-gradient(
to top,
rgba(0, 0, 0, 0.0) 0rem,
rgba(0, 0, 0, 0.2) 1rem,
rgba(0, 0, 0, 0.55) 2rem,
rgba(0, 0, 0, 1.0) 3rem
)`,
},
'&$expanded': {
overflowY: 'auto !important',
WebkitOverflowScrolling: 'touch !important',
maxHeight: '100% !important',
transition: 'max-height ease-in-out 0.7s !important',
/* Fade out the text, using an approxximated exponential gradient. */
maskImage: `linear-gradient(
to top,
rgba(0, 0, 0, 0.0) 0rem,
rgba(0, 0, 0, 0.2) 0.5rem,
rgba(0, 0, 0, 0.55) 1rem,
rgba(0, 0, 0, 1.0) 2rem
)`,
},
};
const captionText = {
padding: '20px !important',
pointerEvents: 'all !important',
'&:empty': {
display: 'none !important',
},
};
const closeButton = {
top: 0,
right: 0,
};
const prevArrow = {};
const nextArrow = {};
const arrow = {
top: '0 !important',
bottom: '0 !important',
margin: 'auto !important',
filter: 'drop-shadow(0 0 1px black) !important',
width: DEFAULT_DIMENSION_LARGE,
height: DEFAULT_DIMENSION_LARGE,
padding: DEFAULT_PADDING_LARGE,
'&$nextArrow': {
right: '0 !important',
/* Needed for screen reader mode to size correctly. */
left: 'auto !important',
},
'&$prevArrow': {
left: '0 !important',
/* Needed for screen reader mode to size correctly. */
right: 'auto !important',
},
};
const JSS = {
'@keyframes fadeIn': {
from: {opacity: 0},
to: {
opacity: 1,
visibility: 'visible',
},
},
'@keyframes fadeOut': {
from: {opacity: 1},
to: {
opacity: 0,
visibility: 'hidden',
},
},
arrow,
auto,
caption,
captionText,
clip,
closeButton,
control,
controlsPanel,
expanded,
hideControls,
lightbox,
gallery,
grid,
nextArrow,
prevArrow,
showControls,
thumbnail,
topControl,
};
// useStyles gets replaced for AMP builds via `babel-plugin-transform-jss`.
// eslint-disable-next-line local/no-export-side-effect
export const useStyles = createUseStyles(JSS);