1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-14351] Migrate away from theme enum (#11812)

* update extension autofill concerns to use theme object and type over enum

* mark ThemeType enum as deprecated

* update theming service concerns to use theme object and type over enum
This commit is contained in:
Jonathan Prusik
2024-10-31 16:46:25 -04:00
committed by GitHub
parent eb67b73a09
commit eba1212e1c
10 changed files with 56 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
import { EVENTS } from "@bitwarden/common/autofill/constants";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { setElementStyles } from "../../../utils";
import {
@@ -210,19 +210,19 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
const { theme } = message;
let borderColor: string;
let verifiedTheme = theme;
if (verifiedTheme === ThemeType.System) {
if (verifiedTheme === ThemeTypes.System) {
verifiedTheme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}
if (verifiedTheme === ThemeType.Dark) {
if (verifiedTheme === ThemeTypes.Dark) {
borderColor = "#4c525f";
}
if (theme === ThemeType.Nord) {
if (theme === ThemeTypes.Nord) {
borderColor = "#2E3440";
}
if (theme === ThemeType.SolarizedDark) {
if (theme === ThemeTypes.SolarizedDark) {
borderColor = "#073642";
}
if (borderColor) {

View File

@@ -1,7 +1,9 @@
import { Theme } from "@bitwarden/common/platform/enums";
type NotificationBarIframeInitData = {
type?: string;
isVaultLocked?: boolean;
theme?: string;
theme?: Theme;
removeIndividualVault?: boolean;
importType?: string;
applyRedesign?: boolean;

View File

@@ -1,4 +1,4 @@
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import type { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
@@ -392,10 +392,10 @@ function setupLogoLink(i18n: Record<string, string>) {
function setNotificationBarTheme() {
let theme = notificationBarIframeInitData.theme;
if (theme === ThemeType.System) {
if (theme === ThemeTypes.System) {
theme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}
document.documentElement.classList.add(`theme_${theme}`);

View File

@@ -1,5 +1,5 @@
import { EVENTS } from "@bitwarden/common/autofill/constants";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { sendExtensionMessage, setElementStyles } from "../../../utils";
import {
@@ -239,19 +239,19 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
const { theme } = message;
let borderColor: string;
let verifiedTheme = theme;
if (verifiedTheme === ThemeType.System) {
if (verifiedTheme === ThemeTypes.System) {
verifiedTheme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}
if (verifiedTheme === ThemeType.Dark) {
if (verifiedTheme === ThemeTypes.Dark) {
borderColor = "#4c525f";
}
if (theme === ThemeType.Nord) {
if (theme === ThemeTypes.Nord) {
borderColor = "#2E3440";
}
if (theme === ThemeType.SolarizedDark) {
if (theme === ThemeTypes.SolarizedDark) {
borderColor = "#073642";
}
if (borderColor) {

View File

@@ -1,6 +1,8 @@
import { Theme } from "@bitwarden/common/platform/enums";
export type NotificationTypeData = {
isVaultLocked?: boolean;
theme?: string;
theme?: Theme;
removeIndividualVault?: boolean;
importType?: string;
launchTimestamp?: number;

View File

@@ -2,7 +2,7 @@ import { mock } from "jest-mock-extended";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { UriMatchStrategy } from "@bitwarden/common/models/domain/domain-service";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
@@ -210,7 +210,7 @@ export function createInitAutofillInlineMenuListMessageMock(
command: "initAutofillInlineMenuList",
translations: overlayPagesTranslations,
styleSheetUrl: "https://jest-testing-website.com",
theme: ThemeType.Light,
theme: ThemeTypes.Light,
authStatus: AuthenticationStatus.Unlocked,
portKey: "portKey",
inlineMenuFillType: CipherType.Login,