Skip to content

Commit

Permalink
feat(core): add browser specific style mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea committed Oct 10, 2023
1 parent 090b8c7 commit 30e7b08
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 18 deletions.
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;
}
}
14 changes: 7 additions & 7 deletions projects/core/styles/mixins/textfield.less
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@

// TODO: Rename to label in 4.0
.textfield-placeholder() {
.safari-only({
& {
will-change: unset;
transition-property: transform, color, letter-spacing;
}
});

.transition(~'transform, font-size, color, letter-spacing');
.text-overflow();
display: block;
Expand Down Expand Up @@ -234,13 +241,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 30e7b08

Please sign in to comment.