UNPKG

6.66 kBSCSSView Raw
1//
2// Copyright IBM Corp. 2016, 2018
3//
4// This source code is licensed under the Apache-2.0 license found in the
5// LICENSE file in the root directory of this source tree.
6//
7
8//-----------------------------
9// Tiles
10//-----------------------------
11
12@import '../../globals/scss/vars';
13@import '../../globals/scss/helper-mixins';
14@import '../../globals/scss/layer';
15@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
16@import '../../globals/scss/css--reset';
17@import '../../globals/scss/css--typography';
18
19@mixin tile {
20 .#{$prefix}--tile {
21 @include layer('raised');
22 display: block;
23 min-width: 8rem;
24 min-height: 4rem;
25 background-color: $ui-01;
26 border: 1px solid $ui-03;
27 position: relative;
28 padding: $spacing-md;
29
30 &:focus {
31 @include focus-outline('border');
32 }
33 }
34
35 .#{$prefix}--tile--clickable,
36 .#{$prefix}--tile--selectable,
37 .#{$prefix}--tile--expandable {
38 transition: $transition--base $carbon--standard-easing;
39 cursor: pointer;
40
41 &:hover {
42 border: 1px solid $ui-04;
43 }
44
45 &:hover,
46 &:focus {
47 .#{$prefix}--tile__checkmark {
48 opacity: 1;
49 }
50
51 .#{$prefix}--tile__chevron svg {
52 fill: $brand-01;
53 }
54 }
55 }
56
57 .#{$prefix}--tile--clickable,
58 .#{$prefix}--tile--expandable {
59 &:focus {
60 @include focus-outline('border');
61 }
62 }
63
64 .#{$prefix}--tile--selectable {
65 padding-right: $spacing-3xl;
66 }
67
68 .#{$prefix}--tile--selectable:focus {
69 outline: none;
70 border: 1px solid $brand-01;
71 }
72
73 .#{$prefix}--tile--is-clicked {
74 @include layer('flat');
75 border: 1px solid $ui-04;
76 }
77
78 .#{$prefix}--tile__checkmark,
79 .#{$prefix}--tile__chevron {
80 position: absolute;
81 transition: $transition--base $carbon--standard-easing;
82 border: none;
83 background: transparent;
84
85 &:focus {
86 @include focus-outline;
87 }
88 }
89
90 .#{$prefix}--tile__checkmark {
91 height: 1rem;
92 top: 1rem;
93 right: 1rem;
94 opacity: 0;
95
96 svg {
97 border-radius: 50%;
98 background-color: rgba($ui-01, 0.25);
99 fill: rgba($brand-01, 0.25);
100 }
101 }
102
103 .#{$prefix}--tile__chevron {
104 position: absolute;
105 bottom: 0.5rem;
106 right: 0.5rem;
107 height: 1rem;
108
109 svg {
110 transform-origin: center;
111 transition: $transition--base $carbon--standard-easing;
112 fill: $ui-05;
113 }
114
115 &:hover {
116 cursor: pointer;
117 }
118 }
119
120 .#{$prefix}--tile--expandable {
121 overflow: hidden;
122 cursor: default;
123 transition: $transition--base $carbon--standard-easing;
124 }
125
126 .#{$prefix}--tile-content__above-the-fold {
127 display: block;
128 }
129
130 .#{$prefix}--tile-content__below-the-fold {
131 display: block;
132 opacity: 0;
133 transition: $transition--base $carbon--standard-easing;
134 }
135
136 .#{$prefix}--tile--is-expanded {
137 overflow: visible;
138 transition: $transition--base $carbon--standard-easing;
139
140 .#{$prefix}--tile__chevron svg {
141 transform: rotate(-180deg);
142 }
143
144 .#{$prefix}--tile-content__below-the-fold {
145 opacity: 1;
146 transition: $transition--base $carbon--standard-easing;
147 }
148 }
149
150 .#{$prefix}--tile--is-selected,
151 .#{$prefix}--tile--is-selected:hover,
152 .#{$prefix}--tile--is-selected:focus {
153 border: 1px solid $brand-01;
154 outline: none;
155 }
156
157 .#{$prefix}--tile--is-selected .#{$prefix}--tile__checkmark {
158 opacity: 1;
159
160 svg {
161 fill: $brand-01;
162 }
163 }
164
165 .#{$prefix}--tile-input:checked {
166 & + .#{$prefix}--tile__checkmark {
167 opacity: 1;
168 }
169
170 & + .#{$prefix}--tile__checkmark svg {
171 fill: $brand-01;
172 background-color: $ui-01;
173 }
174 }
175
176 .#{$prefix}--tile-content {
177 width: 100%;
178 height: 100%;
179 }
180
181 .#{$prefix}--tile-input {
182 @include hidden();
183 }
184}
185
186@mixin tile--x {
187 .#{$prefix}--tile {
188 display: block;
189 min-width: 8rem;
190 min-height: 4rem;
191 background-color: $ui-01;
192 position: relative;
193 padding: $carbon--spacing-05;
194 outline: 2px solid transparent;
195 outline-offset: -2px;
196
197 &:focus {
198 @include focus-outline('outline');
199 }
200 }
201
202 .#{$prefix}--tile--clickable,
203 .#{$prefix}--tile--selectable,
204 .#{$prefix}--tile--expandable {
205 transition: $duration--moderate-01 motion(standard, productive);
206 cursor: pointer;
207
208 &:hover {
209 background: $hover-ui;
210 }
211
212 &:hover,
213 &:focus {
214 .#{$prefix}--tile__checkmark {
215 opacity: 1;
216 }
217 }
218 }
219
220 .#{$prefix}--tile--clickable,
221 .#{$prefix}--tile--expandable {
222 &:focus {
223 @include focus-outline('outline');
224 }
225 }
226
227 .#{$prefix}--tile--selectable {
228 padding-right: $carbon--spacing-09;
229 }
230
231 .#{$prefix}--tile__checkmark,
232 .#{$prefix}--tile__chevron {
233 position: absolute;
234 transition: $duration--fast-02 motion(standard, productive);
235 border: none;
236 background: transparent;
237 }
238
239 .#{$prefix}--tile__checkmark {
240 height: 1rem;
241 top: 1rem;
242 right: 1rem;
243 opacity: 0;
244
245 svg {
246 border-radius: 50%;
247 fill: $icon-02;
248 }
249
250 &:focus {
251 @include focus-outline('outline');
252 }
253 }
254
255 .#{$prefix}--tile__chevron {
256 position: absolute;
257 bottom: 0.5rem;
258 right: 0.5rem;
259 height: 1rem;
260
261 svg {
262 transform-origin: center;
263 transition: $duration--fast-02 motion(standard, productive);
264 fill: $ui-05;
265 }
266
267 &:hover {
268 cursor: pointer;
269 }
270
271 &:focus {
272 outline: none;
273 }
274 }
275
276 .#{$prefix}--tile--expandable {
277 overflow: hidden;
278 transition: $duration--moderate-01 motion(standard, productive);
279 }
280
281 .#{$prefix}--tile-content__above-the-fold {
282 display: block;
283 }
284
285 .#{$prefix}--tile-content__below-the-fold {
286 display: block;
287 opacity: 0;
288 transition: $duration--fast-02 motion(standard, productive);
289 }
290
291 .#{$prefix}--tile--is-expanded {
292 overflow: visible;
293 transition: $duration--fast-02 motion(standard, productive);
294
295 .#{$prefix}--tile__chevron svg {
296 transform: rotate(-180deg);
297 }
298
299 .#{$prefix}--tile-content__below-the-fold {
300 opacity: 1;
301 transition: $duration--fast-02 motion(standard, productive);
302 }
303 }
304
305 .#{$prefix}--tile--is-selected {
306 outline: 1px solid $interactive-02;
307 outline-offset: -1px;
308 }
309
310 .#{$prefix}--tile--is-selected .#{$prefix}--tile__checkmark {
311 opacity: 1;
312 }
313
314 .#{$prefix}--tile-input:checked + .#{$prefix}--tile > .#{$prefix}--tile__checkmark svg {
315 fill: $ui-05;
316 }
317
318 .#{$prefix}--tile-content {
319 width: 100%;
320 height: 100%;
321 }
322
323 .#{$prefix}--tile-input {
324 @include hidden;
325 }
326}
327
328@include exports('tile') {
329 @if feature-flag-enabled('components-x') {
330 @include tile--x;
331 } @else {
332 @include tile;
333 }
334}