Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
v9.1.0 - Adding spacing utility classes. (#391)
Browse files Browse the repository at this point in the history
* v9.1.0 - Adding spacing utility classes.

* v9.1.0 - Additional utility classes.

* v9.1.0 - Removed class.

* v9.1.0 - Enforce trump styles.

* v9.1.0 - Update module docs.
  • Loading branch information
DamianMullins authored Aug 22, 2022
1 parent cea5fac commit 9d682c2
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Future Todo List
- Update to use latest v2 PIE design tokens


v9.1.0
------------------------------
*August 19, 2022*

### Added
- Utilities mixin module containing a new `spacing-map` variable and `spacing-classes` mixin which can be used to generate utility classes for each spacing variable.
- Optional spacing trump module which generates margin & padding utility classes.
- `u-noBorder`, `u-noBackground`, and `u-hover--cursor` utility classes.


v9.0.2
------------------------------
*August 11, 2022*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@justeat/fozzie",
"title": "Fozzie – Just Eat UI Web Framework",
"description": "UI Web Framework for the Just Eat Global Platform",
"version": "9.0.2",
"version": "9.1.0",
"main": "dist/js/index.js",
"files": [
"dist/js",
Expand Down
1 change: 1 addition & 0 deletions src/scss/_dependencies.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
* These should always come last as they should 'trump' other properties
*/
@forward 'trumps/utilities';
@forward 'trumps/spacing';
@forward 'trumps/rwd';

/**
Expand Down
1 change: 1 addition & 0 deletions src/scss/tools/mixins/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
@forward 'alerts';
@forward 'ratings';
@forward 'border';
@forward 'utilities';
51 changes: 51 additions & 0 deletions src/scss/tools/mixins/_utilities.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@use '../../settings/variables' as v;
@use 'sass:map';

// ==========================================================================
// Utilities Mixins
// ==========================================================================

/**
* Extends default $spacing map with an empty entry at the start
*/
$spacing-map: map.merge((
'': 0
), v.$spacing);

//
// ==========================================================================
// Spacing classes mixin
//
// Generates spacing utility classes
// ==========================================================================
//
// Usage:
// @include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'top') using ($spacingValue) {
// padding-top: spacing(#{$spacingValue});
// }
//
// eg. the output of the above would generate the following
//
// .u-pad--top { padding-top: spacing(); }
// .u-pad-a--top { padding-top: spacing(a); }
// .u-pad-b--top { padding-top: spacing(b); }
// .u-pad-c--top { padding-top: spacing(c); }
// .u-pad-d--top { padding-top: spacing(d); }
// .u-pad-e--top { padding-top: spacing(e); }
// .u-pad-f--top { padding-top: spacing(f); }
// .u-pad-g--top { padding-top: spacing(g); }
// .u-pad-h--top { padding-top: spacing(h); }
// .u-pad-i--top { padding-top: spacing(i); }
// .u-pad-j--top { padding-top: spacing(j); }
//
@mixin spacing-classes($spacings, $name, $modifier: '') {
@each $spacing-value, $value in $spacings {
$separator: if($spacing-value == '', '', '-');
$modifier-str: if($modifier == '', '', '--#{$modifier}');
$suffix: #{$separator}#{$spacing-value}#{$modifier-str};

.u-#{$name}#{$suffix} {
@content($spacing-value);
}
}
}
98 changes: 98 additions & 0 deletions src/scss/trumps/_spacing.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@use '../tools/mixins/utilities';


@mixin trumps-spacing() {
/**
* Spacing Trumps
* ===================================
*
* These can be helpful in situations where you need to apply some spacing and do not wish to create a new class name for an element.
* The classes generated include spacing for each of our spacing variables in all directions (left.right, top, bottom), including horizontal & vertical, for both padding & margin.
*
* The format of the generated classes is `.u-{name}--{modifier}`, modifier is an optional parameter.
*
* eg. a subset of the generated classes
*
* .u-spacing { margin: spacing(); }
* .u-spacing--top { margin-top: spacing(); }
* .u-spacing-a--top { margin-top: spacing(a); }
* .u-spacing-b--top { margin-top: spacing(b); }
*
* .u-pad { padding: spacing(); }
* .u-pad--top { padding-top: spacing(); }
* .u-pad-a--top { padding-top: spacing(a); }
* .u-pad-b--top { padding-top: spacing(b); }
*
* This is an optional component within Fozzie.
* If you'd like to use it in your project you can include it by adding `@include trumps-spacing();` into your SCSS dependencies file.
*/

//
// Margin Utilities
// ==========================================================================

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing') using ($spacingValue) {
margin: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'top') using ($spacingValue) {
margin-top: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'bottom') using ($spacingValue) {
margin-bottom: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'left') using ($spacingValue) {
margin-left: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'right') using ($spacingValue) {
margin-right: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'horizontal') using ($spacingValue) {
margin-left: spacing(#{$spacingValue}) !important;
margin-right: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'spacing', 'vertical') using ($spacingValue) {
margin-bottom: spacing(#{$spacingValue}) !important;
margin-top: spacing(#{$spacingValue}) !important;
}


//
// Padding Utilities
// ==========================================================================

@include utilities.spacing-classes(utilities.$spacing-map, 'pad') using ($spacingValue) {
padding: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'top') using ($spacingValue) {
padding-top: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'bottom') using ($spacingValue) {
padding-bottom: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'left') using ($spacingValue) {
padding-left: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'right') using ($spacingValue) {
padding-right: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'horizontal') using ($spacingValue) {
padding-left: spacing(#{$spacingValue}) !important;
padding-right: spacing(#{$spacingValue}) !important;
}

@include utilities.spacing-classes(utilities.$spacing-map, 'pad', 'vertical') using ($spacingValue) {
padding-bottom: spacing(#{$spacingValue}) !important;
padding-top: spacing(#{$spacingValue}) !important;
}
}
18 changes: 18 additions & 0 deletions src/scss/trumps/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
background-color: dt.$color-white;
}

//
// Border Utilities
// ==========================================================================

.u-noBorder {
border: none !important;
}

.u-bordered {
@extend %u-bordered;
}
Expand Down Expand Up @@ -444,4 +452,14 @@
}
}
}

.u-noBackground {
background: none !important;
}

.u-hover--cursor {
&:hover {
cursor: pointer !important;
}
}
}

0 comments on commit 9d682c2

Please sign in to comment.