Skip to content

Commit

Permalink
Fix flexbox props output in both versions
Browse files Browse the repository at this point in the history
  • Loading branch information
thestephenmarshall committed May 11, 2022
1 parent 86c07bb commit fa37772
Show file tree
Hide file tree
Showing 49 changed files with 850 additions and 299 deletions.
1 change: 1 addition & 0 deletions playbook/app/pb_kits/playbook/_playbook.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
@import 'pb_time_stacked/time_stacked';
@import 'pb_walkthrough/walkthrough';
@import 'pb_weekday_stacked/weekday_stacked';
@import './utilities/mixins';
@import './utilities/spacing';
@import './utilities/cursor';
@import './utilities/max_width';
Expand Down
39 changes: 10 additions & 29 deletions playbook/app/pb_kits/playbook/utilities/_align_content.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
.align_content_start {
display: flex;
align-content: start !important;
}

.align_content_end {
display: flex;
align-content: end !important;
}

.align_content_center {
display: flex;
align-content: center !important;
}

.align_content_space_between {
display: flex;
align-content: space-between !important;
}

.align_content_space_around {
display: flex;
align-content: space-around !important;
}

.align_content_space_evenly {
display: flex;
align-content: space-evenly !important;
}
$align_content_values: (
start: start,
end: end,
center: center,
space_between: space-between,
space_around: space-around,
space_evenly: space-evenly
);

@include global_props_responsive_css($align_content_values, 'align_content', 'align-content');
46 changes: 11 additions & 35 deletions playbook/app/pb_kits/playbook/utilities/_align_items.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
.align_items_flex_start {
display: flex;
align-items: flex-start !important;
}

.align_items_flex_end {
display: flex;
align-items: flex-end !important;
}

.align_items_start {
display: flex;
align-items: start !important;
}

.align_items_end {
display: flex;
align-items: end !important;
}


.align_items_center {
display: flex;
align-items: center !important;
}

.align_items_baseline {
display: flex;
align-items: baseline !important;
}

.align_items_stretch {
display: flex;
align-items: stretch !important;
}
$align_items_values: (
flex_start: flex-start,
flex_end: flex-end,
start: start,
center: center,
end: end,
baseline: baseline,
stretch: stretch,
);

@include global_props_responsive_css($align_items_values, 'align_items', 'align-items');
39 changes: 10 additions & 29 deletions playbook/app/pb_kits/playbook/utilities/_align_self.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
.align_self_start {
display: flex;
align-self: start !important;
}

.align_self_end {
display: flex;
align-self: end !important;
}

.align_self_auto {
display: flex;
align-self: auto !important;
}

.align_self_center {
display: flex;
align-self: center !important;
}

.align_self_stretch {
display: flex;
align-self: stretch !important;
}

.align_self_baseline {
display: flex;
align-self: baseline !important;
}
$align_self_values: (
auto: auto,
start: start,
center: center,
end: end,
baseline: baseline,
stretch: stretch,
);

@include global_props_responsive_css($align_self_values, 'align_self', 'align-self');
33 changes: 19 additions & 14 deletions playbook/app/pb_kits/playbook/utilities/_flex.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
.flex_auto {
flex: auto !important;
}
$flex_values: (
auto: auto,
initial: initial,
none: none,
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
10: 10,
11: 11,
12: 12,
);

.flex_initial {
flex: initial !important;
}

.flex_none {
flex: none !important;
}

.flex_1 {
flex: 1 !important;
}
@include global_props_responsive_css($flex_values, 'flex', 'flex');
22 changes: 1 addition & 21 deletions playbook/app/pb_kits/playbook/utilities/_flex_direction.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,4 @@ $flex_direction_values: (
column_reverse: column-reverse
);

@include break_at(breakpoint("lg")) {
.test {
display: none;
}
}

@each $flex-direction, $flex-direction-value in $flex_direction_values {
.flex_direction_#{$flex-direction} {
display: flex;
flex-direction: #{$flex-direction-value} !important;
}
}

