Skip to content

Commit ac4853c

Browse files
optimized helpers
1 parent ce308ea commit ac4853c

File tree

3 files changed

+189
-132
lines changed

3 files changed

+189
-132
lines changed

src/Utilities/helpers.scss

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,71 @@ PUNICA CSS > UTILITIES : HELPERS *********************/
1616

1717
/*****************************************************
1818
Font Sizes *******************************************/
19-
@include setHelperList($font-sizes, "!important");
19+
@include setHelperList($font-sizes, "font-size", "!important");
2020

2121
/*****************************************************
2222
Text Colors ******************************************/
23-
@include setHelperList($text-colors, "!important");
23+
@include setHelperList($text-colors, "color", "!important");
2424

2525
/*****************************************************
2626
Background Colors ************************************/
27-
@include setHelperList($bg-colors, "!important");
27+
@include setHelperList($bg-colors, "background-color", "!important");
2828
@include customBackgrounds();
2929

3030
/*****************************************************
3131
Cursors **********************************************/
32-
@include setHelperList($cursors, "!important");
32+
@include setHelperList($cursors, "cursor", "!important");
3333

3434
/*****************************************************
3535
Display Properties ***********************************/
36-
@include setHelperList($display-properties, "!important");
37-
@include setHelperList($align-items);
38-
@include setHelperList($align-self);
36+
@include setHelperList($display-properties, "display", "!important");
3937

4038
/*****************************************************
4139
Alignment ********************************************/
42-
@include setHelperList($align-items);
43-
@include setHelperList($align-self);
44-
@include setHelperList($justify-content);
40+
@include setHelperList($align-items, "align-items");
41+
@include setHelperList($align-self, "align-self");
42+
@include setHelperList($justify-content, "justify-content");
4543

4644
/*****************************************************
4745
Filters **********************************************/
48-
@include setHelperList($display-filters);
46+
@include setHelperList($display-filters, "filter");
4947

5048
/*****************************************************
5149
Text Transform Properties ****************************/
52-
@include setHelperList($text-transforms);
50+
@include setHelperList($text-transforms, "text-transform");
5351

5452
/*****************************************************
5553
Overflow Properties **********************************/
5654
@include setHelperList($overflow-properties);
5755

5856
/*****************************************************
5957
Position Properties **********************************/
60-
@include setHelperList($position-properties);
58+
@include setHelperList($position-properties, "position");
6159

6260
/*****************************************************
6361
Stack Order ******************************************/
6462
@include setHelperListWithRange($z-indexes, $helper-z-indexes, null, "!important");
6563

6664
/*****************************************************
6765
Direction of the flexible items **********************/
68-
@include setHelperList($flex-directions);
66+
@include setHelperList($flex-directions, "flex-direction");
6967

7068
/*****************************************************
7169
User Select Properties *******************************/
72-
@include setHelperList($user-selects);
70+
@include setHelperList($user-selects, "user-select");
71+
72+
/*****************************************************
73+
Insets *******************************/
74+
@include setNestedHelperList($insets);
7375

7476
/*****************************************************
7577
Line Height Properties *******************************/
7678
@include setHelperListWithRange($line-heights, $helper-lh-ranges, null, "!important");
7779

80+
/*****************************************************
81+
Border Radius ****************************************/
82+
@include setHelperListWithRange($border-radius, $helper-br-ranges, "px", "!important");
83+
7884
/*****************************************************
7985
Others ***********************************************/
8086
@include otherHelpers();

src/Utilities/mixins.scss

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,67 @@
11
/*****************************************************
22
PUNICA CSS > UTILITIES : HELPERS > MIXINS ************/
33

4+
/**
5+
*
6+
*/
47
@mixin setHelperListWithRange(
5-
$helpers,
6-
$range,
7-
$value-type: null,
8-
$specificity: null
8+
$helpers, $range, $value-type: null, $specificity: null
99
) {
1010
@each $class, $property in $helpers {
1111
@each $value in $range {
1212
.#{$class}#{$value} {
13-
#{$property}: #{$value}#{$value-type} #{$specificity};
13+
@include setProperties($property, $value, $value-type, $specificity);
1414
}
1515
}
1616
}
1717
}
18+
19+
/**
20+
*
21+
*/
1822
@mixin setHelperList(
19-
$list,
20-
$specificity: null
23+
$list, $property-name: null, $specificity: null
2124
) {
22-
@each $class, $property, $value in $list {
23-
.#{$class} {
24-
#{$property}: #{$value} #{$specificity};
25+
@if $property-name {
26+
@each $class, $value in $list {
27+
.#{$class} {
28+
@include setProperties($property-name, $value, null, $specificity);
29+
}
30+
}
31+
} @else {
32+
@each $class, $property, $value in $list {
33+
.#{$class} {
34+
@include setProperties($property, $value, null, $specificity);
35+
}
36+
}
37+
}
38+
}
39+
40+
/**
41+
*
42+
*/
43+
@mixin setNestedHelperList($list) {
44+
@each $class-name, $values in $list {
45+
@each $value in $values {
46+
.#{$class-name}-#{$value} {
47+
@include setProperties($class-name, $value);
48+
}
2549
}
2650
}
2751
}
52+
53+
/**
54+
*
55+
*/
56+
@mixin setProperties(
57+
$property, $value, $value-type: null, $specificity: null
58+
) {
59+
#{$property}: #{$value}#{$value-type} #{$specificity};
60+
}
61+
62+
/**
63+
*
64+
*/
2865
@mixin customBackgrounds() {
2966
.bg-grid {
3067
height: 100%;
@@ -40,6 +77,10 @@ PUNICA CSS > UTILITIES : HELPERS > MIXINS ************/
4077
background-size: 100% 8px;
4178
}
4279
}
80+
81+
/**
82+
*
83+
*/
4384
@mixin otherHelpers() {
4485
.centered {margin: 0 auto;}
4586
.align.right {text-align: right !important;}

0 commit comments

Comments
 (0)