diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 38e683c5e0..7ce9ef45d6 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -4843,5 +4843,11 @@ }, "generatedPassword": { "message": "Generated password" + }, + "compactMode": { + "message": "Compact mode" + }, + "beta": { + "message": "Beta" } } diff --git a/apps/browser/src/platform/popup/layout/popup-compact-mode.service.ts b/apps/browser/src/platform/popup/layout/popup-compact-mode.service.ts new file mode 100644 index 0000000000..ffcd2321b1 --- /dev/null +++ b/apps/browser/src/platform/popup/layout/popup-compact-mode.service.ts @@ -0,0 +1,31 @@ +import { inject, Injectable } from "@angular/core"; +import { map, Observable } from "rxjs"; + +import { GlobalStateProvider, KeyDefinition, THEMING_DISK } from "@bitwarden/common/platform/state"; +import { CompactModeService } from "@bitwarden/components"; + +const COMPACT_MODE = new KeyDefinition(THEMING_DISK, "compactMode", { + deserializer: (s) => s, +}); + +/** + * Service to persist Compact Mode to state / user settings. + **/ +@Injectable({ providedIn: "root" }) +export class PopupCompactModeService implements CompactModeService { + private state = inject(GlobalStateProvider).get(COMPACT_MODE); + + enabled$: Observable = this.state.state$.pipe(map((state) => state ?? false)); + + init() { + this.enabled$.subscribe((enabled) => { + enabled + ? document.body.classList.add("tw-bit-compact") + : document.body.classList.remove("tw-bit-compact"); + }); + } + + async setEnabled(enabled: boolean) { + await this.state.update(() => enabled); + } +} diff --git a/apps/browser/src/platform/popup/layout/popup-footer.component.html b/apps/browser/src/platform/popup/layout/popup-footer.component.html index f60964b139..50ad535c89 100644 --- a/apps/browser/src/platform/popup/layout/popup-footer.component.html +++ b/apps/browser/src/platform/popup/layout/popup-footer.component.html @@ -1,7 +1,7 @@