@each $flex-direction, $flex-direction-value in $flex_direction_values {
@each $breakpoint, $breakpoint-value in $breakpoints {
.flex_direction_#{$breakpoint}_#{$flex-direction} {
display: flex;
flex-direction: #{$flex-direction-value} !important;
}
}
}
@include global_props_responsive_css($flex_direction_values, 'flex_direction', 'flex-direction');
13 changes: 5 additions & 8 deletions playbook/app/pb_kits/playbook/utilities/_flex_grow.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.flex_grow_1 {
display: flex;
flex-grow: 1 !important;
}
$flex_grow_values: (
0: 0,
1: 1,
);

.flex_grow_0 {
display: flex;
flex-grow: 0 !important;
}
@include global_props_responsive_css($flex_grow_values, 'flex_grow', 'flex-grow');
13 changes: 5 additions & 8 deletions playbook/app/pb_kits/playbook/utilities/_flex_shrink.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.flex_shrink_1 {
display: flex;
flex-shrink: 1 !important;
}
$flex_shrink_values: (
0: 0,
1: 1,
);

.flex_shrink_0 {
display: flex;
flex-shrink: 0 !important;
}
@include global_props_responsive_css($flex_shrink_values, 'flex_shrink', 'flex-shrink');
19 changes: 6 additions & 13 deletions playbook/app/pb_kits/playbook/utilities/_flex_wrap.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
.flex_wrap_wrap {
display: flex;
flex-wrap: wrap !important;
}
$flex_wrap_values: (
wrap: wrap,
nowrap: nowrap,
wrap_reverse: wrap-reverse,
);

.flex_wrap_nowrap {
display: flex;
flex-wrap: nowrap !important;
}

.flex_wrap_wrap_reverse {
display: flex;
flex-wrap: wrap-reverse !important;
}
@include global_props_responsive_css($flex_wrap_values, 'flex_wrap', 'flex-wrap');
33 changes: 10 additions & 23 deletions playbook/app/pb_kits/playbook/utilities/_justify_content.scss
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
.justify_content_start {
justify-content: start !important;
}

.justify_content_end {
justify-content: end !important;
}

.justify_content_center {
justify-content: center !important;
}

.justify_content_space_between {
justify-content: space-between !important;
}

.justify_content_space_around {
justify-content: space-around !important;
}

.justify_content_space_evenly {
justify-content: space-evenly !important;
}
$justify_content_values: (
start: start,
center: center,
end: end,
space_around: space-around,
space_between: space-between,
space_evenly: space-evenly,
);

@include global_props_responsive_css($justify_content_values, 'justify_content', 'justify-content');
28 changes: 9 additions & 19 deletions playbook/app/pb_kits/playbook/utilities/_justify_self.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
.justify_self_auto {
justify-self: auto !important;
}

.justify_self_start {
justify-self: start !important;
}

.justify_self_end {
justify-self: end !important;
}

.justify_self_center {
justify-self: center !important;
}

.justify_self_stretch {
justify-self: stretch !important;
}
$justify_self_values: (
auto: auto,
start: start,
center: center,
end: end,
stretch: stretch,
);

@include global_props_responsive_css($justify_self_values, 'justify_self', 'justify-self');
26 changes: 26 additions & 0 deletions playbook/app/pb_kits/playbook/utilities/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@mixin global_props_css($props, $class_prefix, $css_attribute, $responsive) {
@each $propkey, $propvalue in $props {
.#{$class_prefix}_#{$propkey} {
#{$css_attribute}: #{$propvalue} !important;
@content;
}
}

@if $responsive {
@each $size, $size_value in $breakpoints_grid {
@each $prop_key, $prop_value in $props {
$min_size: map-get($size_value, "min");
$max_size: map-get($size_value, "max");
.#{$class_prefix}_#{$size}_#{$prop_key} {
@include break_on($min_size, $max_size) {
#{$css_attribute}: #{$prop_value} !important;
}
}
}
}
}
}

@mixin global_props_responsive_css($props, $class_prefix, $css_attribute) {
@include global_props_css($props, $class_prefix, $css_attribute, 1)
}
Loading

0 comments on commit fa37772

Please sign in to comment.