From 0993372290d373d5e49a71f78503e37eb1ce8ff8 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Wed, 31 May 2023 18:36:47 +0200 Subject: [PATCH] fix: replace dark mode hack with bootstrap's own dark mode Signed-off-by: Tilman Vatteroth --- frontend/global-styles/dark.scss | 30 ---- frontend/global-styles/highlight-js.scss | 2 +- frontend/global-styles/index.scss | 4 - frontend/global-styles/variables.dark.scss | 134 ------------------ frontend/global-styles/variables.light.scss | 7 - .../loading-screen/loading-screen.tsx | 2 +- .../common/fields/display-name-field.tsx | 1 - .../common/fields/new-password-field.tsx | 1 - .../common/fields/password-again-field.tsx | 1 - .../common/fields/username-field.tsx | 1 - .../highlighted-code/highlighted-code.tsx | 4 +- .../__snapshots__/external-link.spec.tsx.snap | 8 +- .../__snapshots__/internal-link.spec.tsx.snap | 8 +- .../translated-external-link.spec.tsx.snap | 2 +- .../translated-internal-link.spec.tsx.snap | 2 +- .../components/common/links/external-link.tsx | 9 +- .../components/common/links/internal-link.tsx | 9 +- .../__snapshots__/common-modal.spec.tsx.snap | 16 +-- .../deletion-moadal.spec.tsx.snap | 8 +- .../components/common/modals/common-modal.tsx | 2 +- .../common/modals/deletion-modal.tsx | 2 +- .../__snapshots__/motd-modal.spec.tsx.snap | 2 +- .../common/motd-modal/motd-modal.tsx | 2 +- ...nd-additional-configuration-to-renderer.ts | 15 +- .../renderer-iframe/renderer-iframe.tsx | 9 +- .../common/renderer-iframe/style.module.scss | 9 ++ .../editor-page/app-bar/app-bar.tsx | 6 +- .../app-bar/cheatsheet/cheatsheet-button.tsx | 4 +- .../cheatsheet-in-new-tab-button.tsx | 5 +- .../cheatsheet/read-more-link-item.tsx | 2 +- .../app-bar/help-button/help-button.tsx | 4 +- .../app-bar/read-only-mode-button.tsx | 8 +- .../editor-page/app-bar/slide-mode-button.tsx | 4 +- .../editor-pane/status-bar/status-bar.tsx | 2 +- .../emoji-picker/emoji-picker.module.scss | 8 +- .../editor-pane/tool-bar/tool-bar.module.scss | 3 - .../editor-pane/tool-bar/tool-bar.tsx | 3 +- .../editor-pane/tool-bar/toolbar-button.tsx | 3 +- .../sidebar-button/sidebar-button.module.scss | 2 +- .../sidebar/style/sidebar.module.scss | 4 +- .../__snapshots__/splitter.spec.tsx.snap | 44 +++--- .../split-divider/split-divider.module.scss | 13 +- .../splitter/split-divider/split-divider.tsx | 16 ++- .../history-page/entry-menu/entry-menu.tsx | 2 +- .../history-card/history-card.tsx | 22 +-- .../history-table/history-table-row.tsx | 4 +- .../history-table/history-table.tsx | 5 +- .../history-toolbar/clear-history-button.tsx | 2 +- .../history-toolbar/export-history-button.tsx | 2 +- .../history-refresh-button.tsx | 2 +- .../history-toolbar/history-toolbar.tsx | 2 +- .../history-view-mode-toggle-button.tsx | 4 +- .../history-toolbar/import-history-button.tsx | 2 +- .../history-page/pin-button/pin-button.tsx | 2 +- .../history-page/sort-button/sort-button.tsx | 2 +- .../intro-page/intro-custom-content.tsx | 2 - .../landing-layout/footer/footer.tsx | 2 +- .../footer/version-info/version-info-link.tsx | 7 +- .../landing-layout/landing-layout.tsx | 15 +- .../navigation/header-bar/header-bar.tsx | 2 +- .../header-bar/header-nav-link.module.scss | 6 +- .../navigation/header-bar/header-nav-link.tsx | 17 ++- .../settings-dialog/settings-button.tsx | 11 +- .../login-page/auth/fields/password-field.tsx | 1 - .../login-page/auth/fields/username-field.tsx | 1 - .../components/login-page/auth/via-local.tsx | 2 +- .../image-placeholder.module.scss | 2 +- .../image-placeholder/image-placeholder.tsx | 2 +- .../dark-mode/use-apply-dark-mode-style.ts | 11 +- .../use-outline-button-variant.spec.tsx | 29 ++++ .../dark-mode/use-outline-button-variant.ts | 10 ++ frontend/src/pages/_app.tsx | 1 - frontend/src/pages/login.tsx | 2 +- frontend/src/pages/n/[noteId].tsx | 3 + frontend/src/pages/register.tsx | 2 +- frontend/src/pages/render.tsx | 7 +- frontend/src/pages/s/[noteId].tsx | 2 +- 77 files changed, 244 insertions(+), 365 deletions(-) delete mode 100644 frontend/global-styles/dark.scss delete mode 100644 frontend/global-styles/variables.dark.scss create mode 100644 frontend/src/components/common/renderer-iframe/style.module.scss create mode 100644 frontend/src/hooks/dark-mode/use-outline-button-variant.spec.tsx create mode 100644 frontend/src/hooks/dark-mode/use-outline-button-variant.ts diff --git a/frontend/global-styles/dark.scss b/frontend/global-styles/dark.scss deleted file mode 100644 index b698c31fa..000000000 --- a/frontend/global-styles/dark.scss +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - - -body.dark { - @import "variables.dark"; - - /* redefine theme color variables */ - @each $color, $value in $theme-colors { - --#{$prefix}#{$color}: #{$value}; - } - - $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value"); - - @each $color, $value in $theme-colors-rgb { - --#{$prefix}#{$color}-rgb: #{$value}; - } - - --#{$prefix}body-color: #{$body-color}; - --#{$prefix}body-bg: #{$body-bg}; - - @import "colors-only-bootstrap/bootstrap"; - - .btn-close { - filter: invert(1); - } -} diff --git a/frontend/global-styles/highlight-js.scss b/frontend/global-styles/highlight-js.scss index 6f5fd2868..db699a0a4 100644 --- a/frontend/global-styles/highlight-js.scss +++ b/frontend/global-styles/highlight-js.scss @@ -6,6 +6,6 @@ @import '~highlight.js/styles/github'; -body.dark { +[data-bs-theme="dark"] { @import '~highlight.js/styles/github-dark'; } diff --git a/frontend/global-styles/index.scss b/frontend/global-styles/index.scss index fd7a97863..038d62a13 100644 --- a/frontend/global-styles/index.scss +++ b/frontend/global-styles/index.scss @@ -26,10 +26,6 @@ cursor: pointer; } -body { - background-color: $dark; -} - *:focus { outline: 0 !important; } diff --git a/frontend/global-styles/variables.dark.scss b/frontend/global-styles/variables.dark.scss deleted file mode 100644 index 01d757818..000000000 --- a/frontend/global-styles/variables.dark.scss +++ /dev/null @@ -1,134 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -$white: #fff; -$gray-100: #f8f9fa; -$gray-200: #ebebeb; -$gray-300: #dee2e6; -$gray-400: #ced4da; -$gray-500: #adb5bd; -$gray-600: #888; -$gray-700: #444; -$gray-800: #303030; -$gray-900: #222; -$black: #000; - -$blue: #337ab7; -$indigo: #6610f2; -$purple: #6f42c1; -$pink: #e83e8c; -$red: #e74c3c; -$orange: #fd7e14; -$yellow: #f39c12; -$green: #00bc8c; -$teal: #20c997; -$cyan: #5EB7E0; - -$primary: $blue; -$secondary: $white; -$success: $green; -$info: $cyan; -$warning: $yellow; -$danger: $red; -$light: $gray-900; -$dark: $white; - -$yiq-contrasted-threshold: 175; - -// Body -$body-bg: $light; -$body-color: $dark; - -// Links -$link-color: $cyan; - -// Fonts -$text-muted: $gray-400; - -// Tables -$table-accent-bg: $gray-800; -$table-border-color: $gray-700; - -// Forms -$input-border-color: $body-bg; -$input-group-addon-color: $gray-500; -$input-group-addon-bg: $gray-700; -$input-bg: $gray-700; -$input-placeholder-color: $gray-500; -$input-color: $white; -$input-disabled-bg: $gray-900; - -$custom-file-color: $gray-500; -$custom-file-border-color: $body-bg; - -// Dropdowns -$dropdown-bg: $gray-900; -$dropdown-border-color: $gray-700; -$dropdown-divider-bg: $gray-700; -$dropdown-link-color: $white; -$dropdown-link-hover-color: $white; -$dropdown-link-hover-bg: $primary; - -// Navs -$nav-link-disabled-color: $gray-500; -$nav-tabs-border-color: $gray-700; -$nav-tabs-link-hover-border-color: $nav-tabs-border-color $nav-tabs-border-color transparent; -$nav-tabs-link-active-color: $white; -$nav-tabs-link-active-border-color: $nav-tabs-border-color $nav-tabs-border-color transparent; - -// Navbar -$navbar-dark-color: rgba($white, .6); -$navbar-dark-hover-color: $white; -$navbar-light-color: rgba($gray-900, .7); -$navbar-light-hover-color: $gray-900; -$navbar-light-active-color: $gray-900; -$navbar-light-toggler-border-color: rgba($gray-900, .1); - -// Jumbotron -$jumbotron-bg: $gray-800; - -// Cards -$card-cap-bg: $gray-700; -$card-bg: $gray-800; - -// Popovers -$popover-bg: $gray-800; -$popover-header-bg: $gray-700; - -// Toasts -$toast-background-color: $gray-700; -$toast-header-background-color: $gray-800; - -// Modals -$modal-content-color: $dark; -$modal-content-bg: $gray-800; -$modal-content-border-color: $gray-700; -$modal-header-border-color: $gray-700; - -// Progress bars -$progress-bg: $gray-700; - -// List group -$list-group-bg: $gray-800; -$list-group-border-color: $gray-700; -$list-group-hover-bg: $gray-700; -$list-group-action-hover-color: $white; - -// Breadcrumbs -$breadcrumb-bg: $gray-700; - -// Close -$close-color: $white; -$close-text-shadow: none; - -// Code -$pre-color: $dark; - -$list-group-color: $dark; - -@import "~bootstrap/scss/functions"; -@import "~bootstrap/scss/mixins"; -@import "~bootstrap/scss/variables"; diff --git a/frontend/global-styles/variables.light.scss b/frontend/global-styles/variables.light.scss index 253fde3a3..d734051f3 100644 --- a/frontend/global-styles/variables.light.scss +++ b/frontend/global-styles/variables.light.scss @@ -7,10 +7,3 @@ $blue: #337ab7 !default; $cyan: #5EB7E0 !default; $dark: #222222 !default; - -@import "~bootstrap/scss/functions"; -@import "~bootstrap/scss/mixins"; -@import "~bootstrap/scss/variables"; - -$toast-background-color: $white; - diff --git a/frontend/src/components/application-loader/loading-screen/loading-screen.tsx b/frontend/src/components/application-loader/loading-screen/loading-screen.tsx index 732129230..fb274dc93 100644 --- a/frontend/src/components/application-loader/loading-screen/loading-screen.tsx +++ b/frontend/src/components/application-loader/loading-screen/loading-screen.tsx @@ -21,7 +21,7 @@ export interface LoadingScreenProps { */ export const LoadingScreen: React.FC = ({ errorMessage }) => { return ( -
+
diff --git a/frontend/src/components/common/fields/display-name-field.tsx b/frontend/src/components/common/fields/display-name-field.tsx index 1f8357614..79b3cbebf 100644 --- a/frontend/src/components/common/fields/display-name-field.tsx +++ b/frontend/src/components/common/fields/display-name-field.tsx @@ -38,7 +38,6 @@ export const DisplayNameField: React.FC = ({ onChange, va isValid={isValid} onChange={onChange} placeholder={t('profile.displayName') ?? undefined} - className='bg-dark text-light' autoComplete='name' required /> diff --git a/frontend/src/components/common/fields/new-password-field.tsx b/frontend/src/components/common/fields/new-password-field.tsx index c182e787e..f5eb03d16 100644 --- a/frontend/src/components/common/fields/new-password-field.tsx +++ b/frontend/src/components/common/fields/new-password-field.tsx @@ -33,7 +33,6 @@ export const NewPasswordField: React.FC = ({ onChange, value, isInvalid={hasError} onChange={onChange} placeholder={t('login.auth.password') ?? undefined} - className='bg-dark text-light' autoComplete='new-password' required /> diff --git a/frontend/src/components/common/fields/password-again-field.tsx b/frontend/src/components/common/fields/password-again-field.tsx index 40202f752..092a61e11 100644 --- a/frontend/src/components/common/fields/password-again-field.tsx +++ b/frontend/src/components/common/fields/password-again-field.tsx @@ -47,7 +47,6 @@ export const PasswordAgainField: React.FC = ({ isValid={isValid} onChange={onChange} placeholder={t('login.register.passwordAgain') ?? undefined} - className='bg-dark text-light' autoComplete='new-password' required /> diff --git a/frontend/src/components/common/fields/username-field.tsx b/frontend/src/components/common/fields/username-field.tsx index 4edf0b548..917b909fb 100644 --- a/frontend/src/components/common/fields/username-field.tsx +++ b/frontend/src/components/common/fields/username-field.tsx @@ -33,7 +33,6 @@ export const UsernameField: React.FC = ({ onChange, value }) = isValid={isValid} onChange={onChange} placeholder={t('login.auth.username') ?? undefined} - className='bg-dark text-light' autoComplete='username' autoFocus={true} required diff --git a/frontend/src/components/common/highlighted-code/highlighted-code.tsx b/frontend/src/components/common/highlighted-code/highlighted-code.tsx index 9333e93a3..561a9eb07 100644 --- a/frontend/src/components/common/highlighted-code/highlighted-code.tsx +++ b/frontend/src/components/common/highlighted-code/highlighted-code.tsx @@ -3,11 +3,11 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { AsyncLoadingBoundary } from '../../../components/common/async-loading-boundary/async-loading-boundary' -import { CopyToClipboardButton } from '../../../components/common/copyable/copy-to-clipboard-button/copy-to-clipboard-button' import { concatCssClasses } from '../../../utils/concat-css-classes' import { cypressAttribute, cypressId } from '../../../utils/cypress-attribute' import { testId } from '../../../utils/test-id' +import { AsyncLoadingBoundary } from '../async-loading-boundary/async-loading-boundary' +import { CopyToClipboardButton } from '../copyable/copy-to-clipboard-button/copy-to-clipboard-button' import styles from './highlighted-code.module.scss' import { useAsyncHighlightJsImport } from './hooks/use-async-highlight-js-import' import { useAttachLineNumbers } from './hooks/use-attach-line-numbers' diff --git a/frontend/src/components/common/links/__snapshots__/external-link.spec.tsx.snap b/frontend/src/components/common/links/__snapshots__/external-link.spec.tsx.snap index 191a471cd..f605a4bea 100644 --- a/frontend/src/components/common/links/__snapshots__/external-link.spec.tsx.snap +++ b/frontend/src/components/common/links/__snapshots__/external-link.spec.tsx.snap @@ -3,7 +3,7 @@ exports[`ExternalLink renders an external link correctly 1`] = `
testText @@ -14,7 +14,7 @@ exports[`InternalLink renders an internal link correctly 1`] = ` exports[`InternalLink renders an internal link with a title 1`] = `
@@ -37,7 +37,7 @@ exports[`InternalLink renders an internal link with additional className 1`] = ` exports[`InternalLink renders an internal link with an icon 1`] = `
BootstrapIconMock_Heart @@ -50,7 +50,7 @@ exports[`InternalLink renders an internal link with an icon 1`] = ` exports[`InternalLink renders an internal link with an id 1`] = `
diff --git a/frontend/src/components/common/links/__snapshots__/translated-external-link.spec.tsx.snap b/frontend/src/components/common/links/__snapshots__/translated-external-link.spec.tsx.snap index baaebbd31..5f46c1dc7 100644 --- a/frontend/src/components/common/links/__snapshots__/translated-external-link.spec.tsx.snap +++ b/frontend/src/components/common/links/__snapshots__/translated-external-link.spec.tsx.snap @@ -3,7 +3,7 @@ exports[`TranslatedExternalLink renders with i18nKey 1`] = `
testi18nKey diff --git a/frontend/src/components/common/links/external-link.tsx b/frontend/src/components/common/links/external-link.tsx index 8cd6e4927..8a1cb2fb8 100644 --- a/frontend/src/components/common/links/external-link.tsx +++ b/frontend/src/components/common/links/external-link.tsx @@ -19,14 +19,7 @@ import React from 'react' * @param className Additional class names added to the link object * @param title The title of the link */ -export const ExternalLink: React.FC = ({ - href, - text, - icon, - id, - className = 'text-light', - title -}) => { +export const ExternalLink: React.FC = ({ href, text, icon, id, className = '', title }) => { return ( diff --git a/frontend/src/components/common/links/internal-link.tsx b/frontend/src/components/common/links/internal-link.tsx index b6bffc2c5..4475c8d0c 100644 --- a/frontend/src/components/common/links/internal-link.tsx +++ b/frontend/src/components/common/links/internal-link.tsx @@ -19,14 +19,7 @@ import React from 'react' * @param className Additional class names added to the link object * @param title The title of the link */ -export const InternalLink: React.FC = ({ - href, - text, - icon, - id, - className = 'text-light', - title -}) => { +export const InternalLink: React.FC = ({ href, text, icon, id, className = '', title }) => { return ( diff --git a/frontend/src/components/common/modals/__snapshots__/common-modal.spec.tsx.snap b/frontend/src/components/common/modals/__snapshots__/common-modal.spec.tsx.snap index a796c2ac8..2f3a11e8e 100644 --- a/frontend/src/components/common/modals/__snapshots__/common-modal.spec.tsx.snap +++ b/frontend/src/components/common/modals/__snapshots__/common-modal.spec.tsx.snap @@ -4,7 +4,7 @@ exports[`CommonModal does not render if show is false 1`] = `
`; exports[`CommonModal render correctly in size lg 1`] = `