Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(styles): set CSS vars in pin mixin #1296

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 42 additions & 38 deletions styles/mixins.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use 'sass:list';

@mixin overflow-ellipsis($type: ellipsis) {
white-space: nowrap;
overflow: hidden;
Expand Down Expand Up @@ -63,92 +65,94 @@
}
}

$-pin-mixin-variables-ns: --_--g-pin-mixin-border-radius;
amje marked this conversation as resolved.
Show resolved Hide resolved

@mixin -pin-mixin-variables-from-list($list) {
amje marked this conversation as resolved.
Show resolved Hide resolved
$props: top-left, top-right, bottom-right, bottom-left;
$indexes: 1, 2, 3, 4;

@if list.length($list) == 1 {
$indexes: 1, 1, 1, 1;
}

@each $prop, $index in list.zip($props, $indexes) {
#{#{$-pin-mixin-variables-ns}-#{$prop}}: list.nth($list, $index);
}
}

@mixin pin($block, $selectors, $radius, $append: true) {
@each $selector in $selectors {
&#{get-pin-selector($block, $selector, $append)} {
border-radius: (
var(#{$-pin-mixin-variables-ns}-top-left)
var(#{$-pin-mixin-variables-ns}-top-right)
var(#{$-pin-mixin-variables-ns}-bottom-right)
var(#{$-pin-mixin-variables-ns}-bottom-left)
Comment on lines +87 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTL support degradation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

physical properties instead of logical ones

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But property is border-radius, it is rtl compatible

Copy link
Contributor

@amje amje Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no such api like top-left, bottom-right. Instead we should only use logical names: start-start, end-end, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i will rename vars, no problem

);
}
}

@each $selector in $selectors {
&#{get-pin-selector(#{$block}_pin_round-round, $selector, $append)} {
border-radius: $radius;
@include -pin-mixin-variables-from-list($radius);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break customization via CSS API, see "Custom" story of Button

}

&#{get-pin-selector(#{$block}_pin_brick-brick, $selector, $append)} {
border-radius: 0;
@include -pin-mixin-variables-from-list(0);
}

&#{get-pin-selector(#{$block}_pin_clear-clear, $selector, $append)} {
border-radius: 0;
@include -pin-mixin-variables-from-list(0);
border-inline: 0;
}

&#{get-pin-selector(#{$block}_pin_circle-circle, $selector, $append)} {
border-radius: 100px;
@include -pin-mixin-variables-from-list(100px);
}

&#{get-pin-selector(#{$block}_pin_round-brick, $selector, $append)} {
border-start-start-radius: $radius;
border-start-end-radius: 0;
border-end-start-radius: $radius;
border-end-end-radius: 0;
@include -pin-mixin-variables-from-list($radius 0 0 $radius);
}

&#{get-pin-selector(#{$block}_pin_brick-round, $selector, $append)} {
border-start-start-radius: 0;
border-start-end-radius: $radius;
border-end-start-radius: 0;
border-end-end-radius: $radius;
@include -pin-mixin-variables-from-list(0 $radius $radius 0);
}

&#{get-pin-selector(#{$block}_pin_round-clear, $selector, $append)} {
border-start-start-radius: $radius;
border-start-end-radius: 0;
border-end-start-radius: $radius;
border-end-end-radius: 0;
@include -pin-mixin-variables-from-list($radius 0 0 $radius);
border-inline-end: 0;
}

&#{get-pin-selector(#{$block}_pin_clear-round, $selector, $append)} {
border-start-start-radius: 0;
border-start-end-radius: $radius;
border-end-start-radius: 0;
border-end-end-radius: $radius;
@include -pin-mixin-variables-from-list(0 $radius $radius 0);
border-inline-start: 0;
}

&#{get-pin-selector(#{$block}_pin_brick-clear, $selector, $append)} {
border-radius: 0;
@include -pin-mixin-variables-from-list(0);
border-inline-end: 0;
}

&#{get-pin-selector(#{$block}_pin_clear-brick, $selector, $append)} {
border-radius: 0;
@include -pin-mixin-variables-from-list(0);
border-inline-start: 0;
}

&#{get-pin-selector(#{$block}_pin_circle-brick, $selector, $append)} {
border-start-start-radius: 100px;
border-start-end-radius: 0;
border-end-start-radius: 100px;
border-end-end-radius: 0;
@include -pin-mixin-variables-from-list(100px 0 0 100px);
}

&#{get-pin-selector(#{$block}_pin_brick-circle, $selector, $append)} {
border-start-start-radius: 0;
border-start-end-radius: 100px;
border-end-start-radius: 0;
border-end-end-radius: 100px;
@include -pin-mixin-variables-from-list(0 100px 100px 0);
}

&#{get-pin-selector(#{$block}_pin_circle-clear, $selector, $append)} {
border-start-start-radius: 100px;
border-start-end-radius: 0;
border-end-start-radius: 100px;
border-end-end-radius: 0;
@include -pin-mixin-variables-from-list(100px 0 0 100px);
border-inline-end: 0;
}

&#{get-pin-selector(#{$block}_pin_clear-circle, $selector, $append)} {
border-start-start-radius: 0;
border-start-end-radius: 100px;
border-end-start-radius: 0;
border-end-end-radius: 100px;
@include -pin-mixin-variables-from-list(0 100px 100px 0);
border-inline-start: 0;
}
}
Expand Down
Loading