Skip to content

Commit

Permalink
feat: remove SCSS variable usages in components (#2137)
Browse files Browse the repository at this point in the history
* feat: removed SCSS variable usages in components and other custom styles

* feat: removed SCSS variable files in components

* refactor: code refactoring

* refactor: deleted old logic to search SCSS variables

* refactor: refactoring variables and Anotation component

* feat: added CSS hooks plus tokens for IconButton

* refactor: refacoring IconButton component

* refactor: some refactoring

* feat: update replace-scss-vars script to handle interpolation expressions

* feat: remove SCSS variables in docs site and start using custom media queries

---------

Co-authored-by: Viktor Rusakov <[email protected]>
  • Loading branch information
PKulkoRaccoonGang and viktorrusakov committed Aug 5, 2024
1 parent ad4b847 commit 2a7e53a
Show file tree
Hide file tree
Showing 130 changed files with 4,530 additions and 4,159 deletions.
22 changes: 7 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/ActionRow/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "variables";

.pgn__action-row {
display: flex;
flex-grow: 1;
Expand All @@ -11,7 +9,7 @@
}

& > * + * {
margin-inline-start: $action-row-gap-x;
margin-inline-start: var(--pgn-spacing-action-row-gap-x);
}
}

Expand All @@ -27,7 +25,7 @@
}

