From de07eca1ca619dd7c9230cebc684aa40ac00a6d9 Mon Sep 17 00:00:00 2001 From: Peter Kulko <93188219+PKulkoRaccoonGang@users.noreply.github.com> Date: Thu, 3 Aug 2023 21:51:40 +0300 Subject: [PATCH] fix: renamed custom media query (#2495) --- src/Card/Card.scss | 2 +- src/DataTable/index.scss | 2 +- src/ProductTour/Checkpoint.scss | 2 +- src/Toast/ToastContainer.scss | 2 +- src/Toast/index.scss | 4 ++-- tokens/style-dictionary.js | 5 +++-- tokens/utils.js | 12 ++++++++++++ www/src/components/Menu.scss | 4 ++-- www/src/components/Search/Search.scss | 10 +++++----- www/src/components/_doc-elements.scss | 2 +- www/src/components/header/Header.scss | 6 +++--- 11 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/Card/Card.scss b/src/Card/Card.scss index 66d8884466..a9e22a60ef 100644 --- a/src/Card/Card.scss +++ b/src/Card/Card.scss @@ -477,7 +477,7 @@ a.pgn__card { } } -@media (--max-pgn-size-breakpoint-xs) { +@media (--pgn-size-breakpoint-max-width-xs) { .pgn__card-footer { &.horizontal > :not(:last-child) { margin-inline-end: 0; diff --git a/src/DataTable/index.scss b/src/DataTable/index.scss index 12c0bdac88..218532bb78 100644 --- a/src/DataTable/index.scss +++ b/src/DataTable/index.scss @@ -86,7 +86,7 @@ display: flex; align-items: flex-start; - @media (--max-pgn-size-breakpoint-xl) { + @media (--pgn-size-breakpoint-max-width-xl) { overflow-x: scroll; } diff --git a/src/ProductTour/Checkpoint.scss b/src/ProductTour/Checkpoint.scss index 4c80dc8f6f..4921f120cb 100644 --- a/src/ProductTour/Checkpoint.scss +++ b/src/ProductTour/Checkpoint.scss @@ -10,7 +10,7 @@ z-index: var(--pgn-elevation-product-tour-checkpoint-zindex); max-width: var(--pgn-size-product-tour-checkpoint-width-max); - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { min-width: 90%; max-width: 90%; } diff --git a/src/Toast/ToastContainer.scss b/src/Toast/ToastContainer.scss index 18b84d2030..dd10638557 100644 --- a/src/Toast/ToastContainer.scss +++ b/src/Toast/ToastContainer.scss @@ -9,7 +9,7 @@ left: 0; } - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { bottom: var(--pgn-spacing-toast-container-gutter-sm); right: var(--pgn-spacing-toast-container-gutter-sm); left: var(--pgn-spacing-toast-container-gutter-sm); diff --git a/src/Toast/index.scss b/src/Toast/index.scss index fa6775d30e..69b6a58a46 100644 --- a/src/Toast/index.scss +++ b/src/Toast/index.scss @@ -41,11 +41,11 @@ } } - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { max-width: 100%; } - @media (--min-pgn-size-breakpoint-md) { + @media (--pgn-size-breakpoint-min-width-md) { min-width: var(--pgn-size-toast-max-width); max-width: var(--pgn-size-toast-max-width); } diff --git a/tokens/style-dictionary.js b/tokens/style-dictionary.js index 8b7310da89..f89917c8bd 100644 --- a/tokens/style-dictionary.js +++ b/tokens/style-dictionary.js @@ -5,6 +5,7 @@ const StyleDictionary = require('style-dictionary'); const chroma = require('chroma-js'); const { colorYiq, darken, lighten } = require('./sass-helpers'); const cssUtilities = require('./css-utilities'); +const { composeBreakpointName } = require('./utils'); const { fileHeader, sortByReference } = StyleDictionary.formatHelpers; @@ -182,9 +183,9 @@ StyleDictionary.registerFormat({ for (let i = 0; i < breakpoints.length; i++) { const [currentBreakpoint, nextBreakpoint] = [breakpoints[i], breakpoints[i + 1]]; - customMediaVariables += `@custom-media --min-${currentBreakpoint.name} (min-width: ${currentBreakpoint.value});\n`; + customMediaVariables += `${composeBreakpointName(currentBreakpoint.name, 'min')} (min-width: ${currentBreakpoint.value});\n`; if (nextBreakpoint) { - customMediaVariables += `@custom-media --max-${currentBreakpoint.name} (max-width: ${nextBreakpoint.value});\n`; + customMediaVariables += `${composeBreakpointName(currentBreakpoint.name, 'max')} (max-width: ${nextBreakpoint.value});\n`; } } diff --git a/tokens/utils.js b/tokens/utils.js index ed0bef2fad..520f0422d3 100644 --- a/tokens/utils.js +++ b/tokens/utils.js @@ -190,9 +190,21 @@ function createIndexCssFile({ buildDir = path.resolve(__dirname, '../styles/css' }); } +/** + * Composes a breakpoint name according to the Paragon namespace. + * + * @param {string} breakpointName - breakpoint initial name. + * @param {string} format - screen width format. + * @return {string} - new breakpoint name. + */ +function composeBreakpointName(breakpointName, format) { + return `@custom-media --${breakpointName.replace(/breakpoint/g, `breakpoint-${format}-width`)}`; +} + module.exports = { createIndexCssFile, getFilesWithExtension, getSCSStoCSSMap, transformInPath, + composeBreakpointName, }; diff --git a/www/src/components/Menu.scss b/www/src/components/Menu.scss index 2cf9e4bb8e..331d774e97 100644 --- a/www/src/components/Menu.scss +++ b/www/src/components/Menu.scss @@ -144,11 +144,11 @@ .pgn-doc__menu-all-components .pgn-doc__menu-component-list { columns: 4; - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { columns: 2; } - @media (--max-pgn-size-breakpoint-xs) { + @media (--pgn-size-breakpoint-max-width-xs) { columns: 1; } } diff --git a/www/src/components/Search/Search.scss b/www/src/components/Search/Search.scss index 8468af4b86..4ba0b1f362 100644 --- a/www/src/components/Search/Search.scss +++ b/www/src/components/Search/Search.scss @@ -53,7 +53,7 @@ margin: 6.875rem auto auto; cursor: auto; - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { max-width: 100%; margin: auto; border-radius: 0; @@ -65,7 +65,7 @@ border-top: var(--pgn-size-border-width) solid var(--pgn-color-light-400); padding: 0 1.625rem; - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { position: absolute; border-radius: 0; bottom: 0; @@ -92,7 +92,7 @@ padding: 0 1.625rem; max-height: 20.9375rem; - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { height: 100%; // stylelint-disable-next-line max-line-length max-height: calc(var(--docsearch-vh, 1vh) * 100 - var(--docsearch-searchbox-height) - var(--docsearch-spacing) - var(--docsearch-footer-height)); @@ -290,7 +290,7 @@ text-decoration: underline; } - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { font-size: var(--pgn-typography-font-size-base); line-height: var(--pgn-typography-line-height-base); font-weight: var(--pgn-typography-font-weight-semi-bold); @@ -318,7 +318,7 @@ } .DocSearch-Cancel { - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { margin-right: 1.1875rem; } } diff --git a/www/src/components/_doc-elements.scss b/www/src/components/_doc-elements.scss index ac52d11668..e2c29574f2 100644 --- a/www/src/components/_doc-elements.scss +++ b/www/src/components/_doc-elements.scss @@ -246,7 +246,7 @@ align-items: center; background-color: var(--pgn-color-gray-100); - @media (--max-pgn-size-breakpoint-sm) { + @media (--pgn-size-breakpoint-max-width-sm) { max-width: 100%; } } diff --git a/www/src/components/header/Header.scss b/www/src/components/header/Header.scss index a1829cd5af..9afcec866d 100644 --- a/www/src/components/header/Header.scss +++ b/www/src/components/header/Header.scss @@ -70,7 +70,7 @@ width: 13.25rem; height: 2.75rem; - @media (--max-pgn-size-breakpoint-md) { + @media (--pgn-size-breakpoint-max-width-md) { width: 2.75rem; height: 2.75rem; border-radius: 50%; @@ -78,7 +78,7 @@ padding: .625rem .75rem; } - @media (--max-pgn-size-breakpoint-xs) { + @media (--pgn-size-breakpoint-max-width-xs) { margin: 0 0 0 .5rem; width: 2rem; height: 2rem; @@ -118,7 +118,7 @@ &-settings-and-search .DocSearch.DocSearch-Button { margin: 0 var(--pgn-spacing-spacer-base) 0 0; - @media (--max-pgn-size-breakpoint-xs) { + @media (--pgn-size-breakpoint-max-width-xs) { margin: 0 .5rem 0 0; } }