Skip to content

Commit

Permalink
Remove sass deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmanuel committed May 14, 2023
1 parent c21d5c0 commit d9478a4
Show file tree
Hide file tree
Showing 7 changed files with 939 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/dummy/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ $inuit-global-text-color: $black-80;
$inuit-global-background-color: $white;

// TOOLS
@import "inuitcss/tools/tools.font-size";
@import "tools/font-size";
@import "inuitcss/tools/tools.clearfix";
@import "inuitcss/tools/tools.hidden";
@import "sass-mq/mq";
@import "tools/mq";

// GENERIC
@import "inuitcss/generic/generic.box-sizing";
Expand All @@ -21,7 +21,6 @@ $inuit-global-background-color: $white;
@import "inuitcss/generic/generic.shared";

// ELEMENTS
@import "inuitcss/elements/elements.page";
@import "elements/elements.page";
@import "inuitcss/elements/elements.images";
@import "inuitcss/elements/elements.headings";
Expand All @@ -30,22 +29,21 @@ $inuit-global-background-color: $white;
// OBJECTS
@import "inuitcss/objects/objects.block";
@import "inuitcss/objects/objects.box";
@import "inuitcss/objects/objects.crop";
@import "inuitcss/objects/objects.flag";
@import "inuitcss/objects/objects.layout";
@import "inuitcss/objects/objects.list-bare";
@import "inuitcss/objects/objects.list-inline";
@import "inuitcss/objects/objects.media";
@import "inuitcss/objects/objects.pack";
@import "inuitcss/objects/objects.ratio";
@import "inuitcss/objects/objects.table";
@import "inuitcss/objects/objects.wrapper";
@import "objects/crop";
@import "objects/ratio";

// UTILITIES
@import "inuitcss/utilities/utilities.clearfix";
@import "inuitcss/utilities/utilities.headings";
@import "inuitcss/utilities/utilities.hide";
@import "inuitcss/utilities/utilities.print";
@import "inuitcss/utilities/utilities.spacings";
@import "inuitcss/utilities/utilities.widths";

@import "utilities/widths";
25 changes: 25 additions & 0 deletions tests/dummy/app/styles/elements/elements.page.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/* ==========================================================================
#PAGE
========================================================================== */

@use "sass:math";

/**
* Simple page-level setup.
*
* 1. Set the default `font-size` and `line-height` for the entire project,
* sourced from our default variables. The `font-size` is calculated to exist
* in ems, the `line-height` is calculated to exist unitlessly.
* 2. Force scrollbars to always be visible to prevent awkward ‘jumps’ when
* navigating between pages that do/do not have enough content to produce
* scrollbars naturally.
* 3. Ensure the page always fills at least the entire height of the viewport.
*/

html {
font-size: math.div($inuit-global-font-size, 16px) * 1em; /* [1] */
line-height: math.div($inuit-global-line-height, $inuit-global-font-size); /* [1] */
overflow-y: scroll; /* [2] */
min-height: 100%; /* [3] */
}

