This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
perdido.js
1129 lines (924 loc) · 32.4 KB
/
perdido.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["perdido"] = factory();
else
root["perdido"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Fluid Grid Systems in JSS, Perdido, a translation of Lost.
*
* @copyright Wellington Cordeiro 2015
* @website https://github.com/wldcordeiro/perdido
* @license MIT
*/
'use strict';
exports.__esModule = true;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _perdido = __webpack_require__(1);
var _perdido2 = _interopRequireDefault(_perdido);
exports['default'] = new _perdido2['default']();
module.exports = exports['default'];
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _align2 = __webpack_require__(2);
var _align3 = _interopRequireDefault(_align2);
var _center2 = __webpack_require__(3);
var _center3 = _interopRequireDefault(_center2);
var _column2 = __webpack_require__(4);
var _column3 = _interopRequireDefault(_column2);
var _flexContainer = __webpack_require__(5);
var _flexContainer2 = _interopRequireDefault(_flexContainer);
var _masonry = __webpack_require__(6);
var _move2 = __webpack_require__(7);
var _move3 = _interopRequireDefault(_move2);
var _offset2 = __webpack_require__(8);
var _offset3 = _interopRequireDefault(_offset2);
var _row2 = __webpack_require__(9);
var _row3 = _interopRequireDefault(_row2);
var _utils = __webpack_require__(10);
var utils = _interopRequireWildcard(_utils);
var _waffle2 = __webpack_require__(11);
var _waffle3 = _interopRequireDefault(_waffle2);
var _defaults = __webpack_require__(12);
/**
* Main Perdido class.
*
* @api public
*/
var Perdido = (function () {
function Perdido() {
var gutter = arguments.length <= 0 || arguments[0] === undefined ? _defaults.GUTTER : arguments[0];
var flex = arguments.length <= 1 || arguments[1] === undefined ? _defaults.FLEX : arguments[1];
var cycle = arguments.length <= 2 || arguments[2] === undefined ? _defaults.CYCLE : arguments[2];
var offsetDir = arguments.length <= 3 || arguments[3] === undefined ? _defaults.OFFSET_DIR : arguments[3];
_classCallCheck(this, Perdido);
// Set the default values.
this.gutter = gutter;
this.flex = flex;
this.cycle = cycle;
this.offsetDir = offsetDir;
// Simple properties/methods.
this.flexContainer = _flexContainer2['default'];
this.utils = utils;
}
/**
* Creates a new instance of Perdido.
*
* @see Perdido
* @api public
*/
Perdido.prototype.create = function create() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref$gutter = _ref.gutter;
var gutter = _ref$gutter === undefined ? _defaults.GUTTER : _ref$gutter;
var _ref$flex = _ref.flex;
var flex = _ref$flex === undefined ? _defaults.FLEX : _ref$flex;
var _ref$cycle = _ref.cycle;
var cycle = _ref$cycle === undefined ? _defaults.CYCLE : _ref$cycle;
var _ref$offsetDir = _ref.offsetDir;
var offsetDir = _ref$offsetDir === undefined ? _defaults.OFFSET_DIR : _ref$offsetDir;
return new Perdido(gutter, flex, cycle, offsetDir);
};
/**
* Aligns nested elements.
*
* @see align
* @api public
*/
Perdido.prototype.align = function align(alignment) {
var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref2$flex = _ref2.flex;
var flex = _ref2$flex === undefined ? this.flex : _ref2$flex;
return _align3['default'](alignment, flex);
};
/**
* Centers a containing element.
*
* @see center
* @api public
*/
Perdido.prototype.center = function center(maxWidth) {
var _ref3 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var padding = _ref3.padding;
var _ref3$flex = _ref3.flex;
var flex = _ref3$flex === undefined ? this.flex : _ref3$flex;
return _center3['default'](maxWidth, padding, flex);
};
/**
* Creates a column that is a fraction of its containing element's size.
*
* @see column
* @api public
*/
Perdido.prototype.column = function column(columnVal) {
var _ref4 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref4$cycle = _ref4.cycle;
var cycle = _ref4$cycle === undefined ? this.cycle : _ref4$cycle;
var _ref4$gutter = _ref4.gutter;
var gutter = _ref4$gutter === undefined ? this.gutter : _ref4$gutter;
var _ref4$flex = _ref4.flex;
var flex = _ref4$flex === undefined ? this.flex : _ref4$flex;
return _column3['default'](columnVal, cycle, gutter, flex);
};
/**
* Create a column for working with JS Masonry libraries like Isotope.
*
* @see masonry.masonryColumn
* @api public
*/
Perdido.prototype.masonryColumn = function masonryColumn(columnVal) {
var _ref5 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref5$gutter = _ref5.gutter;
var gutter = _ref5$gutter === undefined ? this.gutter : _ref5$gutter;
var _ref5$flex = _ref5.flex;
var flex = _ref5$flex === undefined ? this.flex : _ref5$flex;
return _masonry.masonryColumn(columnVal, gutter, flex);
};
/**
* Create a wrapping element for working with JS Masonry libraries
* like Isotope.
*
* @see masonry.masonryWrap
* @api public
*/
Perdido.prototype.masonryWrap = function masonryWrap() {
var _ref6 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref6$flex = _ref6.flex;
var flex = _ref6$flex === undefined ? this.flex : _ref6$flex;
var _ref6$gutter = _ref6.gutter;
var gutter = _ref6$gutter === undefined ? this.gutter : _ref6$gutter;
return _masonry.masonryWrap(flex, gutter);
};
/**
* Source ordering. Shift elements left, right, up, or down.
*
* @see move
* @api public
*/
Perdido.prototype.move = function move(moveVal) {
var _ref7 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref7$direction = _ref7.direction;
var direction = _ref7$direction === undefined ? this.offsetDir : _ref7$direction;
var _ref7$gutter = _ref7.gutter;
var gutter = _ref7$gutter === undefined ? this.gutter : _ref7$gutter;
return _move3['default'](moveVal, direction, gutter);
};
/**
* Margin to the left, right, bottom, or top, of an element.
*
* @see offset
* @api public
*/
Perdido.prototype.offset = function offset(offsetVal) {
var _ref8 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref8$direction = _ref8.direction;
var direction = _ref8$direction === undefined ? this.offsetDir : _ref8$direction;
var _ref8$gutter = _ref8.gutter;
var gutter = _ref8$gutter === undefined ? this.gutter : _ref8$gutter;
return _offset3['default'](offsetVal, direction, gutter);
};
/**
* Creates a row that is a fraction of its containing element's size.
*
* @see row
* @api public
*/
Perdido.prototype.row = function row(rowVal) {
var _ref9 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref9$gutter = _ref9.gutter;
var gutter = _ref9$gutter === undefined ? this.gutter : _ref9$gutter;
var _ref9$flex = _ref9.flex;
var flex = _ref9$flex === undefined ? this.flex : _ref9$flex;
return _row3['default'](rowVal, gutter, flex);
};
/**
* Creates a block that is a fraction of the size of its containing element.
*
* @see waffle
* @api public
*/
Perdido.prototype.waffle = function waffle(waffleVal) {
var _ref10 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref10$cycle = _ref10.cycle;
var cycle = _ref10$cycle === undefined ? this.cycle : _ref10$cycle;
var _ref10$gutter = _ref10.gutter;
var gutter = _ref10$gutter === undefined ? this.gutter : _ref10$gutter;
var _ref10$flex = _ref10.flex;
var flex = _ref10$flex === undefined ? this.flex : _ref10$flex;
return _waffle3['default'](waffleVal, cycle, gutter, flex);
};
return Perdido;
})();
exports['default'] = Perdido;
module.exports = exports['default'];
/***/ },
/* 2 */
/***/ function(module, exports) {
/**
* alignProps: Simple helper function that returns the appropriate JSON
* object for the style block.
*
* @param {string} position value for position rule
* @param {string} top value for top rule
* @param {string} right value for right rule
* @param {string} bottom value for bottom rule
* @param {string} left value for left rule
* @param {string} transform value for transform rule
* @return {object} An object containing the valid JSS rules and
* values.
*/
'use strict';
exports.__esModule = true;
exports['default'] = align;
function alignProps(position, top, right, bottom, left, transform) {
return {
position: position,
top: top,
right: right,
bottom: bottom,
left: left,
transform: transform
};
}
/**
* Perdido.align: Align nested elements. Apply this to a parent container.
*
* @param {string} [reset|horizontal|vertical|top-left|top-center|top|
* top-right|middle-left|left|middle-center|center|middle-right|right|
* bottom-left|bottom-center|bottom|bottom-right] - The position the nested
* element takes relative to the containing element.
* @param {boolean} - Determines whether this element should use Flexbox or not.
* @return {object} an object containing the valid JSS rules and values to align
* nested elements.
*/
function align(alignment, flex) {
var style = {};
if (flex === false) {
if (alignment === 'reset') {
style.position = 'static';
style['& > *'] = alignProps('static', 'auto', 'auto', 'auto', 'auto', 'translate(0, 0)');
} else {
style.position = 'relative';
if (alignment === 'horizontal') {
style['& > *'] = alignProps('absolute', 'auto', 'auto', 'auto', '50%', 'translate(-50%, 0)');
} else if (alignment === 'vertical') {
style['& > *'] = alignProps('absolute', '50%', 'auto', 'auto', 'auto', 'translate(0, -50%)');
} else if (alignment === 'top-left') {
style['& > *'] = alignProps('absolute', '0', 'auto', 'auto', '0', 'translate(0, 0)');
} else if (alignment === 'top-center' || alignment === 'top') {
style['& > *'] = alignProps('absolute', '0', 'auto', 'auto', '50%', 'translate(-50%, 0)');
} else if (alignment === 'top-right') {
style['& > *'] = alignProps('absolute', '0', '0', 'auto', 'auto', 'translate(0, 0)');
} else if (alignment === 'middle-left' || alignment === 'left') {
style['& > *'] = alignProps('absolute', '50%', 'auto', 'auto', '0', 'translate(0, -50%)');
} else if (alignment === 'middle-center' || alignment === 'center') {
style['& > *'] = alignProps('absolute', '50%', 'auto', 'auto', '50%', 'translate(-50%, -50%)');
} else if (alignment === 'middle-right' || alignment === 'right') {
style['& > *'] = alignProps('absolute', '50%', '0', 'auto', 'auto', 'translate(0, -50%)');
} else if (alignment === 'bottom-left') {
style['& > *'] = alignProps('absolute', 'auto', 'auto', '0', '0', 'translate(0, 0)');
} else if (alignment === 'bottom-center' || alignment === 'bottom') {
style['& > *'] = alignProps('absolute', 'auto', 'auto', '0', '50%', 'translate(-50%, 0)');
} else if (alignment === 'bottom-right') {
style['& > *'] = alignProps('absolute', 'auto', '0', '0', 'auto', 'translate(0, 0)');
}
}
} else {
if (alignment === 'reset') {
style.display = 'initial';
style['& > *'] = {
justifyContent: 'inherit',
alignItems: 'inherit'
};
} else {
style.display = 'flex';
if (alignment === 'horizontal') {
style['& > *'] = {
justifyContent: 'center',
alignItems: 'inherit'
};
} else if (alignment === 'vertical') {
style['& > *'] = {
justifyContent: 'inherit',
alignItems: 'center'
};
} else if (alignment === 'top-left') {
style['& > *'] = {
justifyContent: 'flex-start',
alignItems: 'flex-start'
};
} else if (alignment === 'top-center' || alignment === 'top') {
style['& > *'] = {
justifyContent: 'center',
alignItems: 'flex-start'
};
} else if (alignment === 'top-right') {
style['& > *'] = {
justifyContent: 'flex-end',
alignItems: 'flex-start'
};
} else if (alignment === 'middle-left' || alignment === 'left') {
style['& > *'] = {
justifyContent: 'flex-start',
alignItems: 'center'
};
} else if (alignment === 'middle-center' || alignment === 'center') {
style['& > *'] = {
justifyContent: 'center',
alignItems: 'center'
};
} else if (alignment === 'middle-right' || alignment === 'right') {
style['& > *'] = {
justifyContent: 'flex-end',
alignItems: 'center'
};
} else if (alignment === 'bottom-left') {
style['& > *'] = {
justifyContent: 'flex-start',
alignItems: 'flex-end'
};
} else if (alignment === 'bottom-center' || alignment === 'bottom') {
style['& > *'] = {
justifyContent: 'center',
alignItems: 'flex-end'
};
} else if (alignment === 'bottom-right') {
style['& > *'] = {
justifyContent: 'flex-end',
alignItems: 'flex-end'
};
}
}
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 3 */
/***/ function(module, exports) {
/**
* Perdido.center: Horizontally center a containing element and apply padding
* to it.
*
* @param {length} maxWidth a max width to assign of any unit type.
* @param {length} padding left and right padding on the element, can be
* any unit.
* @param {boolean} flex determines whether to use flex or not.
* @return {object} an object containing the valid JSS rules and values
* to center containing elements.
*/
'use strict';
exports.__esModule = true;
exports['default'] = center;
function center(maxWidth, padding, flex) {
var style = {
maxWidth: maxWidth,
marginLeft: 'auto',
marginRight: 'auto'
};
if (padding) {
style.paddingLeft = padding;
style.paddingRight = padding;
}
if (flex === false) {
style['&:before'] = {
content: "''",
display: 'table'
};
style['&:after'] = {
content: "''",
display: 'table',
clear: 'both'
};
} else {
style.display = 'flex';
style.flexFlow = 'row wrap';
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 4 */
/***/ function(module, exports) {
/**
* Perdido.column: Creates a column that is a fraction of the size of its
* containing element's width with a gutter.
*
* @param {string} [fraction] - This is a simple fraction of the containing
* element's width.
* @param {integer} [cycle] - Perdido works by assigning a margin-right to all
* elements except the last in the row. If settings.cycle is set to auto
* it will do this by default by using the denominator of the fraction you
* pick. To override the default use this param.,
* e.g.: {'.foo': { extend: Perdido.column('2/4', 2)}}
* @param {length} [gutter] - how many units wide the gutter should be.
* @param {boolean} - Determines whether this element should use Flexbox
* or not.
* @return {object} an object containing the valid JSS rules and values to
* create a column.
*/
'use strict';
exports.__esModule = true;
exports['default'] = column;
function column(columnVal, cycle, gutter, flex) {
var style = {},
cycleVal = cycle;
if (columnVal !== 'none') {
if (cycle === -1) {
cycleVal = parseInt(columnVal.split('/')[1], 10);
} else {
cycleVal = cycle;
}
if (gutter !== '0') {
style.width = 'calc(99.99% * ' + columnVal + ' - (' + gutter + ' - ' + gutter + ' * ' + columnVal + '))';
} else {
style.width = 'calc(99.999999% * ' + columnVal + ')';
}
if (flex === true) {
style.flex = '0 0 auto';
style['&:nth-child(n)'] = {
marginRight: gutter
};
style['&:last-child'] = {
marginRight: '0'
};
style['&:nth-child(' + cycleVal + 'n)'] = {
float: 'right'
};
if (cycle !== 0) {
style['&:nth-child(' + cycleVal + 'n)'].marginRight = '0';
}
} else {
style['&:nth-child(n)'] = {
float: 'left',
marginRight: gutter,
clear: 'none'
};
style['&:last-child'] = {
marginRight: '0'
};
style['&:nth-child(' + cycleVal + 'n)'] = {
float: 'right'
};
if (cycle !== 0) {
style['&:nth-child(' + cycleVal + 'n)'].marginRight = '0';
style['&:nth-child(' + cycleVal + 'n + 1)'] = {
clear: 'left'
};
}
}
} else {
style.width = 'auto';
style['&:last-child'] = {
float: 'none',
clear: 'none',
marginRight: '0',
width: 'auto'
};
style['&:nth-child(n)'] = {
float: 'none',
clear: 'none',
marginRight: '0',
width: 'auto'
};
style['&:nth-child(1n + 1)'] = {
float: 'none',
clear: 'none',
marginRight: '0',
width: 'auto'
};
style['&:nth-child(1n)'] = {
float: 'none',
clear: 'none',
marginRight: '0',
width: 'auto'
};
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 5 */
/***/ function(module, exports) {
/**
* Perdido.flexContainer: Creates a Flexbox container.
*
* @param {string} [row|column] - The flex-direction the container should
* create. This is typically opposite to the element you're creating so a
* row would need `Perdido.flexContainer('column')`.
* @return {object} an object containing the valid JSS rules and values to
* create a flexbox container.
*/
'use strict';
exports.__esModule = true;
exports['default'] = flexContainer;
function flexContainer(direction) {
var style = {
display: 'flex'
};
if (direction === 'column') {
style.flexFlow = 'column nowrap';
} else {
style.flexFlow = 'row wrap';
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 6 */
/***/ function(module, exports) {
/**
* Perdido.masonryColumn: Creates a column for working with JS masonry
* libraries like Isotope. Assigns a margin to
* each side of the element.
*
* @param {string} columnVal fraction of the containing element's size.
* @param {string} gutter how many units wide the gutter should be.
* @param {boolean} flex boolean that determines whether to use flexbox.
* @return {object} an object containing the valid JSS rules and values to
* create a masonry grid column.
*/
'use strict';
exports.__esModule = true;
exports.masonryColumn = masonryColumn;
exports.masonryWrap = masonryWrap;
function masonryColumn(columnVal, gutter, flex) {
var style = {},
unit = gutter.match(/\D/g);
if (unit !== null) {
unit = unit.join('');
}
if (flex === true) {
style.flex = '0 0 auto';
} else {
style.float = 'left';
}
if (gutter !== '0') {
style.width = 'calc(99.99% * ' + columnVal + ' - ' + gutter + ')';
style.marginLeft = '' + parseInt(gutter, 10) / 2 + unit;
style.marginRight = '' + parseInt(gutter, 10) / 2 + unit;
} else {
style.width = 'calc(99.99% * ' + columnVal + ')';
}
return style;
}
/**
* Perdido.masonryWrap: Creates a wrapping element for working with JS Masonry
* libraries like Isotope. Assigns a negative margin on
* each side of this wrapping element.
*
* @param {boolean} flex boolean that determines whether to use flexbox.
* @param {string} gutter how many units wide the gutter should be.
* @return {object} an object containing the valid JSS rules and values to
* create a masonry grid wrapping element.
*/
function masonryWrap(flex, gutter) {
var style = {};
if (flex === false) {
style['&:before'] = {
content: "''",
display: 'table'
};
style['&:after'] = {
content: "''",
display: 'table',
clear: 'both'
};
} else {
style.display = 'flex';
style.flexFlow = 'row wrap';
}
var unit = gutter.match(/\D/g).join('');
style.marginLeft = '' + parseInt(gutter, 10) / -2 + unit;
style.marginRight = '' + parseInt(gutter, 10) / -2 + unit;
return style;
}
/***/ },
/* 7 */
/***/ function(module, exports) {
/**
* Perdido.move: Source ordering. Shift elements left, right, up, or down, by
* their left or top position by passing a positive or negative
* fraction.
* @param {string} moveVal fraction of the container to be shifted.
* @param {string} direction direction the grid should be going. Should
* be opposite of column or row it's being used on.
* @param {string} gutter Adjust the size of the gutter for this movement.
* Should match the element's gutter.
* @return {object} an object containing the valid JSS rules and values to shift
* an element around the grid.
*/
'use strict';
exports.__esModule = true;
exports['default'] = move;
function move(moveVal, direction, gutter) {
var style = {
position: 'relative'
};
if (direction === 'column') {
if (gutter !== '0') {
style.top = ['calc(99.99% * ' + moveVal + ' - (' + gutter + ' - ' + gutter, ' * ' + moveVal + ') + ' + gutter + ')'].join('');
} else {
style.top = 'calc(99.999999% * ' + moveVal + ')';
}
} else {
if (gutter !== '0') {
style.left = ['calc(99.99% * ' + moveVal + ' - (' + gutter + ' - ' + gutter, ' * ' + moveVal + ') + ' + gutter + ')'].join('');
} else {
style.left = 'calc(99.999999% * ' + moveVal + ')';
}
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 8 */
/***/ function(module, exports) {
/**
* Perdido.offset: Margin to the left, right, bottom, or top, of an element
* depending on if the fraction passed is positive or negative. It works for
* both horizontal and vertical grids but not both.
*
* @param {string} offsetVal Fraction of the container to be offset.
* @param {string} direction Direction the grid is going. Should be the
* opposite of the column or row it's being used on.
* Defaults to row.
* @param {string} gutter How large the gutter involved is.
* @return {object} An object containing the valid JSS rules and
* values to offset elements.
*/
'use strict';
exports.__esModule = true;
exports['default'] = offset;
function offset(offsetVal, direction, gutter) {
var style = {},
numerator = parseInt(offsetVal.split('/')[0], 10);
if (direction === 'column') {
if (numerator > 0) {
if (gutter !== '0') {
style.marginBottom = ['calc(99.99% * ' + offsetVal + ' - (' + gutter + ' - ' + gutter + ' * ' + offsetVal + ')', ' + (' + gutter + ' * 2)) !important'].join('');
} else {
style.marginBottom = 'calc(99.999999% * ' + offsetVal + ') !important';
}
} else if (numerator < 0) {
if (gutter !== '0') {
style.marginTop = ['calc(99.99% * (' + offsetVal + ' * -1) - ', '(' + gutter + ' - ' + gutter + ' * (' + offsetVal + ' * -1))', ' + ' + gutter + ') !important'].join('');
} else {
style.marginTop = 'calc(99.999999% * ' + offsetVal + ') !important';
}
} else {
style.marginTop = '0 !important';
style.marginBottom = gutter + ' !important';
}
} else {
if (numerator > 0) {
if (gutter !== '0') {
style.marginRight = ['calc(99.99% * ' + offsetVal + ' - (' + gutter + ' - ' + gutter, ' * ' + offsetVal + ') + (' + gutter + ' * 2)) !important'].join('');
} else {
style.marginRight = 'calc(99.999999% * ' + offsetVal + ') !important';
}
} else if (numerator < 0) {
if (gutter !== '0') {
style.marginLeft = ['calc(99.99% * (' + offsetVal + ' * -1) - ', '(' + gutter + ' - ' + gutter + ' * (' + offsetVal + ' * -1))', ' + ' + gutter + ') !important'].join('');
} else {
style.marginLeft = 'calc(99.999999% * ' + offsetVal + ') !important';
}
} else {
style.marginLeft = '0 !important';
style.marginRight = gutter + ' !important';
}
}
return style;
}
module.exports = exports['default'];
/***/ },
/* 9 */
/***/ function(module, exports) {
/**
* Perdido.row: Creates a row that is a fraction of the size of its containing
* element's height with a gutter.
*
* @param {string} rowVal fraction of the containing element's height.
* @param {string} gutter The bottom margin size of the element.
* @param {boolean} flex Whether to utilize flexbox or not
* @return {object} an object containing the valid JSS rules and values to
* create a row.
*/
'use strict';
exports.__esModule = true;
exports['default'] = row;
function row(rowVal, gutter, flex) {
var style = {
width: '100%'
};
if (flex === true) {
style.flex = '0 0 auto';
}
if (gutter !== '0') {
style.height = 'calc(99.99% * ' + rowVal + ' - (' + gutter + ' - ' + gutter + ' * ' + rowVal + '))';
} else {
style.height = 'calc(99.999999% * ' + rowVal + ')';
}
style.marginBottom = gutter;
style['&:last-child'] = {
marginBottom: '0'
};
return style;
}
module.exports = exports['default'];
/***/ },
/* 10 */
/***/ function(module, exports) {
/**
* Perdido.utils.clearFix: An object containing the styles necessary to apply
* a clear fix to an element.
* @type {Object}
*/
'use strict';
exports.__esModule = true;
var clearFix = {
'*zoom': '1',
'&:before': {
content: "''",
display: 'table'
},
'&:after': {
content: "''",
display: 'table',
clear: 'both'
}
};
exports.clearFix = clearFix;
/**
* Perdido.utils.edit: An object containing the styling to apply an "edit" or
* "debug" view.
* @type {Object}
*/
var edit = {
'& *:not(input):not(textarea):not(select)': {
backgroundColor: 'rgba(0, 0, 255, 0.1)'
}
};
exports.edit = edit;
/***/ },
/* 11 */
/***/ function(module, exports) {
/**
* Perdido.waffle: Creates a block that is a fraction of the size of its
* containing element's width AND height with a gutter on
* the right and bottom.