Skip to content

Commit

Permalink
feat(helpers): introduce padding and margin helpers from Tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj committed Sep 12, 2023
1 parent 4dba335 commit 9f36423
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/styles/isomer-template/helpers.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
These are margin and padding helpers with values that follow the ones
used by Tailwind CSS. This will generate several classes, such as:
- .mr-8 which gives margin-right 2rem
- .mx-16 which gives margin-left and margin-right 4rem
- .py-4 which gives padding-top and padding-bottom 1rem
- .p-20 which gives padding 5rem
*/

$spaceamounts: (
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
14,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60,
64,
72,
80,
96
);
$sides: (top, bottom, left, right);

@each $space in $spaceamounts {
$remSpace: calc(#{$space}rem / 4);

@each $side in $sides {
.m#{str-slice($side, 0, 1)}-#{$space} {
margin-#{$side}: $remSpace;
}

.p#{str-slice($side, 0, 1)}-#{$space} {
padding-#{$side}: $remSpace;
}
}

.mx-#{$space} {
margin-left: $remSpace;
margin-right: $remSpace;
}

.px-#{$space} {
padding-left: $remSpace;
padding-right: $remSpace;
}

.my-#{$space} {
margin-top: $remSpace;
margin-bottom: $remSpace;
}

.py-#{$space} {
padding-top: $remSpace;
padding-bottom: $remSpace;
}

.m-#{$space} {
margin: $remSpace;
}

.p-#{$space} {
padding: $remSpace;
}
}
3 changes: 3 additions & 0 deletions src/styles/isomer-template/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@charset 'UTF-8';

@use "helpers";
1 change: 1 addition & 0 deletions src/styles/preview-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@include meta.load-css("sgds-govtech/css/sgds");
@include meta.load-css("./isomer-template.scss");
@include meta.load-css("./isomer-template/styles.scss");

/*! minireset.css v0.0.2 | MIT License | github.com/jgthms/minireset.css */
blockquote,
Expand Down

0 comments on commit 9f36423

Please sign in to comment.