-
Notifications
You must be signed in to change notification settings - Fork 31
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
4 changed files
with
54 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux"; | ||
import counterReducer from "./counter"; | ||
import notesReducer from "./notes"; | ||
|
||
const store = configureStore({ | ||
reducer: { | ||
counter: counterReducer, | ||
notes: notesReducer, | ||
}, | ||
}); | ||
|
||
export type AppState = ReturnType<typeof store.getState>; | ||
export type AppDispatch = typeof store.dispatch; | ||
type AppState = ReturnType<typeof store.getState>; | ||
type AppDispatch = typeof store.dispatch; | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
export const useAppSelector: TypedUseSelectorHook<AppState> = useSelector; | ||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
|
||
export default store; |
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,24 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
|
||
interface NotesState { | ||
notes: Note[]; | ||
} | ||
|
||
const initialState: NotesState = { | ||
notes: [], | ||
}; | ||
|
||
export const notesSlice = createSlice({ | ||
name: "notes", | ||
initialState, | ||
reducers: { | ||
// add note to notes | ||
addNote: (state, action: PayloadAction<Note>) => { | ||
state.notes = [...state.notes, action.payload]; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { addNote } = notesSlice.actions; | ||
|
||
export default notesSlice.reducer; |
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,3 @@ | ||
type Timestamp = number; | ||
|
||
type UUID = string; |
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,22 @@ | ||
interface Position { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
interface Bounding { | ||
width: number; | ||
height: number; | ||
} | ||
|
||
// Sticky note card data model | ||
interface Note { | ||
id: UUID; | ||
// text content could be markdown or raw text. | ||
content: string; | ||
// card bounding. | ||
bounding: Bounding; | ||
// card relative position. | ||
position: Position; | ||
createdTs: Timestamp; | ||
updatedTs: Timestamp; | ||
} |