Skip to content

Commit

Permalink
Merge pull request #63 from infra-geo-ouverte/fix/breakpoints
Browse files Browse the repository at this point in the history
fix: cleaned breakpoint values
  • Loading branch information
LAMM26 authored Jan 21, 2025
2 parents 7288ba9 + c273b77 commit 3d9ed09
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 167 deletions.
153 changes: 98 additions & 55 deletions packages/core/src/layout/_breakpoints.scss
Original file line number Diff line number Diff line change
@@ -1,79 +1,122 @@
@use 'sass:map';

// There is no standard for breakpoints for the Quebec.ca theme
// This is the Material breakpoint design by devices
$device: (
mobile: (
max: 599px
// https://design.quebec.ca/design/bases/grille-8px#c84016
$breakpoints: (
small: (
min-width: 0,
max-width: 599px,
// should be 575px, but set at 599px because of isHandset for now.
container-max-width: container-max-width('mobile'),
columns: 4,
spacing: 16px,
margins: 8px
),
tablet: (
min: 600px,
max: 1239px
medium: (
min-width: 600px,
// should be 576px, but set at 600px because of isHandset for now.
max-width: 767px,
container-max-width: container-max-width('mobile-landscape'),
columns: 4,
spacing: 16px,
margins: 8px
),
laptop: (
min: 1240px,
max: 1439px
large: (
min-width: 768px,
max-width: 991px,
container-max-width: container-max-width('tablet'),
columns: 12,
spacing: 24px,
margins: 12px
),
desktop: (
min: 1440px
extra-large: (
min-width: 992px,
max-width: 1199px,
container-max-width: container-max-width('laptop'),
columns: 12,
spacing: 24px,
margins: 12px
),
maximum: (
min-width: 1200px,
max-width: 9999px,
container-max-width: container-max-width('desktop'),
columns: 12,
spacing: 32px,
margins: 16px
)
);

$container: (
sm: (
max: 599px
),
md: (
min: 600px,
max: 768px
),
lg: (
min: 769px,
max: 992px
),
xl: (
min: 993px,
max: 1239px
),
xxl: (
min: 1240px,
max: 1440px
)
$devices: (
mobile: 'small',
mobile-landscape: 'medium',
tablet: 'large',
laptop: 'extra-large',
desktop: 'maximum'
);

// // Source: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_breakpoints.scss
@function min($name, $breakpoints: $device) {
$min: map.get($breakpoints, $name, min);
@return if($min != 0, $min, null);
@function breakpoint($device) {
@return map.get($devices, $device);
}

@function max($name, $breakpoints: $device) {
$max: map.get($breakpoints, $name, max);
@return if($max and $max > 0, $max, null);
@function min-width($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
@return map.get($breakpoints, $breakpoint, min-width);
}
}

// Media of at least the minimum breakpoint width. No query for the smallest breakpoint.
// Makes the @content apply to the given breakpoint and wider.
@mixin up($name, $breakpoints: $device) {
$min: min($name, $breakpoints);
@if $min {
@media (min-width: $min) {
@content;
}
@function max-width($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
@return map.get($breakpoints, $breakpoint, max-width);
}
}

@function container-max-width($device) {
$breakpoint: breakpoint($device);
$margins: map.get($breakpoints, $breakpoint, margins);

@if $breakpoint == 'small' {
@return calc(map.get($breakpoints, $breakpoint, max-width) - 2 * $margins);
} @else {
@content;
@return calc(map.get($breakpoints, $breakpoint, min-width) - 2 * $margins);
}
}

@function columns($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
@return map.get($breakpoints, $breakpoint, columns);
}
}

@function spacing($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
@return map.get($breakpoints, $breakpoint, spacing);
}
}

@function margins($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
@return map.get($breakpoints, $breapoint, margins);
}
}

// Media of at most the maximum breakpoint width. No query for the largest breakpoint.
// Makes the @content apply to the given breakpoint and narrower.
@mixin down($name, $breakpoints: $device) {
$max: max($name, $breakpoints);
@if $max {
@media (max-width: $max) {
// https://github.com/twbs/bootstrap/blob/main/scss/mixins/_breakpoints.scss
@mixin media($device) {
$breakpoint: breakpoint($device);
@if $breakpoint {
$max-width: map.get($breakpoints, $breakpoint, max-width);
@if $max-width {
@media (max-width: $max-width) {
@content;
}
} @else {
@content;
}
} @else {
@content;
}
}
2 changes: 1 addition & 1 deletion packages/core/src/layout/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@forward './breakpoints' as breakpoint-*;
@forward './breakpoints';
24 changes: 10 additions & 14 deletions packages/core/src/layout/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@
// 2. Include any default variable overrides here
$grid-gutter-width: 2rem;
$grid-breakpoints: (
xs: 0,
sm: breakpoints.max(sm, breakpoints.$container),
md: breakpoints.max(md, breakpoints.$container),
lg: breakpoints.max(lg, breakpoints.$container),
xl: breakpoints.max(xl, breakpoints.$container),
xxl: breakpoints.max(xxl, breakpoints.$container)
xs: breakpoints.min-width('mobile'),
sm: breakpoints.min-width('mobile-landscape'),
md: breakpoints.min-width('tablet'),
lg: breakpoints.min-width('laptop'),
xl: breakpoints.min-width('desktop')
);

$container-max-widths: (
sm: breakpoints.max(sm, breakpoints.$container),
md: breakpoints.max(md, breakpoints.$container),
lg: breakpoints.max(lg, breakpoints.$container),
xl: breakpoints.max(xl, breakpoints.$container),
xxl: breakpoints.max(xxl, breakpoints.$container)
xs: breakpoints.container-max-width('mobile'),
sm: breakpoints.container-max-width('mobile-landscape'),
md: breakpoints.container-max-width('tablet'),
lg: breakpoints.container-max-width('laptop'),
xl: breakpoints.container-max-width('desktop')
);

$navbar-nav-link-padding-x: 16px;
$navbar-nav-link-padding-y: 16px;

// 3. Include remainder of required Bootstrap stylesheets
@import '../../../../node_modules/bootstrap/scss/variables';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/typography/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ $font-color: colors.$blue-dark;

@include typo-utils.title-border;

@include breakpoints.down(tablet) {
@include breakpoints.media(mobile) {
margin-top: 48px !important;
margin-bottom: 16px !important;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/src/lib/navigation/_navigation-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
--mdc-tab-indicator-active-indicator-height: 4px;

.sdg-navigation-header {
@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
@include mat.tabs-density($theme);
@include mat.button-density($theme);
@include mat.icon-button-density($theme);
Expand Down
18 changes: 9 additions & 9 deletions packages/src/lib/navigation/navigation.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $row-height-mobile: 40px;
&-container {
padding: 0 16px;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
padding: 0 8px;
}
}
Expand All @@ -41,7 +41,7 @@ $row-height-mobile: 40px;
}
}

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
height: fit-content;
min-height: $row-height-mobile;
}
Expand All @@ -50,15 +50,15 @@ $row-height-mobile: 40px;
&-actions {
display: flex;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
margin-bottom: 0;
}

::ng-deep {
button {
margin-left: 24px;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
margin-left: 16px;
}
}
Expand All @@ -71,7 +71,7 @@ $row-height-mobile: 40px;

--tab-inner-spacing: 16px;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
--tab-inner-spacing: 8px;
}

Expand All @@ -93,7 +93,7 @@ $row-height-mobile: 40px;
}
}

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
--mdc-secondary-navigation-tab-container-height: #{$row-height-mobile};
}
}
Expand All @@ -110,7 +110,7 @@ $row-height-mobile: 40px;
max-width: 100%;
overflow: hidden;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
width: 100%;
flex-grow: unset;
height: fit-content;
Expand Down Expand Up @@ -142,7 +142,7 @@ $row-height-mobile: 40px;
}
}

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
$font-size-mobile: 13px;
button {
--mdc-filled-button-container-height: 24px;
Expand Down Expand Up @@ -177,7 +177,7 @@ $row-height-mobile: 40px;
mat-icon {
margin-left: 4px;

@include layout.breakpoint-down(mobile) {
@include layout.media(mobile) {
margin-left: 0px;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<sdg-breadcrumbs-with-router class="container" [isHandset]="isHandset()" />

<div class="container split-screen-content" [class.--handset]="isHandset()">
<div class="container split-screen-content">
<div class="lateral-menu">
<ng-content select="[left-slot]"></ng-content>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
@use '@igo2/sdg';

.split-screen-content {
display: flex;
column-gap: 32px;

&.--handset {
flex-direction: column;
}
column-gap: sdg.spacing(desktop);
}

.lateral-menu {
flex: 0 0 25%;
margin-top: 72px;
}

@media only screen and (max-width: sdg.max-width(laptop)) {
.split-screen-content {
column-gap: sdg.spacing(laptop);
}
}

@media only screen and (max-width: sdg.max-width(tablet)) {
.split-screen-content {
column-gap: sdg.spacing(tablet);
}
}

@media only screen and (max-width: sdg.max-width(mobile)) {
.split-screen-content {
flex-direction: column;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<app-basic-screen title="Composants" [isHandset]="isHandset()">
<div class="block-links">
@for (section of sections; track section) {
<sdg-block-link
[class.--handset]="isHandset()"
[section]="section"
[isHandset]="isHandset()"
/>
<sdg-block-link [section]="section" [isHandset]="isHandset()" />
}
</div>
</app-basic-screen>
Loading

0 comments on commit 3d9ed09

Please sign in to comment.