-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1409 from argos-ci/overlay-settings
feat: changes overlay settings
- Loading branch information
Showing
18 changed files
with
442 additions
and
89 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
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,54 @@ | ||
import { createContext, useContext, useMemo } from "react"; | ||
import { invariant } from "@argos/util/invariant"; | ||
|
||
import { useStorageState } from "@/util/useStorageState"; | ||
|
||
type DiffColorContextValue = { | ||
color: string; | ||
setColor: React.Dispatch<React.SetStateAction<string>>; | ||
opacity: number; | ||
setOpacity: React.Dispatch<React.SetStateAction<number>>; | ||
}; | ||
|
||
const DiffColorContext = createContext<DiffColorContextValue | null>(null); | ||
|
||
export function useBuildDiffColorState() { | ||
const context = useContext(DiffColorContext); | ||
invariant( | ||
context, | ||
"useBuildDiffColorState must be used within a BuildDiffColorStateProvider", | ||
); | ||
return context; | ||
} | ||
|
||
export function useBuildDiffColorStyle() { | ||
const { color, opacity } = useBuildDiffColorState(); | ||
return { | ||
filter: `drop-shadow(0 2000px 0 ${color})`, | ||
transform: "translateY(-2000px)", | ||
overflow: "hidden", | ||
opacity, | ||
}; | ||
} | ||
|
||
export function BuildDiffColorStateProvider(props: { | ||
children: React.ReactNode; | ||
}) { | ||
const [color, setColor] = useStorageState( | ||
"preferences.overlay.color", | ||
"#FD3A4A", | ||
); | ||
const [opacity, setOpacity] = useStorageState( | ||
"preferences.overlay.opacity", | ||
0.8, | ||
); | ||
const value = useMemo( | ||
(): DiffColorContextValue => ({ color, setColor, opacity, setOpacity }), | ||
[color, setColor, opacity, setOpacity], | ||
); | ||
return ( | ||
<DiffColorContext.Provider value={value}> | ||
{props.children} | ||
</DiffColorContext.Provider> | ||
); | ||
} |
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
Oops, something went wrong.