Skip to content

Commit

Permalink
feat(core): add readable media aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Nov 6, 2024
1 parent 0e5f250 commit 3bfff2f
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
.loop(6);
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
display: none;
}
}
Expand Down
8 changes: 4 additions & 4 deletions projects/core/directives/surface/surface.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ button[data-surface] {
padding: var(--tui-gap);
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
[data-surface]:hover input[tuiSurfaceLayer] + & {
padding: var(--tui-gap);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ input[tuiSurfaceLayer] {
inset 0 0 0 calc(var(--tui-gap) / 2) var(--tui-background-neutral-1);
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
[data-surface]:hover & {
box-shadow:
inset 0 0,
Expand Down Expand Up @@ -141,7 +141,7 @@ input[tuiSurfaceLayer] {
transform: scale(0.95);
}

@media (hover: hover) {
@media @tui-mouse {
&:hover {
box-shadow: var(--tui-shadow-small-hover);
transform: translate3d(0, -0.25rem, 0);
Expand All @@ -161,7 +161,7 @@ input[tuiSurfaceLayer] {
transform: scale(0.95);
}

@media (hover: hover) {
@media @tui-mouse {
&:hover {
transform: scale(1.15);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/core/styles/components/icon.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tui-icon {
box-sizing: border-box;
mask: var(--t-icon-bg) no-repeat center/contain;

@media (hover: hover) {
@media @tui-mouse {
&[data-appearance='icon']:hover {
color: var(--tui-text-secondary);
}
Expand Down
4 changes: 2 additions & 2 deletions projects/core/styles/mixins/appearance.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.appearance-hover(@content) {
.interactive({
@media (hover: hover) {
@media @tui-mouse {
&:hover:not(:disabled):not([data-state]) {
@content();
}
Expand All @@ -14,7 +14,7 @@
}

/* @deprecated TODO remove in v5 */
@media (hover: hover) {
@media @tui-mouse {
&[tuiWrapper]:hover:not(._no-hover),
&[tuiWrapper][data-state='hover'] {
@content();
Expand Down
5 changes: 3 additions & 2 deletions projects/core/styles/mixins/appearance.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@import 'mixins.scss';
@import '../variables/media.scss';

@mixin appearance-hover {
@include interactive {
@media (hover: hover) {
@media ($tui-mouse) {
&:hover:not([data-state]) {
@content;
}
Expand All @@ -14,7 +15,7 @@
}

/* @deprecated TODO remove in v5 */
@media (hover: hover) {
@media ($tui-mouse) {
&[tuiWrapper]:hover:not(._no-hover),
&[tuiWrapper][data-state='hover'] {
@content;
Expand Down
2 changes: 1 addition & 1 deletion projects/core/styles/mixins/date-picker.less
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
text-underline-offset: 0.25rem;
}

@media (hover: hover) {
@media @tui-mouse {
&:hover:not([data-range='start']):not([data-range='end'])::before {
background: var(--tui-background-neutral-1-hover);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/core/styles/mixins/wrapper.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @deprecated use appearance instead
*/
.wrapper-hover(@ruleset) {
@media (hover: hover) {
@media @tui-mouse {
&:hover:not(._no-hover),
&[data-state='hover'] {
@ruleset();
Expand Down
4 changes: 3 additions & 1 deletion projects/core/styles/mixins/wrapper.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import '../variables/media.scss';

@mixin wrapper-hover {
@media (hover: hover) {
@media ($tui-mouse) {
&:hover:not(._no-hover),
&[data-state='hover'] {
@content;
Expand Down
5 changes: 5 additions & 0 deletions projects/core/styles/variables/media.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ next min-width - 60% from 1px (1/16 * 0.6 = 0.0375)
@tui-desktop-interval: ~'(min-width: 64em) and (max-width: 79.9625em)';

@tui-desktop-lg-min: ~'screen and (min-width: 80em)';

@tui-touch: ~'(hover: none) and (pointer: coarse)';
@tui-stylus: ~'(hover: none) and (pointer: fine)';
@tui-pointer: ~'(hover: hover) and (pointer: coarse)';
@tui-mouse: ~'(hover: hover) and (pointer: fine)';
5 changes: 5 additions & 0 deletions projects/core/styles/variables/media.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ $tui-desktop-min: 'screen and (min-width: 64em)';
$tui-desktop-interval: '(min-width: 64em) and (max-width: 79.9625em)';

$tui-desktop-lg-min: 'screen and (min-width: 80em)';

$tui-touch: '(hover: none) and (pointer: coarse)';
$tui-stylus: '(hover: none) and (pointer: fine)';
$tui-pointer: '(hover) and (pointer: coarse)';
$tui-mouse: '(hover) and (pointer: fine)';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '@taiga-ui/core/styles/taiga-ui-local';

.scale {
@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
&:hover {
transform: scale(1.15);
}
Expand All @@ -25,7 +25,7 @@
);
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
&:hover::after {
opacity: 0.5;
}
Expand All @@ -37,7 +37,7 @@
}

.highlight {
@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
&:hover::before {
backdrop-filter: brightness(1.1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ button[tuiSwipeAction] {
border-radius: 100%;
}

@media only screen and (hover: none) and (pointer: coarse) {
@media @tui-touch {
.fallback {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/files/file/file.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
box-shadow: inset 0 0 0 2px var(--tui-border-focus);
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
opacity: 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/segmented/segmented.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ tui-segmented {
outline-offset: -0.25rem;
}

@media (hover: hover) {
@media @tui-mouse {
&:not(.tui-segmented_active):not(:active):hover {
background-color: var(--tui-background-neutral-1-hover);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/tabs/tabs.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
margin: 0.5rem;
}

@media (hover: hover) {
@media @tui-mouse {
&:hover {
color: var(--tui-text-primary);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/directives/tooltip/tooltip.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
}

@media (hover: hover) {
@media @tui-mouse {
tui-textfield:hover [tuiTooltip][data-appearance='icon']::after,
tui-textarea:hover [tuiTooltip][data-appearance='icon']::after,
tui-primitive-textfield:hover [tuiTooltip][data-appearance='icon']::after,
Expand Down
2 changes: 1 addition & 1 deletion projects/layout/components/cell/cell.styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
}
}

@media (hover: hover) and (pointer: fine) {
@media @tui-mouse {
a[tuiCell]:not([tuiSurface]):hover,
button[tuiCell]:not([tuiSurface]):hover,
label[tuiCell]:not([tuiSurface]):hover {
Expand Down

0 comments on commit 3bfff2f

Please sign in to comment.