Skip to content

Commit

Permalink
fix: renamed custom media query (#2495)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Aug 4, 2024
1 parent 75364f4 commit de07eca
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Card/Card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ProductTour/Checkpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Toast/ToastContainer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Toast/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions tokens/style-dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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`;
}
}

Expand Down
12 changes: 12 additions & 0 deletions tokens/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
4 changes: 2 additions & 2 deletions www/src/components/Menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 5 additions & 5 deletions www/src/components/Search/Search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -318,7 +318,7 @@
}

.DocSearch-Cancel {
@media (--max-pgn-size-breakpoint-sm) {
@media (--pgn-size-breakpoint-max-width-sm) {
margin-right: 1.1875rem;
}
}
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/_doc-elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
}
Expand Down
6 changes: 3 additions & 3 deletions www/src/components/header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@
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%;
overflow: hidden;
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;
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit de07eca

Please sign in to comment.