Skip to content

Commit

Permalink
fix(styles): fix mixed-decls warning from form footer (#3869)
Browse files Browse the repository at this point in the history
  • Loading branch information
alizedebray authored Nov 1, 2024
1 parent 9297419 commit 5bce3fd
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 108 deletions.
8 changes: 4 additions & 4 deletions packages/styles/src/components/form-footer.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@use '../mixins/utilities' as utility-mx;
@use '../tokens/components';
@use '../functions/tokens' as tokens;
@use '../functions/tokens';

@use '../mixins/layout';

tokens.$default-map: components.$post-form-footer;

.form-footer {
@include utility-mx.responsive-actions();
border-block-start-width: tokens.get('form-footer-border-block-start-width');
border-block-start-color: tokens.get('form-footer-border-start-color');
border-block-start-style: tokens.get('form-footer-border-block-start-style');
padding-block-start: tokens.get('form-footer-padding-block-start');
gap: tokens.get('form-footer-gap');

&-primary-actions {
@include layout.responsive-actions {
gap: tokens.get('form-footer-gap');
}
}
9 changes: 9 additions & 0 deletions packages/styles/src/functions/_breakpoint.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@use 'sass:map';
@use '../variables/breakpoints';

/**
Gets a breakpoint from the map based on the key
*/
@function min-width($key) {
@return map.get(breakpoints.$grid-breakpoints, $key);
}
26 changes: 26 additions & 0 deletions packages/styles/src/mixins/_layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@use './media';

@mixin responsive-actions {
display: flex;
flex-direction: column;
justify-content: space-between;

@include media.min(md) {
flex-direction: row-reverse;

> .btn {
margin-right: auto;
}
}

&-primary-actions {
display: flex;
flex-direction: column;
@content;

@include media.min(md) {
flex-direction: row-reverse;
margin-left: auto;
}
}
}
32 changes: 32 additions & 0 deletions packages/styles/src/mixins/_media.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
@use 'sass:map';
@use 'sass:meta';
@use '../functions/breakpoint';

/**
Creates a min-width breakpoint with the given value
@param $device-size A pixel value or a key for the breakpoints map
*/
@mixin min($device-size) {
@if (meta.type-of($device-size) == 'string') {
$device-size: breakpoint.min-width($device-size);
}

@if $device-size != 0 {
@media screen and (min-width: $device-size) {
@content;
Expand All @@ -8,13 +20,33 @@
}
}

/**
Creates a max-width breakpoint with the given value
@param $device-size A pixel value or a key for the breakpoints map
*/
@mixin max($device-size) {
@if (meta.type-of($device-size) == 'string') {
$device-size: breakpoint.min-width($device-size);
}

@media screen and (max-width: ($device-size - 0.01)) {
@content;
}
}

/**
Creates an in-between breakpoint with the given values
@param $min-size A pixel value or a key for the breakpoints map
@param $max-size A pixel value or a key for the breakpoints map
*/
@mixin between($min-size, $max-size) {
@if (meta.type-of($min-size) == 'string') {
$min-size: breakpoint.min-width($min-size);
}
@if (meta.type-of($max-size) == 'string') {
$max-size: breakpoint.min-width($max-size);
}

@media screen and (min-width: $min-size) and (max-width: ($max-size - 0.01)) {
@content;
}
Expand Down
24 changes: 0 additions & 24 deletions packages/styles/src/mixins/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,3 @@
}
}
}

@mixin responsive-actions {
display: flex;
flex-direction: column;
justify-content: space-between;

@include media-breakpoint-up(md) {
flex-direction: row-reverse;

> .btn {
margin-right: auto;
}
}

&-primary-actions {
display: flex;
flex-direction: column;

@include media-breakpoint-up(md) {
flex-direction: row-reverse;
margin-left: auto;
}
}
}
Loading

0 comments on commit 5bce3fd

Please sign in to comment.