-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { Shuffle as ShuffleItem } from './shuffle'; | ||
export { Share as ShareItem } from './share'; | ||
export { Donate as DonateItem } from './donate'; | ||
export { Notepad as NotepadItem } from './notepad'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { MdNotes } from 'react-icons/md/index'; | ||
|
||
import { Item } from '../item'; | ||
|
||
interface NotepadProps { | ||
open: () => void; | ||
} | ||
|
||
export function Notepad({ open }: NotepadProps) { | ||
return <Item icon={<MdNotes />} label="Notepad" onClick={open} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Notepad } from './notepad'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Notepad } from './notepad'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin-bottom: 8px; | ||
|
||
& .label { | ||
font-size: var(--font-sm); | ||
font-weight: 500; | ||
color: var(--color-foreground-subtle); | ||
} | ||
} | ||
|
||
.textarea { | ||
width: 100%; | ||
height: 350px; | ||
padding: 12px; | ||
line-height: 1.6; | ||
color: var(--color-foreground-subtle); | ||
resize: none; | ||
background-color: var(--color-neutral-50); | ||
border: 1px solid var(--color-neutral-200); | ||
border-radius: 4px; | ||
outline: none; | ||
scroll-padding-bottom: 12px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Modal } from '@/components/modal'; | ||
|
||
import styles from './notepad.module.css'; | ||
import { useNoteStore } from '@/store'; | ||
|
||
interface NotepadProps { | ||
onClose: () => void; | ||
show: boolean; | ||
} | ||
|
||
export function Notepad({ onClose, show }: NotepadProps) { | ||
const note = useNoteStore(state => state.note); | ||
const write = useNoteStore(state => state.write); | ||
|
||
return ( | ||
<Modal show={show} wide onClose={onClose}> | ||
<header className={styles.header}> | ||
<h2 className={styles.label}>Your Note</h2> | ||
</header> | ||
|
||
<textarea | ||
className={styles.textarea} | ||
dir="auto" | ||
value={note} | ||
onChange={e => write(e.target.value)} | ||
/> | ||
</Modal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { useSoundStore } from './sound'; | ||
export { useLoadingStore } from './loading'; | ||
export { useNoteStore } from './note'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { create } from 'zustand'; | ||
import { createJSONStorage, persist } from 'zustand/middleware'; | ||
import merge from 'deepmerge'; | ||
|
||
import { type NoteState, createState } from './note.state'; | ||
import { type NoteActions, createActions } from './note.actions'; | ||
|
||
export const useNoteStore = create<NoteState & NoteActions>()( | ||
persist( | ||
(...a) => ({ | ||
...createState(...a), | ||
...createActions(...a), | ||
}), | ||
{ | ||
merge: (persisted, current) => | ||
merge( | ||
current, | ||
// @ts-ignore | ||
persisted, | ||
), | ||
name: 'moodist-note', | ||
partialize: state => ({ note: state.note }), | ||
skipHydration: true, | ||
storage: createJSONStorage(() => localStorage), | ||
version: 0, | ||
}, | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { StateCreator } from 'zustand'; | ||
|
||
import type { NoteState } from './note.state'; | ||
|
||
export interface NoteActions { | ||
write: (note: string) => void; | ||
} | ||
|
||
export const createActions: StateCreator< | ||
NoteActions & NoteState, | ||
[], | ||
[], | ||
NoteActions | ||
> = set => { | ||
return { | ||
write(note) { | ||
set({ note }); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { StateCreator } from 'zustand'; | ||
|
||
import type { NoteActions } from './note.actions'; | ||
|
||
export interface NoteState { | ||
history: string | null; | ||
note: string; | ||
} | ||
|
||
export const createState: StateCreator< | ||
NoteState & NoteActions, | ||
[], | ||
[], | ||
NoteState | ||
> = () => ({ | ||
history: null, | ||
note: '', | ||
}); |