gtk: Improve ink-color() mixin
Avoid using box-shadow for overlays.
Always use background properties for overlays by adding $on argument.
Add support for outlined button style.
By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.
Avoid using box-shadow for overlays.
Always use background properties for overlays by adding $on argument.
Add support for outlined button style.
roundabout,
created on Saturday, 6 March 2021, 23:32:31 (1615073551),
received on Sunday, 11 May 2025, 13:22:57 (1746969777)
Author identity: nana-4 <hnmaigo@gmail.com>
18fdbbaebade4cb47c6c7190fe3f9fdd75b66294
min-width: 16px; padding: ($medium-size - 24px) / 2 ($medium-size - 16px) / 2; border-radius: $corner-radius; background-color: $surface;color: $on-surface; font-weight: 500; @extend %ripple; @include ink-color($on-surface, $elevation: true);@include ink-color($on-surface, $button-style: "raised", $on: $surface);&:disabled { box-shadow: none;
} &:checked { background-color: overlay("activated", $primary, $on: $surface);$background-color: overlay("activated", $primary, $on: $surface);color: $primary; @include ink-color($primary, $elevation: true);@include ink-color($primary, $button-style: "raised", $on: $background-color);&:disabled { box-shadow: none;
} %button-flat-basic { background-color: transparent;color: hint($on-surface); @include ink-color($on-surface);@include ink-color($on-surface, $button-style: "flat");&:disabled { background-color: transparent;
@extend %button-flat-basic; &:checked { background-color: overlay("activated", $primary);$background-color: overlay("activated", $primary);color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat", $on: $background-color);&:disabled { color: disabled($on-surface);
// Suggested and Destructive Action buttons @each $class, $color in (".suggested-action": $primary, ".destructive-action": $error) { &#{$class} { background-color: $color;color: on($color); @include ink-color(on($color), $elevation: true);@include ink-color(on($color), $button-style: "raised", $on: $color);&:disabled { box-shadow: none;
} &:checked { background-color: overlay("activated", on($color), $on: $color);$background-color: overlay("activated", on($color), $on: $color); @include ink-color(on($color), $button-style: "raised", $on: $background-color);} &.flat { background-color: transparent;color: $color; @include ink-color($color);@include ink-color($color, $button-style: "flat");&:disabled { box-shadow: none;
} &:checked { background-color: overlay("activated", $color);$background-color: overlay("activated", $color); @include ink-color($color, $button-style: "flat", $on: $background-color);} }
button.link { &:link { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} &:visited { color: $visited; @include ink-color($visited);@include ink-color($visited, $button-style: "flat");} &:disabled {
// Remove unwanted focus indicator &:focus:not(:hover):not(:active) { box-shadow: inset 0 0 0 9999px transparent;background-color: transparent;} &.up:dir(ltr),
// Remove unwanted focus indicator &:focus:not(:hover):not(:active) { box-shadow: inset 0 0 0 9999px transparent;background-color: transparent;} &.up {
) 0 0 0 / 0 0 0; background-color: transparent; color: hint($on-titlebar); @include ink-color($on-titlebar);@include ink-color($on-titlebar, $button-style: "flat");&:disabled { color: disabled-hint($on-titlebar);
) 0 0 2 / 0 0 2px; background-color: transparent; color: $on-titlebar; @include ink-color($on-titlebar);@include ink-color($on-titlebar, $button-style: "flat");&:disabled { background-color: transparent;
border-radius: 0; background-clip: border-box; color: hint($on-surface); @include ink-color($on-surface, $hover-alt: true);@include ink-color($on-surface, $button-style: "flat", $hover-alt: true);@include list-item; &:disabled {color: disabled-hint($on-surface);}&,&:disabled { background-color: transparent; color: disabled-hint($on-surface);} &:last-child {
min-width: 40px; margin: 0; padding: 0; box-shadow: none;background-color: transparent; background-image: none; -gtk-icon-shadow: $icon-shadow-z2;
&:active, &:disabled { transition: none; // FIXME: this is a workaround for a popover check/radio long transition issue box-shadow: none;background-color: transparent;background-image: none; }
} &, &:hover,&:disabled {box-shadow: none;&:checked, &:indeterminate { &:hover, &:focus { background-color: transparent; }} } }
} &:selected { background-color: $overlay-selected;@include ink-color($primary, $hover-alt: true);@include ink-color($primary, $hover-alt: true, $on: $overlay-selected);&.has-open-popup { background-color: overlay("activated", $primary, $on: $overlay-selected);
&.text-button:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} }
&:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} &.suggested-action:not(:disabled) { background-color: transparent;// color: $primary; // @include ink-color($primary);// @include ink-color($primary, $button-style: "flat");} &.destructive-action:not(:disabled) { background-color: transparent;color: $error; @include ink-color($error);@include ink-color($error, $button-style: "flat");} } }
border-radius: $corner-radius; &:selected { background-color: overlay("activated", $primary);$background-color: overlay("activated", $primary);color: $primary; font-weight: 500; @include ink-color($primary, $hover-alt: true);@include ink-color($primary, $on: $background-color, $hover-alt: true);} + row {
} &:selected { background-color: overlay("activated", $primary);$background-color: overlay("activated", $primary);color: $primary; font-weight: 500; @include ink-color($primary, $hover-alt: true);@include ink-color($primary, $on: $background-color, $hover-alt: true);image.sidebar-icon { color: $primary;
&.text-button:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} } }
button.flat { color: $on-warning; @include ink-color($on-warning);@include ink-color($on-warning, $button-style: "flat");} selection {
button.flat { color: $on-error; @include ink-color($on-error);@include ink-color($on-error, $button-style: "flat");} selection {
} } @mixin ink-color($color, $elevation: false, $hover-alt: false, $opacity-modifier: 0) {@mixin ink-color($color, $on: transparent, $button-style: "none", $hover-alt: false, $opacity-modifier: 0) {$hover: "hover"; @if $hover-alt or $elevation {@if $hover-alt or $button-style == "raised" {$hover: "hover-alt"; } box-shadow: inset 0 0 0 9999px transparent, if($elevation, $shadow-z2, null);@if $button-style == "flat" { box-shadow: none; } @else if $button-style == "outlined" { box-shadow: inset 0 0 0 1px stroke($on-surface); } @else if $button-style == "raised" { box-shadow: $shadow-z2; } @if $button-style != "none" or $on != transparent { background-color: $on; }&:drop(active), &:hover { box-shadow: inset 0 0 0 9999px overlay($hover, $color, $opacity-modifier: $opacity-modifier), if($elevation, $shadow-z4, null);@if $button-style == "flat" { box-shadow: none; } @else if $button-style == "outlined" { box-shadow: inset 0 0 0 1px stroke($on-surface); } @else if $button-style == "raised" { box-shadow: $shadow-z4; } background-color: overlay($hover, $color, $opacity-modifier: $opacity-modifier, $on: $on);} &:focus { box-shadow: inset 0 0 0 9999px overlay("focus", $color, $opacity-modifier: $opacity-modifier), if($elevation, $shadow-z4, null);@if $button-style == "flat" { box-shadow: none; } @else if $button-style == "outlined" { box-shadow: inset 0 0 0 1px stroke($on-surface); } @else if $button-style == "raised" { box-shadow: $shadow-z4; } background-color: overlay("focus", $color, $opacity-modifier: $opacity-modifier, $on: $on);} &:active { @if $elevation {box-shadow: inset 0 0 0 9999px overlay("focus", $color, $opacity-modifier: $opacity-modifier), $shadow-z8;@if $button-style == "flat" { box-shadow: none; } @else if $button-style == "outlined" { box-shadow: inset 0 0 0 1px stroke($on-surface); } @else if $button-style == "raised" { box-shadow: $shadow-z8;} background-image: radial-gradient(circle, overlay("pressed", $color, $opacity-modifier: $opacity-modifier) 10%, transparent 0%);
@mixin list-item { &:drop(active):not(:active), &:hover:not(:active) { transition-property: $ripple-transition-property, box-shadow;transition-property: $ripple-transition-property, background-color;transition-duration: $ripple-transition-duration, 0ms; } }
min-width: 16px; padding: 0; border-radius: 0; background-color: transparent;color: hint($on-panel); @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat");&:disabled { background-color: transparent;color: disabled-hint($on-panel); } &:checked { background-color: overlay("activated", $on-panel);$background-color: overlay("activated", $on-panel);color: $on-panel; @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat", $on: $background-color);&:disabled { background-color: overlay("activated", $on-panel);color: disabled($on-panel); } }
// Adopt Choice chips style stackswitcher.linked > button { @extend %button-flat-activatable;margin: -2px 8px 9px; padding: 0 12px; min-height: 32px; border-radius: $circular-radius; background-color: fill($on-surface);color: hint($on-surface);font-weight: normal; @include ink-color($on-surface, $button-style: "flat", $on: fill($on-surface));&:checked { background-color: overlay("activated", $primary);color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat", $on: overlay("activated", $primary));} &:not(:first-child) {
button.image-button { padding: ($large-size - 24px) / 2; color: hint($on-scrim); @include ink-color($on-scrim);@include ink-color($on-scrim, $button-style: "flat");} }
&.text-button:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} }
&:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} } }
&.error ~ button { color: hint($on-error); @include ink-color($on-error);@include ink-color($on-error, $button-style: "flat");&:disabled { color: disabled-hint($on-error);
&:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} } }
min-width: 16px; padding: 0; // NOTE: Most buttons padding are hard-coded to 0 (except for hide buttons) border-radius: 0; background-color: transparent;color: hint($on-panel); @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat");&:disabled { background-color: transparent;color: disabled-hint($on-panel); } &:checked { background-color: overlay("activated", $on-panel);$background-color: overlay("activated", $on-panel);color: $on-panel; @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat", $on: $background-color);&:disabled { background-color: overlay("activated", $on-panel);color: disabled($on-panel); } }
&:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} } }
&:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} } }
> button > button { padding: 4px 8px; background-size: auto;&:hover {box-shadow: inset 0 0 0 9999px overlay("hover", $on-surface);}&:active { background-image: image(overlay("pressed", $on-surface));background-size: 1000% 1000%;} }
min-width: 16px; padding: 0; border-radius: 0; background-color: transparent;color: hint($on-panel); @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat");&:disabled { background-color: transparent;color: disabled-hint($on-panel); } &:checked { background-color: overlay("activated", $on-panel);$background-color: overlay("activated", $on-panel);color: $on-panel; @include ink-color($on-panel);@include ink-color($on-panel, $button-style: "flat", $on: $background-color);&:disabled { background-color: overlay("activated", $on-panel);color: disabled($on-panel); } }
buttonbox button:not(:disabled) { color: $primary; @include ink-color($primary);@include ink-color($primary, $button-style: "flat");} label#summary {