UNPKG

4.52 kBSCSSView Raw
1@use '../internal' as *;
2
3$generate-utility: should-generate-classes($MODAL);
4
5@if $generate-utility {
6 /* The base of the modal dialog, which is an overlay of the webpage */
7 .modal {
8 position: fixed; /* Scrolls with the user */
9 top: 0;
10 left: 0;
11 right: 0;
12 bottom: 0;
13 opacity: 0; /* Initially hidden */
14 padding: 1rem;
15 display: none; /* Doesn't block the elements underneath */
16 align-items: center;
17 justify-content: center; /* Vertical centering */
18 pointer-events: none; /* Prevent any pointer events made to modal while hidden */
19
20 /* When the modal dialog is visible */
21 &:target,
22 &.modal--visible {
23 display: flex;
24 opacity: 1;
25 z-index: 999;
26 pointer-events: auto; /* Re-enable pointer events */
27
28 /* The div in the modal dialpog used to create the translucent background */
29 .modal-overlay {
30 position: absolute; /* Absolute inside of the modal container */
31 top: 0;
32 left: 0;
33 right: 0;
34 bottom: 0;
35 display: block;
36 background-color: transparentize($color: $cirrus-dark, $amount: 0.5);
37 }
38
39 .modal-container,
40 .modal-container {
41 animation: slide-down var(--animation-duration) ease 1;
42 z-index: 1;
43 }
44
45 // Animation modifiers
46 &.modal-animated--zoom-in,
47 &.modal-animated--zoom-out {
48 opacity: 1;
49 transition: 300ms all ease;
50 }
51
52 &.modal-animated--zoom-in .modal-content,
53 &.modal-animated--zoom-out .modal-content {
54 transform: scale(1);
55 transition: 300ms all ease;
56 }
57 }
58
59 /* Different size modals */
60 &.modal-small .modal-content {
61 max-width: 20rem; /* 320px */
62 }
63
64 &.modal-large .modal-content {
65 max-width: 60rem; /* 960px */
66 }
67
68 /* The modal dialog body with the text itself */
69 .modal-content {
70 background-color: var(--cirrus-bg);
71 padding: 0;
72 display: block;
73 border-radius: 3px;
74 box-shadow: 0 0.4rem 1rem transparentize($color: $cirrus-dark, $amount: 0.7);
75 z-index: 1;
76 color: var(--cirrus-fg);
77 max-width: 40rem; /* 640px */
78
79 /* Restrict width */
80 &.small {
81 max-width: 32rem;
82 }
83
84 #{$header-selectors} {
85 color: var(--cirrus-fg);
86 }
87
88 .modal-header {
89 padding: 1rem 2.5rem;
90 }
91
92 .modal-header .modal-title {
93 font-weight: bolder;
94 font-size: 1.4rem;
95 }
96
97 .modal-body {
98 padding: 1rem 2.5rem;
99 overflow-y: auto;
100 max-height: 50vh; /* Max height is 50% of viewport height which prevents dialog from extetnding past screen */
101 position: relative;
102 }
103
104 .modal-footer {
105 padding: 1rem 2.5rem;
106 }
107
108 @include screen-below($sm) {
109 max-width: 90%;
110 }
111 }
112
113 /* MODAL ANIMATIONS */
114 &.modal-animated--dropdown {
115 animation: slide-down var(--animation-duration) ease 1;
116 }
117
118 /* Visible state */
119 &.modal-animated--zoom-in,
120 &.modal-animated--zoom-out {
121 display: flex;
122 opacity: 0;
123 transition: 300ms all ease;
124 }
125
126 &.modal-animated--zoom-in .modal-content {
127 transform: scale(0.8);
128 transition: 300ms all ease;
129 }
130
131 &.modal-animated--zoom-out .modal-content {
132 transform: scale(1.2);
133 transition: 300ms all ease;
134 }
135 }
136
137 /* Keyframes for slide down animation */
138 @keyframes slide-down {
139 0% {
140 opacity: 0;
141 transform: translateY(-3rem);
142 }
143 100% {
144 opacity: 1;
145 transform: translateY(0);
146 }
147 }
148
149 @include screen-below($sm) {
150 .modal-content {
151 max-width: 90%;
152 }
153 }
154}