-
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.
- Loading branch information
1 parent
e7ed6ea
commit 18c7137
Showing
15 changed files
with
381 additions
and
29 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,58 @@ | ||
"use client"; | ||
|
||
import { useColorStore } from "@/store/store"; | ||
import { BaseColorTypes } from "@/types/app"; | ||
import { cn } from "@ui/lib/utils"; | ||
|
||
function ReadabilityString({ | ||
type, | ||
step, | ||
}: { | ||
type: BaseColorTypes; | ||
step: number; | ||
}) { | ||
const { colorPalettes } = useColorStore(); | ||
const readability = colorPalettes[type][step]?.readability; | ||
// Function to determine border style | ||
const getBorderStyle = (readabilityValue: number) => { | ||
if (readabilityValue >= 7) { | ||
return "border-border ring-1 ring-inset ring-offset-2 ring-primary ring-offset-border"; | ||
} else if (readabilityValue >= 4.5) { | ||
return "border border-accent-foreground"; | ||
} else if (readabilityValue >= 3) { | ||
console.log(`readabilityValue: ${readabilityValue}`); | ||
return "border border-dashed"; | ||
} else { | ||
return ""; | ||
} | ||
}; | ||
|
||
const foregroundBorderStyle = readability | ||
? getBorderStyle(readability.foreground.readability) | ||
: ""; | ||
|
||
const backgroundBorderStyle = readability | ||
? getBorderStyle(readability.background.readability) | ||
: ""; | ||
return ( | ||
<div | ||
className="animate-text flex w-full justify-between" | ||
title={`readability`} | ||
> | ||
<span | ||
className={cn(foregroundBorderStyle, "rounded px-1")} | ||
title={`Against Foreground Readability: ${readability?.foreground?.readability}`} | ||
> | ||
{readability?.foreground?.readability} | ||
</span> | ||
<span | ||
className={cn(backgroundBorderStyle, "!-ml-0.5 rounded px-1")} | ||
title={`Against Background Readability: ${readability?.background?.readability}`} | ||
> | ||
{readability?.background?.readability} | ||
</span> | ||
</div> | ||
); | ||
} | ||
|
||
export default ReadabilityString; |
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,39 @@ | ||
import * as React from "react"; | ||
import { SVGProps } from "react"; | ||
const EyeCVD = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
{...props} | ||
> | ||
<g clipPath="url(#a)"> | ||
<path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
d="M12 16.684c-7 0-10-7-10-7S3.987 5.047 8.5 3.32c.32-.123.654-.23 1-.321l1.23 2.89a4.002 4.002 0 1 0 3.127 7.337l1.26 2.957c-.358.12-.73.22-1.117.3a9.93 9.93 0 0 1-2 .2Zm1.068-5.31.79 1.853A4 4 0 0 0 12 5.684c-.444 0-.87.072-1.27.205l.79 1.853a2 2 0 1 0 1.548 3.633Zm0 0L11.52 7.743a2 2 0 0 1 1.548 3.633Z" | ||
clipRule="evenodd" | ||
/> | ||
<path | ||
stroke="currentColor" | ||
strokeLinecap="square" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M10 3.854a8.81 8.81 0 0 1 3.111-.554C19.333 3.3 22 9.387 22 9.387s-2.155 4.92-7.111 5.913" | ||
/> | ||
<path | ||
stroke="currentColor" | ||
strokeDasharray="4 4" | ||
strokeLinecap="round" | ||
strokeWidth={2} | ||
d="M3 20h19" | ||
/> | ||
</g> | ||
<defs> | ||
<clipPath id="a"> | ||
<path fill="#fff" d="M0 0h24v24H0z" /> | ||
</clipPath> | ||
</defs> | ||
</svg> | ||
); | ||
export default EyeCVD; |
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,34 @@ | ||
import primaryToolbarMenu from "../ui/primary-toolbar-menu"; | ||
import { useColorStore } from "@/store/store"; | ||
import ToolbarMenuItem from "./toolbar-menu-item"; | ||
import { cn } from "@ui/lib/utils"; | ||
import { handleToggleReadability } from "@/app/actions"; | ||
|
||
function CVD() { | ||
const menuItem = primaryToolbarMenu["Color Vision Deficiency"]; | ||
const { showReadability } = useColorStore(); | ||
return ( | ||
<form | ||
onSubmit={(e) => { | ||
e.preventDefault(); | ||
handleToggleReadability(`${!showReadability}`); | ||
useColorStore.setState({ showReadability: !showReadability }); | ||
}} | ||
> | ||
<button | ||
type="submit" | ||
aria-label="Toggle Readability" | ||
className={cn( | ||
showReadability && | ||
"-mx-1.5 rounded-sm bg-primary/20 px-1.5 lg:mx-0 lg:px-0", | ||
)} | ||
> | ||
<ToolbarMenuItem {...menuItem} /> | ||
</button> | ||
</form> | ||
); | ||
} | ||
|
||
export default CVD; | ||
|
||
CVD.displayName = "CVD"; |
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,47 @@ | ||
import primaryToolbarMenu from "../ui/primary-toolbar-menu"; | ||
import { useColorStore } from "@/store/store"; | ||
import ToolbarMenuItem from "./toolbar-menu-item"; | ||
import { cn } from "@ui/lib/utils"; | ||
import { handleToggleReadability } from "@/app/actions"; | ||
import { useState } from "react"; | ||
|
||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "@ui/components/ui/popover"; | ||
|
||
import dynamic from "next/dynamic"; | ||
|
||
const ReadabilityPlugin = dynamic(() => import("./plugin/readability.plugin"), { | ||
ssr: false, | ||
}); | ||
|
||
function Readability() { | ||
const menuItem = primaryToolbarMenu.Readability; | ||
const [open, setOpen] = useState(false); | ||
const { showReadability } = useColorStore(); | ||
return ( | ||
<Popover open={open} onOpenChange={setOpen}> | ||
<PopoverTrigger> | ||
<button | ||
type="button" | ||
aria-label="Show Readability Plugin" | ||
className={cn( | ||
showReadability && | ||
"-mx-1.5 rounded-sm bg-primary/20 px-1.5 lg:mx-0 lg:px-0", | ||
)} | ||
> | ||
<ToolbarMenuItem {...menuItem} /> | ||
</button> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-[18rem] sm:w-[24rem]" align="end"> | ||
{open && <ReadabilityPlugin key={`shareable-${open}`} />} | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} | ||
|
||
export default Readability; | ||
|
||
Readability.displayName = "Readability"; |
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.