-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/add-dsp-presets
- Loading branch information
Showing
10 changed files
with
160 additions
and
4 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
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 @@ | ||
import { useGetDevice } from "src/lib"; | ||
import { MobileControlTouchpanelState } from "src/lib/types/state/state/MobileControlTouchpanelState"; | ||
import { useWebsocketContext } from "src/lib/utils"; | ||
|
||
export function useITheme(touchpanelKey: string):IThemeReturn { | ||
const { sendMessage } = useWebsocketContext(); | ||
const tpState = useGetDevice<MobileControlTouchpanelState>(touchpanelKey); | ||
|
||
const saveTheme = (theme: string) => { | ||
sendMessage(`/device/${touchpanelKey}/saveTheme`, { value: theme }); | ||
} | ||
|
||
return { | ||
currentTheme: tpState?.theme, | ||
saveTheme, | ||
} | ||
} | ||
|
||
interface IThemeReturn { | ||
currentTheme?: string; | ||
saveTheme: (theme: string) => void; | ||
} |
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,36 @@ | ||
import { RefObject, useLayoutEffect, useState } from "react"; | ||
|
||
export function useOverflow<T extends HTMLElement | undefined>(ref:RefObject<T | undefined>, callback?:(hasOverflowVertical: boolean, hasOverflowHorizontal: boolean) => void):UseIsOverflowProps { | ||
const [overflowHorizontal, setOverflowHorizontal] = useState(false); | ||
const [overflowVertical, setOverflowVertical] = useState(false); | ||
|
||
|
||
useLayoutEffect(() => { | ||
const { current } = ref; | ||
|
||
const trigger = () => { | ||
const hasOverflowVertical = current && current.scrollHeight > current.clientHeight; | ||
const hasOverflowHorizontal = current && current.scrollWidth > current.clientWidth; | ||
|
||
setOverflowVertical(hasOverflowVertical ?? false); | ||
setOverflowHorizontal(hasOverflowHorizontal ?? false); | ||
|
||
if (!callback) return; | ||
|
||
callback(hasOverflowVertical ?? false, hasOverflowHorizontal ?? false); | ||
} | ||
|
||
if (!current) return; | ||
|
||
trigger(); | ||
}, [ref, callback]) | ||
|
||
return { overflowHorizontal, overflowVertical }; | ||
} | ||
|
||
export interface UseIsOverflowProps { | ||
overflowHorizontal: boolean; | ||
overflowVertical: boolean; | ||
} | ||
|
||
export default useOverflow; |
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,55 @@ | ||
import { RefObject, useLayoutEffect, useState } from "react"; | ||
|
||
export function useScroll<T extends HTMLElement | undefined>(ref: RefObject<T | undefined>): UseScrollProps { | ||
|
||
const [horizontalScrollPosition, setHorizontalScrollPosition] = useState(ref?.current?.scrollLeft ?? 0); | ||
const [verticalScrollPosition, setVerticalScrollPosition] = useState(ref?.current?.scrollTop ?? 0); | ||
|
||
const scrollHorizontal = (increment: number) => { | ||
const { current } = ref; | ||
|
||
if (!current) return; | ||
|
||
console.log(current.scrollLeft); | ||
|
||
current.scrollLeft += increment; | ||
|
||
console.log(current.scrollLeft); | ||
} | ||
|
||
const scrollVertical = (increment: number) => { | ||
const { current } = ref; | ||
|
||
if (!current) return; | ||
|
||
console.log(current.scrollTop); | ||
|
||
current.scrollTop += increment; | ||
|
||
console.log(current.scrollTop); | ||
} | ||
|
||
useLayoutEffect(() => { | ||
const { current } = ref; | ||
|
||
const trigger = () => { | ||
setHorizontalScrollPosition(current?.scrollLeft ?? 0); | ||
setVerticalScrollPosition(current?.scrollTop ?? 0); | ||
} | ||
|
||
if (!current) return; | ||
|
||
trigger(); | ||
}, [ref]) | ||
|
||
return {horizontalScrollPosition, verticalScrollPosition, scrollHorizontal, scrollVertical}; | ||
} | ||
|
||
export default useScroll; | ||
|
||
export interface UseScrollProps { | ||
scrollHorizontal: (increment: number) => void; | ||
scrollVertical: (increment: number) => void; | ||
horizontalScrollPosition: number; | ||
verticalScrollPosition: number; | ||
} |
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