diff --git a/stylesheets/_mixins.scss b/stylesheets/_mixins.scss index 60e8fa5c1b8c..8af70dbcbe31 100644 --- a/stylesheets/_mixins.scss +++ b/stylesheets/_mixins.scss @@ -140,6 +140,13 @@ } } +@mixin any-theme { + &, + .dark-theme & { + @content; + } +} + // Utilities @mixin rounded-corners() { diff --git a/stylesheets/components/LeftPaneDialog.scss b/stylesheets/components/LeftPaneDialog.scss index 8663d73340be..0085ddb5f496 100644 --- a/stylesheets/components/LeftPaneDialog.scss +++ b/stylesheets/components/LeftPaneDialog.scss @@ -186,45 +186,65 @@ } } - &--error { - background-color: $error-background-color; - color: $error-text-color; - - a { - color: $error-text-color; - } - - .LeftPaneDialog__action-text { - color: $error-text-color; - } + &__tooltip { + --tooltip-background-color: #{$default-background-color}; + --tooltip-text-color: #{$default-text-color}; + min-width: 280px; + text-align: inherit; } - &--warning { - background-color: $warning-background-color; - color: $warning-text-color; + &, + &__tooltip { + &--error { + background-color: $error-background-color; + color: $error-text-color; - a { - color: $color-black; - } + @include any-theme { + --tooltip-background-color: #{$error-background-color}; + --tooltip-text-color: #{$error-text-color}; + } - .LeftPaneDialog__icon { - background-color: $color-black; + a { + color: $error-text-color; + } - @media (forced-colors: active) { - background-color: WindowText; + .LeftPaneDialog__action-text { + color: $error-text-color; } } - .LeftPaneDialog__close-button::before { - background-color: $color-black; - - @media (forced-colors: active) { - background-color: WindowText; - } - } - - .LeftPaneDialog__action-text { + &--warning { + background-color: $warning-background-color; color: $warning-text-color; + + @include any-theme { + --tooltip-background-color: #{$warning-background-color}; + --tooltip-text-color: #{$warning-text-color}; + } + + a { + color: $warning-text-color; + } + + .LeftPaneDialog__icon { + background-color: $warning-text-color; + + @media (forced-colors: active) { + background-color: WindowText; + } + } + + .LeftPaneDialog__close-button::before { + background-color: $warning-text-color; + + @media (forced-colors: active) { + background-color: WindowText; + } + } + + .LeftPaneDialog__action-text { + color: $warning-text-color; + } } } @@ -266,25 +286,4 @@ transition: transform 500ms ease-out; } } - - &__tooltip { - --tooltip-background-color: #{$default-background-color}; - --tooltip-text-color: #{$default-text-color}; - min-width: 280px; - text-align: inherit; - - &--error { - --tooltip-text-color: #{$error-text-color}; - --tooltip-background-color: #{$error-background-color}; - - a { - color: #{$error-text-color}; - } - } - - &--warning { - --tooltip-text-color: #{$warning-text-color}; - --tooltip-background-color: #{$warning-background-color}; - } - } } diff --git a/ts/components/LeftPaneDialog.stories.tsx b/ts/components/LeftPaneDialog.stories.tsx new file mode 100644 index 000000000000..810c7fbfa13a --- /dev/null +++ b/ts/components/LeftPaneDialog.stories.tsx @@ -0,0 +1,133 @@ +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import React from 'react'; +import { LeftPaneDialog } from './LeftPaneDialog'; +import { WidthBreakpoint } from './_util'; + +const widths = { + [WidthBreakpoint.Wide]: '400px', + [WidthBreakpoint.Medium]: '300px', + [WidthBreakpoint.Narrow]: '100px', +}; + +// eslint-disable-next-line max-len +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any +function WidthDecorator(Story: any, context: any): JSX.Element { + return ( +
+ +
+ ); +} + +export default { + title: 'Components/LeftPaneDialog', + component: LeftPaneDialog, + decorators: [WidthDecorator], + argTypes: { + type: { + options: [undefined, 'warning', 'error'], + type: 'select', + }, + icon: { + options: [undefined, 'update', 'relink', 'network', 'warning'], + type: 'select', + }, + title: { + control: 'text', + }, + subtitle: { + control: 'text', + }, + hoverText: { + control: 'text', + defaultValue: + 'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.', + }, + hasXButton: { + control: 'boolean', + }, + hasAction: { + control: 'boolean', + }, + containerWidthBreakpoint: { + options: Object.keys(WidthBreakpoint), + mapping: WidthBreakpoint, + type: 'select', + }, + }, + args: { + title: 'Lorem ipsum dolor sit amet', + subtitle: + 'Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', + hasXButton: true, + hasAction: true, + onClick: (): null => null, + clickLabel: 'Click me', + containerWidthBreakpoint: WidthBreakpoint.Wide, + }, +}; + +export const Update = { + args: { + type: undefined, + icon: 'update', + }, +}; + +export const Warning = { + args: { + type: 'warning', + icon: 'warning', + }, +}; + +export const Error = { + args: { + type: 'error', + icon: 'warning', + }, +}; + +export const Relink = { + args: { + type: undefined, + icon: 'relink', + }, +}; + +export const Network = { + args: { + type: 'warning', + icon: 'network', + }, +}; + +export const NarrowUpdate = { + args: { + type: undefined, + icon: 'update', + containerWidthBreakpoint: WidthBreakpoint.Narrow, + }, +}; + +export const NarrowWarning = { + args: { + type: 'warning', + icon: 'warning', + containerWidthBreakpoint: WidthBreakpoint.Narrow, + }, +}; + +export const NarrowError = { + args: { + type: 'error', + icon: 'warning', + containerWidthBreakpoint: WidthBreakpoint.Narrow, + }, +};