UNPKG

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