signal-desktop/stylesheets/components/Button.scss

374 lines
8.3 KiB
SCSS
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2024-11-15 23:09:31 +00:00
@use 'sass:color';
@use '../mixins';
@use '../variables';
.module-Button {
@mixin focus-box-shadow($inner-color, $outer-color) {
&:focus {
2024-07-24 00:31:40 +00:00
box-shadow:
0 0 0 1px $inner-color,
0 0 0 4px $outer-color;
}
}
@mixin hover-and-active-states($background-color, $mix-color) {
2023-03-20 22:23:53 +00:00
&:hover {
2024-11-15 23:09:31 +00:00
@include mixins.not-disabled {
background: color.mix($background-color, $mix-color, 85%);
2023-03-20 22:23:53 +00:00
}
}
2023-03-20 22:23:53 +00:00
&:active {
2024-11-15 23:09:31 +00:00
@include mixins.not-disabled {
background: color.mix($background-color, $mix-color, 75%);
2023-03-20 22:23:53 +00:00
}
}
}
2024-11-15 23:09:31 +00:00
@include mixins.button-reset;
& {
border-radius: 4px;
padding-block: 8px;
padding-inline: 16px;
text-align: center;
user-select: none;
-webkit-app-region: no-drag;
}
2024-11-15 23:09:31 +00:00
@include mixins.keyboard-mode {
@include focus-box-shadow(
variables.$color-white,
variables.$color-ultramarine
);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-keyboard-mode {
@include focus-box-shadow(
variables.$color-black,
variables.$color-ultramarine
);
}
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
cursor: not-allowed;
}
&--large {
2024-11-15 23:09:31 +00:00
@include mixins.font-title-2;
font-weight: bold;
}
&--medium {
2024-11-15 23:09:31 +00:00
@include mixins.font-body-1-bold;
}
&--small {
2024-11-15 23:09:31 +00:00
@include mixins.font-body-2;
@include mixins.rounded-corners;
2023-04-20 17:03:43 +00:00
padding-block: 6px;
padding-inline: 12px;
}
&--primary {
2024-11-15 23:09:31 +00:00
$color: variables.$color-white;
$background-color: variables.$color-ultramarine;
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: color.adjust($color, $alpha: -0.4);
background: color.adjust($background-color, $alpha: -0.6);
}
&--discouraged {
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
opacity: 0.4;
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
opacity: 0.5;
}
}
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
@include hover-and-active-states(
$background-color,
variables.$color-black
);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
@include hover-and-active-states(
$background-color,
variables.$color-white
);
}
}
&--secondary {
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
$color: variables.$color-gray-90;
$background-color: variables.$color-gray-05;
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: variables.$color-black-alpha-40;
background: color.adjust($background-color, $alpha: -0.6);
}
&--affirmative {
2024-11-15 23:09:31 +00:00
color: variables.$color-ultramarine;
}
&--affirmative--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust(variables.$color-ultramarine, $alpha: -0.5);
}
&--destructive {
2024-11-15 23:09:31 +00:00
color: variables.$color-accent-red;
}
&--destructive--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust(variables.$color-ultramarine, $alpha: -0.5);
}
2024-11-15 23:09:31 +00:00
@include hover-and-active-states(
$background-color,
variables.$color-black
);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
$color: variables.$color-gray-05;
$background-color: variables.$color-gray-65;
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: variables.$color-white-alpha-20;
background: color.adjust($background-color, $alpha: -0.6);
}
&--affirmative {
2024-11-15 23:09:31 +00:00
color: variables.$color-ultramarine-light;
}
&--affirmative--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust(variables.$color-ultramarine-light, $alpha: -0.5);
}
&--destructive {
2024-11-15 23:09:31 +00:00
color: variables.$color-accent-red;
}
&--destructive--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust(variables.$color-accent-red, $alpha: -0.5);
}
2024-11-15 23:09:31 +00:00
@include hover-and-active-states(
$background-color,
variables.$color-white
);
}
}
&--destructive {
2024-11-15 23:09:31 +00:00
$color: variables.$color-white;
$background-color: variables.$color-accent-red;
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: color.adjust($color, $alpha: -0.4);
background: color.adjust($background-color, $alpha: -0.6);
}
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
@include hover-and-active-states(
$background-color,
variables.$color-black
);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
@include hover-and-active-states(
$background-color,
variables.$color-white
);
}
}
&--calling {
2024-11-15 23:09:31 +00:00
$color: variables.$color-white;
$background-color: variables.$color-accent-green;
2024-11-15 23:09:31 +00:00
@include mixins.rounded-corners;
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: color.adjust($color, $alpha: -0.4);
background: color.adjust($background-color, $alpha: -0.6);
}
&--discouraged {
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
opacity: 0.4;
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
opacity: 0.5;
}
}
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
@include hover-and-active-states(
$background-color,
variables.$color-black
);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
@include hover-and-active-states(
$background-color,
variables.$color-white
);
}
}
2021-08-26 20:51:55 +00:00
&--system-message {
2024-11-15 23:09:31 +00:00
@include mixins.rounded-corners;
2021-08-26 20:51:55 +00:00
&.module-Button--small {
2023-04-20 17:03:43 +00:00
padding-top: 5px;
padding-bottom: 5px;
font-weight: 500;
}
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
$color: variables.$color-ultramarine;
$background-color: variables.$color-gray-02;
2021-08-26 20:51:55 +00:00
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: color.adjust($color, $alpha: -0.4);
background: color.adjust($background-color, $alpha: -0.6);
2021-08-26 20:51:55 +00:00
}
&--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust($color, $alpha: -0.5);
}
2024-11-15 23:09:31 +00:00
@include hover-and-active-states(
$background-color,
variables.$color-black
);
2021-08-26 20:51:55 +00:00
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
$color: variables.$color-white;
$background-color: variables.$color-gray-65;
2021-08-26 20:51:55 +00:00
color: $color;
background: $background-color;
2024-11-15 23:09:31 +00:00
@include mixins.disabled {
color: color.adjust($color, $alpha: -0.4);
background: color.adjust($background-color, $alpha: -0.6);
2021-08-26 20:51:55 +00:00
}
&--discouraged {
2024-11-15 23:09:31 +00:00
color: color.adjust($color, $alpha: -0.5);
}
2024-11-15 23:09:31 +00:00
@include hover-and-active-states(
$background-color,
variables.$color-white
);
2021-08-26 20:51:55 +00:00
}
}
&--details {
align-items: center;
border-radius: 8px;
display: flex;
flex-direction: column;
font-size: 11px;
justify-content: center;
line-height: 10px;
min-height: 44px;
min-width: 68px;
padding: 8px;
&--discouraged {
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
opacity: 0.4;
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
opacity: 0.5;
}
}
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
background-color: variables.$color-gray-05;
color: variables.$color-black;
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
background-color: variables.$color-gray-65;
color: variables.$color-gray-05;
}
&:focus {
2024-11-15 23:09:31 +00:00
@include mixins.keyboard-mode {
box-shadow: 0 0 0 2px variables.$color-ultramarine;
2021-10-21 21:04:43 +00:00
}
}
&::before {
margin-bottom: 6px;
}
}
&--icon {
@mixin button-icon($icon) {
content: '';
display: block;
height: 18px;
width: 18px;
2024-11-15 23:09:31 +00:00
@include mixins.light-theme {
@include mixins.color-svg($icon, variables.$color-black);
}
2024-11-15 23:09:31 +00:00
@include mixins.dark-theme {
@include mixins.color-svg($icon, variables.$color-gray-05);
}
}
&--audio::before {
2023-05-04 18:04:22 +00:00
@include button-icon('../images/icons/v3/phone/phone-compact.svg');
}
2023-08-09 00:53:06 +00:00
&--message::before {
@include button-icon('../images/icons/v3/chat/chat-compact.svg');
}
&--muted::before {
2023-05-04 18:04:22 +00:00
@include button-icon('../images/icons/v3/bell/bell-slash-compact.svg');
}
&--search::before {
2023-05-04 18:04:22 +00:00
@include button-icon('../images/icons/v3/search/search-compact.svg');
}
&--unmuted::before {
2023-05-04 18:04:22 +00:00
@include button-icon('../images/icons/v3/bell/bell-compact.svg');
}
&--video::before {
2023-05-04 18:04:22 +00:00
@include button-icon('../images/icons/v3/video/video-compact.svg');
}
}
}