Skip to content

Commit

Permalink
feat(core): add browser specific style mixins (#5589)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Oct 10, 2023
1 parent d04cba6 commit 27623c3
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"aldus",
"hangoff",
"tcrm",
"scrollbars"
"scrollbars",
"callout"
],
"ignoreRegExpList": ["\\(https?://.*?\\)", "\\/{1}.+\\/{1}", "\\%2F.+", "\\%2C.+", "\\ɵ.+", "\\ыва.+"],
"overrides": [
Expand Down
12 changes: 5 additions & 7 deletions projects/core/components/loader/loader.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
}

.t-icon {
.safari-only({
& {
overflow: visible;
}
});
display: block;
min-width: 1em;
max-width: 1em;
Expand All @@ -146,13 +151,6 @@
overflow: hidden;
transform: scale(1, -1);
animation: tuiLoaderRotate 3s linear infinite;

/* Safari Only */
@supports (-webkit-hyphens: none) {
& {
overflow: visible;
}
}
}

.t-circle {
Expand Down
23 changes: 23 additions & 0 deletions projects/core/styles/mixins/browsers.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.firefox-only(@ruleset) {
@supports (-moz-appearance: none) {
@ruleset();
}
}

.safari-only(@ruleset) {
@supports (-webkit-hyphens: none) {
@ruleset();
}
}

.ios-only(@ruleset) {
@supports (-webkit-touch-callout: none) {
@ruleset();
}
}

.chrome-only(@ruleset) {
@supports (not (-moz-appearance: none)) and (not (-webkit-hyphens: none)) {
@ruleset();
}
}
23 changes: 23 additions & 0 deletions projects/core/styles/mixins/browsers.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@mixin firefox-only {
@supports (-moz-appearance: none) {
@content;
}
}

@mixin safari-only {
@supports (-webkit-hyphens: none) {
@content;
}
}

@mixin ios-only {
@supports (-webkit-touch-callout: none) {
@content;
}
}

@mixin chrome-only {
@supports (not (-moz-appearance: none)) and (not (-webkit-hyphens: none)) {
@content;
}
}
13 changes: 6 additions & 7 deletions projects/core/styles/mixins/textfield.less
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
.textfield-placeholder() {
.transition(~'transform, font-size, color, letter-spacing');
.text-overflow();
.safari-only({
& {
will-change: unset;
transition-property: transform, color, letter-spacing;
}
});
display: block;
width: 100%;
user-select: none;
Expand Down Expand Up @@ -234,13 +240,6 @@
:host[data-size='l']._focused._label-outside [tuiWrapper][data-mode='onDark'] & {
color: var(--tui-text-02-night);
}

@supports (-webkit-hyphens: none) {
& {
will-change: unset;
transition-property: transform, color, letter-spacing;
}
}
}

.input-icon() {
Expand Down
2 changes: 1 addition & 1 deletion projects/core/styles/mixins/textfield.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ $line-height-l: 1.25rem;
color: var(--tui-text-02-night);
}

@supports (-webkit-hyphens: none) {
@include safari-only {
& {
will-change: unset;
transition-property: transform, color, letter-spacing;
Expand Down
4 changes: 4 additions & 0 deletions projects/core/styles/taiga-ui-local.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/**
* @deprecated remove in 4.0
*/
@space: 0.25rem;

@import 'mixins/browsers.less';
@import 'mixins/mixins.less';
@import 'mixins/picker.less';
@import 'mixins/slider.less';
Expand Down
6 changes: 5 additions & 1 deletion projects/core/styles/taiga-ui-local.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
$space: 4px;
/**
* @deprecated remove in 4.0
*/
$space: 0.25rem;

@import 'mixins/browsers.scss';
@import 'mixins/mixins.scss';
@import 'mixins/picker.scss';
@import 'mixins/slider.scss';
Expand Down
4 changes: 2 additions & 2 deletions projects/core/styles/theme/wrapper/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
});

// Temporary hide focus in Safari until we figure out a better approach
@supports (-webkit-hyphens: none) {
.safari-only({
:focus-visible &,
&:focus-visible {
--tui-focus: transparent !important;
}
}
});
}

0 comments on commit 27623c3

Please sign in to comment.