-
Notifications
You must be signed in to change notification settings - Fork 1
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
13 changed files
with
174 additions
and
234 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import useMouseStore from '../store/index.js'; | ||
import { FollowerInitialiserComponent } from './follower_init.js'; | ||
|
||
export function Follower() { | ||
const { options } = useMouseStore((state) => ({ options: state.curSettings })); | ||
return <FollowerInitialiserComponent options={options} />; | ||
} |
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 +1,2 @@ | ||
export * from './update_follower.js'; | ||
export * from './follower.js'; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,13 +1,14 @@ | ||
import { useContext } from 'react'; | ||
import { MousePropertiesContext } from '../context/mouse.context.js'; | ||
import useMouseStore from '../store/index.js'; | ||
|
||
export function useControlOptions() { | ||
const { addLayer, removeLayer, clearStack, logStack, peekStack } = useContext(MousePropertiesContext); | ||
const store = useMouseStore((state) => ({ | ||
addOptionLayer: state.pushLayer, | ||
removePreviousLayer: state.popLayer, | ||
clearLayers: state.clearLayers, | ||
})); | ||
|
||
return { | ||
addOptionLayer: addLayer, | ||
removePreviousLayer: removeLayer, | ||
clearLayers: clearStack, | ||
logLayers: logStack, | ||
topLayer: peekStack, | ||
// logLayers: logStack, | ||
...store, | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
export * from './component/index.js'; | ||
export * from './context/index.js'; | ||
export * from './hook/index.js'; |
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,42 @@ | ||
import { create } from 'zustand'; | ||
import { MouseSettings } from '../types/index.js'; | ||
|
||
const defaultSettings: MouseSettings = { | ||
radius: 12 / 2, | ||
}; | ||
|
||
interface useMouseStoreInterface { | ||
curSettings: MouseSettings; | ||
layers: [MouseSettings]; | ||
|
||
pushLayer: (newLayer: MouseSettings) => void; | ||
popLayer: () => void; | ||
clearLayers: () => void; | ||
} | ||
|
||
const useMouseStore = create<useMouseStoreInterface>((set) => ({ | ||
curSettings: defaultSettings, | ||
layers: [defaultSettings], | ||
|
||
pushLayer: (newLayer: MouseSettings) => | ||
set((state) => { | ||
const newCur = { ...state.curSettings, ...newLayer }; | ||
state.layers.push(newCur); | ||
return { layers: state.layers, curSettings: newCur }; | ||
}), | ||
popLayer: () => | ||
set((state) => { | ||
if (state.layers.length > 1) { | ||
state.layers.pop(); | ||
return { layers: state.layers, curSettings: state.layers.at(state.layers.length - 1) }; | ||
} else { | ||
return { layers: [defaultSettings], curSettings: defaultSettings }; | ||
} | ||
}), | ||
clearLayers: () => | ||
set((state) => { | ||
return { layers: [defaultSettings], curSettings: defaultSettings }; | ||
}), | ||
})); | ||
|
||
export default useMouseStore; |
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
Oops, something went wrong.