Files
5chan/src/hooks/stores/useGeneralStore.js
T

61 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-03-13 14:29:34 +01:00
import { create } from 'zustand';
2023-04-08 13:27:17 +02:00
const useGeneralStore = create((set) => ({
2023-03-13 14:29:34 +01:00
bodyStyle: JSON.parse(localStorage.getItem('bodyStyle')) || {
background: '#ffe url(/assets/fade.png) top repeat-x',
color: 'maroon',
fontFamily: 'Helvetica, Arial, sans-serif',
},
setBodyStyle: (bodyStyle) => {
localStorage.setItem('bodyStyle', JSON.stringify(bodyStyle));
set(() => ({ bodyStyle }));
},
2023-04-07 17:47:51 +02:00
captchaResponse: '',
setCaptchaResponse: (response) => set({ captchaResponse: response }),
challengesArray: [],
setChallengesArray: (challengesArray) => set({ challengesArray }),
2023-03-20 17:08:05 +01:00
defaultSubplebbits: [],
setDefaultSubplebbits: (subplebbits) => set({ defaultSubplebbits: subplebbits }),
2023-04-09 20:55:55 +02:00
isCaptchaOpen: false,
setIsCaptchaOpen: (isOpen) => set({ isCaptchaOpen: isOpen }),
2023-03-20 17:08:05 +01:00
isSettingsOpen: false,
setIsSettingsOpen: (isOpen) => set({ isSettingsOpen: isOpen }),
2023-04-07 17:47:51 +02:00
pendingComment: '',
setPendingComment: (comment) => set({ pendingComment: comment }),
publishedComment: '',
setPublishedComment: (comment) => set({ publishedComment: comment }),
2023-03-20 17:08:05 +01:00
2023-03-13 14:29:34 +01:00
selectedAddress: '',
setSelectedAddress: (address) => set({ selectedAddress: address }),
2023-03-20 17:08:05 +01:00
2023-04-12 21:00:51 +02:00
selectedReply: '',
setSelectedReply: (reply) => set({ selectedReply: reply }),
2023-03-13 14:29:34 +01:00
selectedStyle: localStorage.getItem('selectedStyle') || 'Yotsuba',
setSelectedStyle: (style) => {
localStorage.setItem('selectedStyle', style);
set({ selectedStyle: style });
},
2023-03-20 17:08:05 +01:00
selectedThread: '',
setSelectedThread: (thread) => set({ selectedThread: thread }),
selectedTitle: '',
setSelectedTitle: (title) => set({ selectedTitle: title }),
showPostForm: false,
setShowPostForm: (show) => set({ showPostForm: show }),
showPostFormLink: true,
setShowPostFormLink: (show) => set({ showPostFormLink: show }),
2023-03-13 14:29:34 +01:00
}));
2023-04-08 13:27:17 +02:00
export default useGeneralStore;