UNPKG

7.75 kBSCSSView Raw
1@use "sass:math";
2
3// SASS variables for normal drag handle and bar size.
4// Override in your scss file by setting these variables FIRST, then including this file.
5$drag-handle-width: 10px !default;
6$drag-handle-height: 10px !default;
7$drag-bar-size: 6px !default;
8
9// Query to kick us into "mobile" mode with larger drag handles/bars.
10// See: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer
11$mobile-media-query: '(pointer: coarse)' !default;
12
13// Mobile handle/bar sizes. Override as above.
14$drag-handle-mobile-width: 24px !default;
15$drag-handle-mobile-height: 24px !default;
16
17// Handle color/border.
18$drag-handle-background-colour: rgba(0, 0, 0, 0.2) !default;
19$drag-handle-border: 1px solid rgba(255, 255, 255, 0.7) !default;
20
21$half-drag-handle-height: math.div($drag-handle-height, 2);
22$half-drag-handle-width: math.div($drag-handle-width, 2);
23$half-drag-bar-size: math.div($drag-bar-size, 2);
24
25.ReactCrop {
26 position: relative;
27 display: inline-block;
28 cursor: crosshair;
29 overflow: hidden;
30 max-width: 100%;
31
32 &:focus {
33 outline: none;
34 }
35
36 &--disabled,
37 &--locked {
38 cursor: inherit;
39 }
40
41 &__image {
42 display: block;
43 max-width: 100%;
44 touch-action: none;
45 }
46
47 &__crop-selection {
48 position: absolute;
49 top: 0;
50 left: 0;
51 transform: translate3d(0, 0, 0);
52 box-sizing: border-box;
53 cursor: move;
54 box-shadow: 0 0 0 9999em rgba(0, 0, 0, 0.5);
55 touch-action: none;
56
57 .ReactCrop--disabled & {
58 cursor: inherit;
59 }
60
61 .ReactCrop--circular-crop & {
62 border-radius: 50%;
63 box-shadow: 0px 0px 1px 1px white, 0 0 0 9999em rgba(0, 0, 0, 0.5);
64 }
65
66 border: 1px solid;
67 border-image-source: url('data:image/gif;base64,R0lGODlhCgAKAJECAAAAAP///////wAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlk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x8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEBQoAAgAsAAAAAAoACgAAAhWEERkn7W3ei7KlagMWF/dKgYeyGAUAIfkEBQoAAgAsAAAAAAoACgAAAg+UYwLJ7RnQm7QmsCyVKhUAIfkEBQoAAgAsAAAAAAoACgAAAhCUYgLJHdiinNSAVfOEKoUCACH5BAUKAAIALAAAAAAKAAoAAAIRVISAdusPo3RAzYtjaMIaUQAAIfkEBQoAAgAsAAAAAAoACgAAAg+MDiem7Q8bSLFaG5il6xQAIfkEBQoAAgAsAAAAAAoACgAAAg+UYRLJ7QnQm7SmsCyVKhUAIfkEBQoAAgAsAAAAAAoACgAAAhCUYBLJDdiinNSEVfOEKoECACH5BAUKAAIALAAAAAAKAAoAAAIRFISBdusPo3RBzYsjaMIaUQAAOw==');
68 border-image-slice: 1;
69 border-image-repeat: repeat;
70 }
71 &--invisible-crop &__crop-selection {
72 display: none;
73 }
74
75 &__rule-of-thirds-vt::before,
76 &__rule-of-thirds-vt::after,
77 &__rule-of-thirds-hz::before,
78 &__rule-of-thirds-hz::after {
79 content: '';
80 display: block;
81 position: absolute;
82 background-color: rgba(255, 255, 255, 0.4);
83 }
84
85 &__rule-of-thirds-vt {
86 &::before,
87 &::after {
88 width: 1px;
89 height: 100%;
90 }
91
92 &::before {
93 left: 33.3333%;
94 left: calc(100% / 3);
95 }
96
97 &::after {
98 left: 66.6666%;
99 left: calc(100% / 3 * 2);
100 }
101 }
102
103 &__rule-of-thirds-hz {
104 &::before,
105 &::after {
106 width: 100%;
107 height: 1px;
108 }
109
110 &::before {
111 top: 33.3333%;
112 top: calc(100% / 3);
113 }
114
115 &::after {
116 top: 66.6666%;
117 top: calc(100% / 3 * 2);
118 }
119 }
120
121 &__drag-handle {
122 position: absolute;
123
124 &::after {
125 position: absolute;
126 content: '';
127 display: block;
128 width: $drag-handle-width;
129 height: $drag-handle-height;
130 background-color: $drag-handle-background-colour;
131 border: $drag-handle-border;
132 box-sizing: border-box;
133
134 // This stops the borders disappearing when keyboard
135 // nudging.
136 outline: 1px solid transparent;
137 }
138 }
139
140 .ord-nw {
141 top: 0;
142 left: 0;
143 margin-top: -$half-drag-handle-height;
144 margin-left: -$half-drag-handle-width;
145 cursor: nw-resize;
146
147 &::after {
148 top: 0;
149 left: 0;
150 }
151 }
152 .ord-n {
153 top: 0;
154 left: 50%;
155 margin-top: -$half-drag-handle-height;
156 margin-left: -$half-drag-handle-width;
157 cursor: n-resize;
158
159 &::after {
160 top: 0;
161 }
162 }
163 .ord-ne {
164 top: 0;
165 right: 0;
166 margin-top: -$half-drag-handle-height;
167 margin-right: -$half-drag-handle-width;
168 cursor: ne-resize;
169
170 &::after {
171 top: 0;
172 right: 0;
173 }
174 }
175 .ord-e {
176 top: 50%;
177 right: 0;
178 margin-top: -$half-drag-handle-height;
179 margin-right: -$half-drag-handle-width;
180 cursor: e-resize;
181
182 &::after {
183 right: 0;
184 }
185 }
186 .ord-se {
187 bottom: 0;
188 right: 0;
189 margin-bottom: -$half-drag-handle-height;
190 margin-right: -$half-drag-handle-width;
191 cursor: se-resize;
192
193 &::after {
194 bottom: 0;
195 right: 0;
196 }
197 }
198 .ord-s {
199 bottom: 0;
200 left: 50%;
201 margin-bottom: -$half-drag-handle-height;
202 margin-left: -$half-drag-handle-width;
203 cursor: s-resize;
204
205 &::after {
206 bottom: 0;
207 }
208 }
209 .ord-sw {
210 bottom: 0;
211 left: 0;
212 margin-bottom: -$half-drag-handle-height;
213 margin-left: -$half-drag-handle-width;
214 cursor: sw-resize;
215
216 &::after {
217 bottom: 0;
218 left: 0;
219 }
220 }
221 .ord-w {
222 top: 50%;
223 left: 0;
224 margin-top: -$half-drag-handle-height;
225 margin-left: -$half-drag-handle-width;
226 cursor: w-resize;
227
228 &::after {
229 left: 0;
230 }
231 }
232
233 // Use the same specificity as the ords above but just
234 // come after.
235 &__disabled &__drag-handle {
236 cursor: inherit;
237 }
238
239 &__drag-bar {
240 position: absolute;
241
242 &.ord-n {
243 top: 0;
244 left: 0;
245 width: 100%;
246 height: $drag-bar-size;
247 margin-top: -$half-drag-bar-size;
248 }
249 &.ord-e {
250 right: 0;
251 top: 0;
252 width: $drag-bar-size;
253 height: 100%;
254 margin-right: -$half-drag-bar-size;
255 }
256 &.ord-s {
257 bottom: 0;
258 left: 0;
259 width: 100%;
260 height: $drag-bar-size;
261 margin-bottom: -$half-drag-bar-size;
262 }
263 &.ord-w {
264 top: 0;
265 left: 0;
266 width: $drag-bar-size;
267 height: 100%;
268 margin-left: -$half-drag-bar-size;
269 }
270 }
271
272 &--new-crop &__drag-bar,
273 &--new-crop &__drag-handle,
274 &--fixed-aspect &__drag-bar {
275 display: none;
276 }
277
278 &--fixed-aspect &__drag-handle.ord-n,
279 &--fixed-aspect &__drag-handle.ord-e,
280 &--fixed-aspect &__drag-handle.ord-s,
281 &--fixed-aspect &__drag-handle.ord-w {
282 display: none;
283 }
284
285 @media #{$mobile-media-query} {
286 .ord-n,
287 .ord-e,
288 .ord-s,
289 .ord-w {
290 display: none;
291 }
292
293 &__drag-handle {
294 width: $drag-handle-mobile-width;
295 height: $drag-handle-mobile-height;
296 }
297 }
298}