body {
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

Expand Down
167 changes: 167 additions & 0 deletions tests/dummy/app/styles/objects/crop.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/* ==========================================================================
#CROP
========================================================================== */

// A list of cropping ratios that get generated as modifier classes.
// You should predefine it with only the ratios and names your project needs.
//
// The map keys are the strings used in the generated class names, and they can
// follow any convention, as long as they are properly escaped strings. i.e.:
//
// $inuit-crops: (
// "2\\:1" : (2:1),
// "4-by-3" : (4:3),
// "full-hd" : (16:9),
// "card-image" : (2:3),
// "golden-ratio" : (1.618:1) -> non-integers are okay
// ) !default;

@use "sass:math";

$inuit-crops: (
"2\\:1" : (2:1),
"4\\:3" : (4:3),
"16\\:9" : (16:9)
) !default;



/**
* Provide a cropping container in order to display media (usually images)
* cropped to certain ratios.
*
* 1. Set up a positioning context in which the image can sit.
* 2. This is the crucial part: where the cropping happens.
*/

.o-crop {
position: relative; /* [1] */
display: block;
overflow: hidden; /* [2] */
}

/**
* Apply this class to the content (usually `img`) that needs cropping.
*
* 1. Image’s default positioning is top-left in the cropping box.
* 2. Make sure the media doesn’t stop itself too soon.
*/

.o-crop__content {
position: absolute;
top: 0; /* [1] */
left: 0; /* [1] */
max-width: none; /* [2] */
}



/**
* We can position the media in different locations within the cropping area.
*/

.o-crop__content--left-top {
left: 0;
}

.o-crop__content--left-center {
top: 50%;
transform: translateY(-50%);
}

.o-crop__content--left-bottom {
top: auto;
bottom: 0;
}

.o-crop__content--right-top {
right: 0;
left: auto;
}

.o-crop__content--right-center {
top: 50%;
right: 0;
left: auto;
transform: translateY(-50%);
}

.o-crop__content--right-bottom {
top: auto;
right: 0;
bottom: 0;
left: auto;
}

.o-crop__content--center-top {
left: 50%;
transform: translateX(-50%);
}

.o-crop__content--center,
.o-crop__content--center-center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.o-crop__content--center-bottom {
top: auto;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}





/* Crop-ratio variants
========================================================================== */

/**
* Generate a series of crop classes to be used like so:
*
* <div class="o-crop o-crop--golden-ratio">
*
*/

@each $crop-name, $crop-value in $inuit-crops {

@each $antecedent, $consequent in $crop-value {

@if (type-of($antecedent) != number) {
@error "`#{$antecedent}` needs to be a number.";
}

@if (type-of($consequent) != number) {
@error "`#{$consequent}` needs to be a number.";
}

.o-crop--#{$crop-name} {
padding-bottom: math.div($consequent, $antecedent) * 100%;
}

}

}





/* Fill modifier
========================================================================== */

/**
* Content stretches to fill it's container while maintaining aspect-ratio.
*/

.o-crop--fill {

> .o-crop__content {
min-height: 100%;
min-width: 100%;
}

}
120 changes: 120 additions & 0 deletions tests/dummy/app/styles/objects/ratio.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* ==========================================================================
#RATIO
========================================================================== */

// A list of aspect ratios that get generated as modifier classes.
// You should predefine it with only the ratios and names your project needs.
//
// The map keys are the strings used in the generated class names, and they can
// follow any convention, as long as they are properly escaped strings. i.e.:
//
// $inuit-ratios: (
// "2\\:1" : (2:1),
// "4-by-3" : (4:3),
// "full-hd" : (16:9),
// "card-image" : (2:3),
// "golden-ratio" : (1.618:1) -> non-integers are okay
// ) !default;

@use "sass:math";

$inuit-ratios: (
"2\\:1" : (2:1),
"4\\:3" : (4:3),
"16\\:9" : (16:9)
) !default;



/**
* Create ratio-bound content blocks, to keep media (e.g. images, videos) in
* their correct aspect ratios.
*
* http://alistapart.com/article/creating-intrinsic-ratios-for-video
*
* 1. Default is a 1:1 ratio (i.e. a perfect square).
*/

.o-ratio {
position: relative;
display: block;

&:before {
content: "";
display: block;
width: 100%;
padding-bottom: 100%; /* [1] */
}

}

.o-ratio__content,
.o-ratio > iframe,
.o-ratio > embed,
.o-ratio > object {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
}





/* Ratio variants.
========================================================================== */

/**
* Generate a series of ratio classes to be used like so:
*
* <div class="o-ratio o-ratio--golden-ratio">
*
*/

@each $ratio-name, $ratio-value in $inuit-ratios {

@each $antecedent, $consequent in $ratio-value {

@if (type-of($antecedent) != number) {
@error "`#{$antecedent}` needs to be a number.";
}

@if (type-of($consequent) != number) {
@error "`#{$consequent}` needs to be a number.";
}

.o-ratio--#{$ratio-name}:before {
padding-bottom: math.div($consequent, $antecedent) * 100%;
}

}

}





/* Contain modifier.
========================================================================== */

/**
* Only works with image content.
* Contains the image to the boundaries, without cropping or stretching it.
*/

.o-ratio--img-contain {

> .o-ratio__content {
height: auto;
margin: auto;
max-height: 100%;
max-width: 100%;
width: auto;
}

}
Loading

0 comments on commit d9478a4

Please # to comment.