Skip to content

Split out the container, display, positioning and spacing helpers. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [daveberning]
patreon: daveberning
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.idea
dist/editor.blocks.js
.DS_Store
.vscode
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Feel free to add any modifiers to this to create different styled buttons.
<button class="is-button is-cta is-rounded is-outline">Send Message</button>
```

# Modifers
# Modifiers
These are classes that you can tack on to just about anything to add additional styles. These are typically agnostic to the HTML element it's attached to.

## Spacing Modifiers
Expand Down Expand Up @@ -329,7 +329,7 @@ We've also included helper classes to hide and show elements on touch screen dev
`is-device`: Shows an element on a touch screen device
`is-screen`: Shows an element on a non-touch screen device

## Color Modifers
## Color Modifiers
We've touched on this briefly in other sections. But there are modifier classes for each color type (ex: primary) for text and backgrounds.

`is-text-{type}`: Changes the color of the text per the type's value
Expand Down
2 changes: 1 addition & 1 deletion dist/grid-plus.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/utils/containers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.has-container{max-width:var(--container-width);width:100%;margin:0 auto}
1 change: 1 addition & 0 deletions dist/utils/displaying.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/utils/positioning.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.is-centered{display:flex;align-items:center;justify-content:center}.is-centered-horizontally{display:flex;justify-content:center}.is-centered-vertically{display:flex;align-items:center}
1 change: 1 addition & 0 deletions dist/utils/spacing.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 4 additions & 69 deletions src/scss/includes/utilities.scss
Original file line number Diff line number Diff line change
@@ -1,75 +1,10 @@
@import 'functions';
@import '../variables';

/* Containers
------------------------------ */
.has-container {
max-width: variable('container-width');
width: 100%;
margin: 0 auto;
}

/* Spacing
------------------------------ */
$directions: "-top" "-right" "-bottom" "-left";
$sizes: "" "-md" "-lg";

@mixin generate_spacing($property) {
$propertyFirstLetter: get_first_chars($property, 1);

@each $size in $sizes {
.has-#{$propertyFirstLetter}#{$size} { #{$property}: variable("spacing#{$size}"); }
@each $direction in $directions {
.has-#{$propertyFirstLetter}#{$direction}#{$size} {
#{$property}#{$direction}: variable("spacing#{$size}");
}
}
}

.has-no-#{$propertyFirstLetter} { margin: 0; } // Ex: has-no-p and has-no-m
@each $direction in $directions {
.has-no#{$direction}-#{$propertyFirstLetter} { #{$property}#{$direction}: 0; } // Ex: has-no-top-p and has-no-top-m
}
}

@mixin generate_display_classes {
$display_types: "block" "inline-block" "flex" "inline-flex" "grid" "inline-grid";

@each $type in $display_types {
.is-#{$type} { display: #{$type}; }

@for $i from 1 through length($breakpoints) {
.is-#{$type}-#{nth($breakpoints, $i)} {
@media screen and (min-width: #{nth($breakpoint_values, $i)}) { display: #{$type}; }
}
}
}
}

@include generate_spacing('margin');
@include generate_spacing('padding');

/* Positioning
------------------------------ */
.is-centered {
display: flex;
align-items: center;
justify-content: center;
}

.is-centered-horizontally {
display: flex;
justify-content: center;
}

.is-centered-vertically {
display: flex;
align-items: center;
}

/* Display
------------------------------ */
@include generate_display_classes;
@import 'utilities/containers';
@import 'utilities/spacing';
@import 'utilities/positioning';
@import 'utilities/displaying';

/* Images
------------------------------ */
Expand Down
7 changes: 7 additions & 0 deletions src/scss/includes/utilities/containers.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '../functions';

.has-container {
max-width: variable('container-width');
width: 100%;
margin: 0 auto;
}
17 changes: 17 additions & 0 deletions src/scss/includes/utilities/displaying.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@import '../../variables';

@mixin generate_display_classes {
$display_types: "block" "inline-block" "flex" "inline-flex" "grid" "inline-grid";

@each $type in $display_types {
.is-#{$type} { display: #{$type}; }

@for $i from 1 through length($breakpoints) {
.is-#{$type}-#{nth($breakpoints, $i)} {
@media screen and (min-width: #{nth($breakpoint_values, $i)}) { display: #{$type}; }
}
}
}
}

@include generate_display_classes;
15 changes: 15 additions & 0 deletions src/scss/includes/utilities/positioning.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.is-centered {
display: flex;
align-items: center;
justify-content: center;
}

.is-centered-horizontally {
display: flex;
justify-content: center;
}

.is-centered-vertically {
display: flex;
align-items: center;
}
26 changes: 26 additions & 0 deletions src/scss/includes/utilities/spacing.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@import '../functions';
@import '../../variables';

$directions: "-top" "-right" "-bottom" "-left";
$sizes: "" "-md" "-lg";

@mixin generate_spacing($property) {
$propertyFirstLetter: get_first_chars($property, 1);

@each $size in $sizes {
.has-#{$propertyFirstLetter}#{$size} { #{$property}: variable("spacing#{$size}"); }
@each $direction in $directions {
.has-#{$propertyFirstLetter}#{$direction}#{$size} {
#{$property}#{$direction}: variable("spacing#{$size}");
}
}
}

.has-no-#{$propertyFirstLetter} { margin: 0; } // Ex: has-no-p and has-no-m
@each $direction in $directions {
.has-no#{$direction}-#{$propertyFirstLetter} { #{$property}#{$direction}: 0; } // Ex: has-no-top-p and has-no-top-m
}
}

@include generate_spacing('margin');
@include generate_spacing('padding');
14 changes: 13 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const path = require('path');
module.exports = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: [
'./src/scss/includes/utilities/containers.scss',
'./src/scss/includes/utilities/displaying.scss',
'./src/scss/includes/utilities/positioning.scss',
'./src/scss/includes/utilities/spacing.scss',
'./src/scss/includes/grid.scss',
'./src/scss/includes/grid-plus.scss',
'./src/scss/main.scss'
Expand All @@ -18,7 +22,15 @@ module.exports = {
use: [
{
loader: 'file-loader',
options: { name: '[name].css', }
options: {
name: '[name].css',
outputPath: (url, resourcePath, context) => {
if(/utilities/.test(resourcePath)) {
return `utils/${url}`;
}
return url;
}
}
},
{ loader: 'extract-loader' },
{ loader: 'css-loader?-url' },
Expand Down