UNPKG

6.33 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// Modals
10//-----------------------------
11
12@import '../../globals/scss/vars';
13@import '../../globals/scss/helper-mixins';
14@import '../../globals/scss/layout';
15@import '../../globals/scss/layer';
16@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
17@import '../../globals/scss/css--reset';
18@import '../../globals/scss/css--typography';
19@import 'mixins';
20
21@import '../button/button';
22
23@mixin modal {
24 .#{$prefix}--modal {
25 @include reset;
26 @include font-family;
27 position: fixed;
28 top: 0;
29 right: 0;
30 bottom: 0;
31 left: 0;
32 z-index: z('hidden');
33 display: flex;
34 align-items: center;
35 justify-content: center;
36 content: '';
37 opacity: 0;
38 background-color: rgba($ui-03, 0.5);
39 transition: opacity 200ms, z-index 0s 200ms, visibility 0s 200ms;
40 visibility: hidden;
41
42 &.is-visible {
43 z-index: z('modal');
44 opacity: 1;
45 transition: opacity 200ms;
46 visibility: visible;
47 }
48 }
49
50 .#{$prefix}--modal--danger {
51 @include modal--color($support-01);
52 }
53
54 .#{$prefix}--modal-container {
55 @include reset;
56 @include layer('pop-out');
57 position: relative;
58 display: flex;
59 flex-direction: column;
60 background-color: $ui-01;
61 border-top: $modal-border-top;
62 min-width: 100%;
63 max-height: 100%;
64 height: 100%;
65 padding: $spacing-xl 3% 0rem 3%;
66
67 @media (min-width: 600px) {
68 height: auto;
69 min-width: 500px;
70 max-width: 75%;
71 max-height: 90%;
72 padding: $spacing-2xl $spacing-3xl 0 $spacing-3xl;
73 }
74
75 @media (min-width: 1024px) {
76 max-width: 50%;
77 max-height: 80%;
78 }
79 }
80
81 .#{$prefix}--modal-header {
82 margin-bottom: $spacing-lg;
83 }
84
85 .#{$prefix}--modal-header,
86 .#{$prefix}--modal-footer {
87 flex-shrink: 0;
88 }
89
90 .#{$prefix}--modal-header__label {
91 @include reset;
92 @include typescale('omega');
93 @include letter-spacing;
94 color: $text-01;
95 font-weight: 600;
96 text-transform: uppercase;
97 margin-bottom: $spacing-xs;
98 }
99
100 .#{$prefix}--modal-header__heading {
101 @include reset;
102 @include typescale('beta');
103 font-weight: 300;
104 color: $text-02;
105 }
106
107 .#{$prefix}--modal-content {
108 overflow-y: auto;
109 margin-bottom: $spacing-3xl;
110 color: $text-01;
111 font-weight: 400;
112
113 > * {
114 @include reset;
115 }
116 }
117
118 .#{$prefix}--modal-footer {
119 margin-top: auto;
120 display: flex;
121 justify-content: flex-end;
122 background-color: $modal-footer-background-color;
123 margin-left: rem(-24px);
124 margin-right: rem(-24px);
125 padding: $spacing-xl $spacing-xl;
126
127 @media (min-width: 600px) {
128 margin-left: rem(-48px);
129 margin-right: rem(-48px);
130 padding: $spacing-xl $spacing-3xl;
131 }
132 }
133
134 .#{$prefix}--modal-close {
135 position: absolute;
136 top: rem(16px);
137 right: rem(16px);
138 padding: 0;
139 overflow: hidden;
140 cursor: pointer;
141 background-color: transparent;
142 border: none;
143 padding: 0.25rem 0.25rem 0.125rem;
144
145 &:focus {
146 @include focus-outline('border');
147 }
148 }
149
150 .#{$prefix}--modal-close__icon {
151 fill: $ui-05;
152 }
153}
154
155@mixin modal--x {
156 .#{$prefix}--modal {
157 position: fixed;
158 top: 0;
159 right: 0;
160 bottom: 0;
161 left: 0;
162 z-index: z('hidden');
163 display: flex;
164 align-items: center;
165 justify-content: center;
166 content: '';
167 opacity: 0;
168 background-color: $overlay-01;
169 transition: opacity $duration--moderate-01 motion(exit, expressive),
170 z-index 0s $duration--moderate-01 motion(exit, expressive), visibility 0s $duration--moderate-01 motion(exit, expressive);
171 visibility: hidden;
172
173 &.is-visible {
174 z-index: z('modal');
175 opacity: 1;
176 transition: opacity $duration--slow-01 motion(entrance, expressive);
177 visibility: visible;
178 }
179
180 .#{$prefix}--text-input,
181 .#{$prefix}--select-input {
182 background-color: $field-02;
183 }
184 }
185
186 .#{$prefix}--modal--danger {
187 @include modal--color($support-01);
188 }
189
190 .#{$prefix}--modal-container {
191 position: relative;
192 display: flex;
193 flex-direction: column;
194 background-color: $ui-01;
195 width: 100%;
196 max-height: 100%;
197 height: 100%;
198
199 @include carbon--breakpoint(md) {
200 height: auto;
201 width: 50%;
202 max-width: 768px;
203 max-height: 90%;
204 }
205
206 @include carbon--breakpoint(lg) {
207 max-height: 80%;
208 }
209 }
210
211 .#{$prefix}--modal-header,
212 .#{$prefix}--modal-content {
213 width: 75%;
214 padding-left: 1rem;
215 }
216
217 .#{$prefix}--modal-header,
218 .#{$prefix}--modal-footer {
219 flex-shrink: 0;
220 }
221
222 .#{$prefix}--modal-header {
223 padding-top: 1rem;
224 margin-bottom: $carbon--spacing-05;
225 }
226
227 .#{$prefix}--modal-header__label {
228 @include type-style('label-01');
229
230 color: $text-02;
231 margin-bottom: $carbon--spacing-02;
232 }
233
234 .#{$prefix}--modal-header__heading {
235 @include type-style('productive-heading-03');
236
237 color: $text-01;
238 }
239
240 .#{$prefix}--modal-content {
241 @include type-style('body-long-01');
242
243 overflow-y: auto;
244 margin-bottom: $carbon--spacing-09;
245 color: $text-01;
246 font-weight: 400;
247 }
248
249 .#{$prefix}--modal-content > * {
250 @include type-style('body-long-01');
251 }
252
253 .#{$prefix}--modal-footer {
254 display: flex;
255 margin-top: auto;
256 height: 4rem;
257 background-color: $modal-footer-background-color;
258
259 button.#{$prefix}--btn {
260 max-width: none;
261 width: 50%;
262 height: 4rem;
263 margin: 0;
264 padding-top: 1rem;
265 padding-bottom: 2rem;
266 }
267 }
268
269 .#{$prefix}--modal-close {
270 position: absolute;
271 top: 0;
272 right: 0;
273 height: 3rem;
274 width: 3rem;
275 padding: rem(12px);
276 border: 2px solid transparent;
277 overflow: hidden;
278 cursor: pointer;
279 background-color: transparent;
280
281 &:hover {
282 background-color: $hover-ui;
283 }
284
285 &:focus {
286 outline: none;
287 border-color: $interactive-01;
288 }
289 }
290
291 .#{$prefix}--modal-close__icon {
292 fill: $icon-01;
293 height: rem(20px);
294 width: rem(20px);
295 }
296}
297
298@include exports('modal') {
299 @if feature-flag-enabled('components-x') {
300 @include modal--x;
301 } @else {
302 @include modal;
303 }
304}