# code-block-pro/1.1.0/src/state/theme.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.1.0. 29 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.1.0/code/src/state/theme.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.1.0/raw/src/state/theme.ts
- Modified: 2022-08-22T22:25:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.1.0/code/src/state/theme.ts#L10-L20`.

```typescript
import { Theme } from 'shiki';
import create from 'zustand';
import { devtools, persist } from 'zustand/middleware';

type ThemeType = {
    previousTheme: Theme;
    setPreviousTheme: (theme: Theme) => void;
};
export const useThemeStore = create<ThemeType>()(
    persist(
        devtools(
            (set) => ({
                previousTheme: 'nord',
                setPreviousTheme(theme: Theme) {
                    set({ previousTheme: theme });
                },
            }),
            { name: 'Code Block Pro Theme' },
        ),
        {
            name: 'code-block-pro-last-theme',
            getStorage: () => localStorage,
            partialize: (state) => ({
                previousTheme: state?.previousTheme ?? null,
            }),
        },
    ),
);

```
