Skip to content

Commit

Permalink
replace imports with use and forward
Browse files Browse the repository at this point in the history
  • Loading branch information
StanH-Swis committed Dec 2, 2024
1 parent 2214fa9 commit 21e42a0
Show file tree
Hide file tree
Showing 38 changed files with 444 additions and 361 deletions.
56 changes: 17 additions & 39 deletions stylesheets/_breakpoint.scss
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
//////////////////////////////
// Default Variables
//////////////////////////////
$Breakpoint-Settings: (
'default media': all,
'default feature': min-width,
'default pair': width,

'force all media type': false,
'to ems': false,
'transform resolutions': true,

'no queries': false,
'no query fallbacks': false,

'base font size': 16px,

'legacy syntax': false
);

$breakpoint: () !default;

//////////////////////////////
// Imports
//////////////////////////////
@import "breakpoint/settings";
@import 'breakpoint/context';
@import 'breakpoint/helpers';
@import 'breakpoint/parsers';
@import 'breakpoint/no-query';
@use "breakpoint/settings";
@use 'breakpoint/context';
@use 'breakpoint/helpers';
@use 'breakpoint/parsers';
@use 'breakpoint/no-query';

@import 'breakpoint/respond-to';
//@use 'breakpoint/respond-to';

@import "breakpoint/legacy-settings";
@use "breakpoint/legacy-settings";

//////////////////////////////
// Breakpoint Mixin
//////////////////////////////

@mixin breakpoint($query, $no-query: false) {
@include legacy-settings-warning;
@include legacy-settings.legacy-settings-warning;

// Reset contexts
@include private-breakpoint-reset-contexts();
@include context.private-breakpoint-reset-contexts();

$breakpoint: breakpoint($query, false);
$breakpoint: parsers.breakpoint($query, false);

$query-string: map-get($breakpoint, 'query');
$query-fallback: map-get($breakpoint, 'fallback');
Expand All @@ -57,31 +35,31 @@ $breakpoint: () !default;
}

@if $query-fallback != false {
$context-setter: private-breakpoint-set-context('no-query', $query-fallback);
$context-setter: context.private-breakpoint-set-context('no-query', $query-fallback);
}

// Print Out Query String
@if not breakpoint-get('no queries') {
@if not settings.breakpoint-get('no queries') {
@media #{$query-string} {
@content;
}
}