& > * + * {
margin-bottom: $action-row-gap-y;
margin-bottom: var(--pgn-spacing-action-row-gap-y);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/ActionRow/_variables.scss

This file was deleted.

36 changes: 0 additions & 36 deletions src/Alert/_variables.scss

This file was deleted.

58 changes: 28 additions & 30 deletions src/Alert/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "variables";

//
// Override Bootstrap's alert definition.
// We do this to get more control over colors
Expand All @@ -12,13 +10,13 @@

.alert {
position: relative;
padding: $alert-padding-y $alert-padding-x;
margin-bottom: $alert-margin-bottom;
border: $alert-border-width solid var(--pgn-alert-border-color, transparent);
padding: var(--pgn-spacing-alert-padding-y) var(--pgn-spacing-alert-padding-x);
margin-bottom: var(--pgn-spacing-alert-margin-bottom);
border: var(--pgn-size-alert-border-width) solid var(--pgn-alert-border-color, transparent);
color: inherit;
background-color: var(--pgn-alert-bg, transparent);

@include border-radius($alert-border-radius);
@include border-radius(var(--pgn-size-alert-border-radius));
@include pgn-box-shadow(1, "down");

.alert-message-content > :last-child {
Expand All @@ -28,7 +26,7 @@
.alert-icon {
color: var(--pgn-alert-icon-color, inherit);
float: left;
margin-inline-end: $alert-icon-space;
margin-inline-end: var(--pgn-spacing-alert-icon-space);
width: 1.5rem;
height: 1.5rem;
flex-shrink: 0;
Expand All @@ -37,17 +35,17 @@

// Headings for larger alerts
.alert-heading {
// Specified to prevent conflicts of changing $headings-color
color: $alert-title-color;
// Specified to prevent conflicts of changing var(--pgn-color-headings-base)
color: var(--pgn-color-alert-title);
display: flex;
}

// added to align content and icon
.alert-content {
display: flex;
font-size: $alert-font-size;
line-height: $alert-line-height;
color: $alert-content-color;
font-size: var(--pgn-typography-alert-font-size);
line-height: var(--pgn-typography-alert-line-height);
color: var(--pgn-color-alert-content);
text-align: start;

div {
Expand All @@ -57,7 +55,7 @@

// Provide class for links that match alerts
.alert-link {
font-weight: $alert-link-font-weight;
font-weight: var(--pgn-typography-alert-font-weight-link);
text-decoration: underline;

&:hover {
Expand All @@ -69,16 +67,16 @@
//
// Expand the right padding and account for the close button's positioning.

// Baking in $close-font-size: $font-size-base * 1.5 !default; to avoid any dependency
// Baking in $close-font-size: var(--pgn-typography-font-size-base) * 1.5 !default; to avoid any dependency
.alert-dismissible {
padding-right: calc((#{$font-size-base} * 1.5) + (#{$alert-padding-x} * 2));
padding-right: calc((var(--pgn-typography-font-size-base) * 1.5) + (var(--pgn-spacing-alert-padding-x) * 2));

// Adjust close link position
.close {
position: absolute;
top: 0;
right: 0;
padding: $alert-padding-y $alert-padding-x;
padding: var(--pgn-spacing-alert-padding-y) var(--pgn-spacing-alert-padding-x);
color: inherit;
}
}
Expand All @@ -88,38 +86,38 @@
align-items: center;

.pgn__alert-actions {
margin-inline-start: $alert-actions-gap;
margin-inline-start: var(--pgn-spacing-alert-actions-gap);
}
}

.pgn__alert-message-wrapper-stacked {
.pgn__alert-actions {
margin-top: $alert-actions-gap;
margin-top: var(--pgn-spacing-alert-actions-gap);
}
}

// Alternate styles

.alert-success {
--pgn-alert-bg: #{$alert-success-bg};
--pgn-alert-border-color: #{$alert-success-border-color};
--pgn-alert-icon-color: #{$alert-success-icon-color};
--pgn-alert-bg: var(--pgn-color-alert-bg-success);
--pgn-alert-border-color: var(--pgn-color-alert-border-success);
--pgn-alert-icon-color: var(--pgn-color-alert-icon-success);
}

.alert-info {
--pgn-alert-bg: #{$alert-info-bg};
--pgn-alert-border-color: #{$alert-info-border-color};
--pgn-alert-icon-color: #{$alert-info-icon-color};
--pgn-alert-bg: var(--pgn-color-alert-bg-info);
--pgn-alert-border-color: var(--pgn-color-alert-border-info);
--pgn-alert-icon-color: var(--pgn-color-alert-icon-info);
}

.alert-danger {
--pgn-alert-bg: #{$alert-danger-bg};
--pgn-alert-border-color: #{$alert-danger-border-color};
--pgn-alert-icon-color: #{$alert-danger-icon-color};
--pgn-alert-bg: var(--pgn-color-alert-bg-danger);
--pgn-alert-border-color: var(--pgn-color-alert-border-danger);
--pgn-alert-icon-color: var(--pgn-color-alert-icon-danger);
}

.alert-warning {
--pgn-alert-bg: #{$alert-warning-bg};
--pgn-alert-border-color: #{$alert-warning-border-color};
--pgn-alert-icon-color: #{$alert-warning-icon-color};
--pgn-alert-bg: var(--pgn-color-alert-bg-warning);
--pgn-alert-border-color: var(--pgn-color-alert-border-warning);
--pgn-alert-icon-color: var(--pgn-color-alert-icon-warning);
}
104 changes: 104 additions & 0 deletions src/Annotation/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
@mixin annotation-triangle($triangle-color, $triangle-direction) {
content: "";
height: 0;
width: 0;
position: absolute;
border: solid transparent;

@if $triangle-direction == top {
border-bottom-color: $triangle-color;
border-width: 0 var(--pgn-size-annotation-arrow-border-width) var(--pgn-size-annotation-arrow-border-width);
right: 0;
left: 0;
top: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
margin: 0 auto;
}

@else if $triangle-direction == right {
border-left-color: $triangle-color;
border-width:
var(--pgn-size-annotation-arrow-border-width) 0 var(--pgn-size-annotation-arrow-border-width)
var(--pgn-size-annotation-arrow-border-width);
top: 0;
bottom: 0;
right: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
margin: auto 0;
}

@else if $triangle-direction == bottom {
border-top-color: $triangle-color;
border-width: var(--pgn-size-annotation-arrow-border-width) var(--pgn-size-annotation-arrow-border-width) 0;
right: 0;
left: 0;
bottom: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
margin: 0 auto;
}

@else if $triangle-direction == left {
border-right-color: $triangle-color;
border-width:
var(--pgn-size-annotation-arrow-border-width) var(--pgn-size-annotation-arrow-border-width)
var(--pgn-size-annotation-arrow-border-width) 0;
top: 0;
bottom: 0;
left: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
margin: auto 0;
}

@else {
@error "Unknown direction #{$triangle-direction}.";
}
}

@mixin annotation-variant($bg-color, $text-color, $direction) {
background-color: $bg-color;
color: $text-color;

// set additional margin to arrow side of the Annotation
margin-#{$direction}:
calc(
var(--pgn-size-annotation-arrow-border-width) + var(--pgn-spacing-annotation-arrow-side-margin)
);

[dir="rtl"] & {
@if $direction == left {
margin-left: 0;
margin-right:
calc(
var(--pgn-size-annotation-arrow-border-width) + var(--pgn-spacing-annotation-arrow-side-margin)
);
}

@else if $direction == right {
margin-right: 0;
margin-left:
calc(
var(--pgn-size-annotation-arrow-border-width) + var(--pgn-spacing-annotation-arrow-side-margin)
);
}
}

&::after {
@include annotation-triangle($bg-color, $direction);

[dir="rtl"] & {
@if $direction == left {
left: initial;
right: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
border-width:
var(--pgn-size-annotation-arrow-border-width) 0 var(--pgn-size-annotation-arrow-border-width)
var(--pgn-size-annotation-arrow-border-width);
border-left-color: $bg-color;
}

@else if $direction == right {
right: initial;
left: calc(var(--pgn-size-annotation-arrow-border-width) * -1);
border-width:
var(--pgn-size-annotation-arrow-border-width) var(--pgn-size-annotation-arrow-border-width)
var(--pgn-size-annotation-arrow-border-width) 0;
border-right-color: $bg-color;
}
}
}
}
Loading

0 comments on commit 2a7e53a

Please sign in to comment.