Skip to content

Commit

Permalink
refactor: theme storage improve usability (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
govza authored Sep 21, 2024
1 parent a7d51c3 commit 41950aa
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export type BaseStorage<D> = {
subscribe: (listener: () => void) => () => void;
};

export type Theme = 'light' | 'dark';

export type ThemeStorage = BaseStorage<Theme> & {
toggle: () => Promise<void>;
};

export type StorageConfig<D = string> = {
/**
* Assign the {@link StorageEnum} to use.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { createStorage } from './base';
import { StorageEnum } from './enums';
import type { Theme, ThemeStorage } from './types';
import { StorageEnum } from '../base/enums';
import { createStorage } from '../base/base';
import type { BaseStorage } from '../base/types';

type Theme = 'light' | 'dark';

type ThemeStorage = BaseStorage<Theme> & {
toggle: () => Promise<void>;
};

const storage = createStorage<Theme>('theme-storage-key', 'light', {
storageEnum: StorageEnum.Local,
Expand Down
1 change: 1 addition & 0 deletions packages/storage/lib/impl/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './exampleThemeStorage';
9 changes: 2 additions & 7 deletions packages/storage/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
import { createStorage } from './base';
import { exampleThemeStorage } from './exampleThemeStorage';
import { SessionAccessLevelEnum, StorageEnum } from './enums';
import type { BaseStorage } from './types';

export { exampleThemeStorage, createStorage, StorageEnum, SessionAccessLevelEnum };
export type { BaseStorage };
export type { BaseStorage } from './base/types';
export * from './impl';

0 comments on commit 41950aa

Please sign in to comment.