@if breakpoint-get('no query fallbacks') != false or breakpoint-get('no queries') == true {
@if settings.breakpoint-get('no query fallbacks') != false or settings.breakpoint-get('no queries') == true {

$type: type-of(breakpoint-get('no query fallbacks'));
$type: type-of(settings.breakpoint-get('no query fallbacks'));
$print: false;

@if ($type == 'bool') {
$print: true;
}
@else if ($type == 'string') {
@if $query-fallback == breakpoint-get('no query fallbacks') {
@if $query-fallback == settings.breakpoint-get('no query fallbacks') {
$print: true;
}
}
@else if ($type == 'list') {
@each $wrapper in breakpoint-get('no query fallbacks') {
@each $wrapper in settings.breakpoint-get('no query fallbacks') {
@if $query-fallback == $wrapper {
$print: true;
}
Expand All @@ -103,7 +81,7 @@ $breakpoint: () !default;
}
}

@include private-breakpoint-reset-contexts();
@include context.private-breakpoint-reset-contexts();
}


Expand Down
8 changes: 5 additions & 3 deletions stylesheets/breakpoint/_context.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "settings";

//////////////////////////////
// Private Breakpoint Variables
//////////////////////////////
Expand Down Expand Up @@ -34,7 +36,7 @@ $private-breakpoint-query-count: 0 !default;
}
@else {
@if breakpoint-has-context() and $feature == 'media' {
@return breakpoint-get('default media');
@return settings.breakpoint-get('default media');
}
@else {
@return false;
Expand All @@ -59,7 +61,7 @@ $private-breakpoint-query-count: 0 !default;
$v-holder: ();
@for $i from 1 to $private-breakpoint-query-count {
@if $feature == 'media' {
$v-holder: append($v-holder, breakpoint-get('default media'));
$v-holder: append($v-holder, settings.breakpoint-get('default media'));
}
@else {
$v-holder: append($v-holder, false);
Expand All @@ -73,7 +75,7 @@ $private-breakpoint-query-count: 0 !default;
$length: length($v-holder);
@for $i from $length to $private-breakpoint-query-count - 1 {
@if $feature == 'media' {
$v-holder: append($v-holder, breakpoint-get('default media'));
$v-holder: append($v-holder, settings.breakpoint-get('default media'));
}
@else {
$v-holder: append($v-holder, false);
Expand Down
11 changes: 6 additions & 5 deletions stylesheets/breakpoint/_helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
//////////////////////////////

@use "sass:math";
@use "settings";

@function breakpoint-to-base-em($value) {
$value-unit: unit($value);

// Will convert relative EMs into root EMs.
@if breakpoint-get('base font size') and type-of(breakpoint-get('base font size')) == 'number' and $value-unit == 'em' {
$base-unit: unit(breakpoint-get('base font size'));
@if settings.breakpoint-get('base font size') and type-of(settings.breakpoint-get('base font size')) == 'number' and $value-unit == 'em' {
$base-unit: unit(settings.breakpoint-get('base font size'));

@if $base-unit == 'px' or $base-unit == '%' or $base-unit == 'em' or $base-unit == 'pt' {
@return math.div(base-conversion($value), base-conversion(breakpoint-get('base font size'))) * 1em;
@return math.div(base-conversion($value), base-conversion(settings.breakpoint-get('base font size'))) * 1em;
}
@else {
@warn '#{breakpoint-get(\'base font size\')} is not set in valid units for font size!';
@warn '#{settings.breakpoint-get(\'base font size\')} is not set in valid units for font size!';
@return false;
}
}
Expand Down Expand Up @@ -140,7 +141,7 @@ $breakpoint-single-string-features: 'color',
@function breakpoint-is-resolution($feature) {
$resolutions: 'device-pixel-ratio', 'dpr';
@if breakpoint-get('transform resolutions') {
@if settings.breakpoint-get('transform resolutions') {
$resolutions: append($resolutions, 'resolution');
}
Expand Down
38 changes: 20 additions & 18 deletions stylesheets/breakpoint/_legacy-settings.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "settings";

@mixin legacy-settings-warning {
$legacyVars: (
'default-media': 'default media',
Expand All @@ -20,31 +22,31 @@
//////////////////////////////
// Hand correct each setting
//////////////////////////////
@if global-variable-exists('breakpoint-default-media') and $breakpoint-default-media != breakpoint-get('default media') {
@include breakpoint-set('default media', $breakpoint-default-media);
@if global-variable-exists('breakpoint-default-media') and $breakpoint-default-media != settings.breakpoint-get('default media') {
@include settings.breakpoint-set('default media', $breakpoint-default-media);
}
@if global-variable-exists('breakpoint-default-feature') and $breakpoint-default-feature != breakpoint-get('default feature') {
@include breakpoint-set('default feature', $breakpoint-default-feature);
@if global-variable-exists('breakpoint-default-feature') and $breakpoint-default-feature != settings.breakpoint-get('default feature') {
@include settings.breakpoint-set('default feature', $breakpoint-default-feature);
}
@if global-variable-exists('breakpoint-force-media-all') and $breakpoint-force-media-all != breakpoint-get('force all media type') {
@include breakpoint-set('force all media type', $breakpoint-force-media-all);
@if global-variable-exists('breakpoint-force-media-all') and $breakpoint-force-media-all != settings.breakpoint-get('force all media type') {
@include settings.breakpoint-set('force all media type', $breakpoint-force-media-all);
}
@if global-variable-exists('breakpoint-to-ems') and $breakpoint-to-ems != breakpoint-get('to ems') {
@include breakpoint-set('to ems', $breakpoint-to-ems);
@if global-variable-exists('breakpoint-to-ems') and $breakpoint-to-ems != settings.breakpoint-get('to ems') {
@include settings.breakpoint-set('to ems', $breakpoint-to-ems);
}
@if global-variable-exists('breakpoint-resolutions') and $breakpoint-resolutions != breakpoint-get('transform resolutions') {
@include breakpoint-set('transform resolutions', $breakpoint-resolutions);
@if global-variable-exists('breakpoint-resolutions') and $breakpoint-resolutions != settings.breakpoint-get('transform resolutions') {
@include settings.breakpoint-set('transform resolutions', $breakpoint-resolutions);
}
@if global-variable-exists('breakpoint-no-queries') and $breakpoint-no-queries != breakpoint-get('no queries') {
@include breakpoint-set('no queries', $breakpoint-no-queries);
@if global-variable-exists('breakpoint-no-queries') and $breakpoint-no-queries != settings.breakpoint-get('no queries') {
@include settings.breakpoint-set('no queries', $breakpoint-no-queries);
}
@if global-variable-exists('breakpoint-no-query-fallbacks') and $breakpoint-no-query-fallbacks != breakpoint-get('no query fallbacks') {
@include breakpoint-set('no query fallbacks', $breakpoint-no-query-fallbacks);
@if global-variable-exists('breakpoint-no-query-fallbacks') and $breakpoint-no-query-fallbacks != settings.breakpoint-get('no query fallbacks') {
@include settings.breakpoint-set('no query fallbacks', $breakpoint-no-query-fallbacks);
}
@if global-variable-exists('breakpoint-base-font-size') and $breakpoint-base-font-size != breakpoint-get('base font size') {
@include breakpoint-set('base font size', $breakpoint-base-font-size);
@if global-variable-exists('breakpoint-base-font-size') and $breakpoint-base-font-size != settings.breakpoint-get('base font size') {
@include settings.breakpoint-set('base font size', $breakpoint-base-font-size);
}
@if global-variable-exists('breakpoint-legacy-syntax') and $breakpoint-legacy-syntax != breakpoint-get('legacy syntax') {
@include breakpoint-set('legacy syntax', $breakpoint-legacy-syntax);
@if global-variable-exists('breakpoint-legacy-syntax') and $breakpoint-legacy-syntax != settings.breakpoint-get('legacy syntax') {
@include settings.breakpoint-set('legacy syntax', $breakpoint-legacy-syntax);
}
}
Loading

0 comments on commit 21e42a0

Please sign in to comment.