diff --git a/index.html b/index.html index e67608f..2ddf104 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@
{query}
- + + {isWeightSupported ? snippets[type] : "This weight is not yet supported"} handleCopySnippet(e, type)} disabled={!isWeightSupported} - style={ - isWeightSupported - ? { color: "currentColor" } - : snippetButtonStyle - } > {copied === type ? ( - + ) : ( @@ -168,11 +194,6 @@ const DetailFooter = () => { }); }, [entry]); - const buttonBarStyle: CSSProperties = { - color: isDark ? "white" : buttonColor, - backgroundColor: "transparent", - }; - const handleCopySnippet = ( event: React.MouseEvent, type: SnippetType @@ -193,7 +214,39 @@ const DetailFooter = () => { if (!ref.current) return; navigator.clipboard?.writeText(cloneWithSize(ref.current, size).outerHTML); - setCopied("SVG"); + setCopied(CopyType.SVG); + }; + + const handleCopyDataSVG = ( + event: React.MouseEvent + ) => { + event.currentTarget.blur(); + if (!entry) return; + if (!ref.current) return; + + navigator.clipboard?.writeText( + "data:image/svg+xml;base64," + + btoa( + unescape( + encodeURIComponent(cloneWithSize(ref.current, size).outerHTML) + ) + ) + ); + setCopied(CopyType.SVG_DATA); + }; + + const handleCopyRawSVG = async () => { + if (!entry) return; + + const { name } = entry; + const data = await fetch( + `https://raw.githubusercontent.com/phosphor-icons/core/main/raw/${weight}/${name}${ + weight === "regular" ? "" : `-${weight}` + }.svg` + ); + const content = await data.text(); + navigator.clipboard?.writeText(content); + setCopied(CopyType.SVG_RAW); }; const handleDownloadSVG = ( @@ -223,6 +276,40 @@ const DetailFooter = () => { ); }; + const handleCopyPNG = async ( + event: React.MouseEvent + ) => { + event.currentTarget.blur(); + if (!entry) return; + if (!ref.current) return; + + Svg2Png.toDataURL(cloneWithSize(ref.current, size)) + .then((data) => fetch(data)) + .then((res) => res.blob()) + .then((blob) => + navigator.clipboard.write([ + new ClipboardItem({ + [blob.type]: blob, + }), + ]) + ) + .then(() => { + setCopied(CopyType.PNG); + }); + }; + + // const handleCopyDataPNG = async ( + // event: React.MouseEvent + // ) => { + // event.currentTarget.blur(); + // if (!entry) return; + // if (!ref.current) return; + + // const data = await Svg2Png.toDataURL(cloneWithSize(ref.current, size)); + // navigator.clipboard?.writeText(data); + // setCopied(CopyType.PNG_DATA); + // }; + return ( {!!entry && ( @@ -244,46 +331,81 @@ const DetailFooter = () => { - - - {" "} - PNG - - - {" "} - SVG - - - {copied === "SVG" ? ( - + + + + {!showMoreActions ? ( + <> + + + + + + > ) : ( - + <> + + + + + + > + )} + + setShowMoreActions((s) => !s)} + > + {!showMoreActions ? ( + + ) : ( + )} - {copied === "SVG" ? "Copied!" : " SVG"} - setInitialTab({ i })} - /> + { ); }; -export default DetailFooter; +export default Panel; diff --git a/src/components/IconGrid/TagCloud.css b/src/components/IconGrid/TagCloud.css index 57ee857..64f3729 100644 --- a/src/components/IconGrid/TagCloud.css +++ b/src/components/IconGrid/TagCloud.css @@ -1,25 +1,25 @@ .tag-cloud { display: flex; flex-wrap: wrap; - justify-content: center; + justify-content: flex-start; + gap: 6px; } button.tag-button { - margin: 4px; border-radius: 4px; - background-color: var(--sheer); + background-color: var(--background-card); outline: none; cursor: pointer; - transition: background-color 200ms ease, box-shadow 200ms ease; + transition: background-color 150ms ease, box-shadow 150ms ease; color: var(--foreground); } button.tag-button:hover { - background-color: var(--soft); + background-color: var(--sheer); } button.tag-button:focus-visible { - box-shadow: 0 0 0 1px var(--soft); + box-shadow: 0 0 0 1px var(--sheer); } .tag-button code { diff --git a/src/components/Links/Links.tsx b/src/components/Links/Links.tsx index 72a66d9..5a87a38 100644 --- a/src/components/Links/Links.tsx +++ b/src/components/Links/Links.tsx @@ -26,18 +26,18 @@ const Links = (_: LinksProps) => { - - Figma library - - {" / "} - plugin + Figma plugin + + {" / "} + + library @@ -56,18 +56,12 @@ const Links = (_: LinksProps) => { - - - Donate on PayPal - - {" / "} - - Patreon - - + + Showcase + @@ -91,17 +85,27 @@ const Links = (_: LinksProps) => { - - TKTK - + + + Donate on PayPal + + {" / "} + + Patreon + + + - Showcase TK + Twitter diff --git a/src/components/Notice/Notice.tsx b/src/components/Notice/Notice.tsx index d22cd76..1c353af 100644 --- a/src/components/Notice/Notice.tsx +++ b/src/components/Notice/Notice.tsx @@ -1,19 +1,18 @@ import { ReactNode } from "react"; import { motion } from "framer-motion"; -import { useRecoilValue } from "recoil"; import { HourglassMedium, Question, SmileyXEyes } from "@phosphor-icons/react"; -import { searchQueryAtom } from "@/state"; - interface NoticeProps { - message?: string; + message?: ReactNode; type?: "wait" | "help" | "warn" | "none"; children?: ReactNode; } -const Notice = ({ message, type = "warn", children }: NoticeProps) => { - const query = useRecoilValue(searchQueryAtom); - +const Notice = ({ + message = "An error occurred.", + type = "warn", + children, +}: NoticeProps) => { return ( { animate={{ opacity: 1 }} transition={{ duration: 0.5 }} > - {type === "wait" && ( - - )} - {type === "help" && ( - - )} - {type === "warn" && ( - - )} - {message ?? ( - - No results for "{query}" - - )} - {children} + + {type === "wait" && } + {type === "help" && } + {type === "warn" && } + {message} + {children} + ); diff --git a/src/components/SearchInput/SearchInput.css b/src/components/SearchInput/SearchInput.css index 9e96243..71f45fa 100644 --- a/src/components/SearchInput/SearchInput.css +++ b/src/components/SearchInput/SearchInput.css @@ -1,4 +1,5 @@ .search-bar { + position: relative; display: flex; flex: 2; align-items: center; @@ -11,7 +12,7 @@ .search-bar:focus-within { outline: none; - color: black !important; + color: var(--moss) !important; background-color: white !important; } @@ -37,7 +38,7 @@ .search-bar input:focus { outline: none; - color: black; + color: var(--moss); } .search-bar input::placeholder { @@ -53,6 +54,9 @@ } .keys { + position: absolute; + top: 16px; + right: 24px; display: inline-flex; align-items: center; justify-content: flex-end; diff --git a/src/components/SearchInput/SearchInput.tsx b/src/components/SearchInput/SearchInput.tsx index 414d55f..3c9a995 100644 --- a/src/components/SearchInput/SearchInput.tsx +++ b/src/components/SearchInput/SearchInput.tsx @@ -8,7 +8,12 @@ import { import { useRecoilState } from "recoil"; import { useDebounce } from "react-use"; import { useHotkeys } from "react-hotkeys-hook"; -import { Command, MagnifyingGlass, X, HourglassHigh } from "@phosphor-icons/react"; +import { + Command, + MagnifyingGlass, + X, + HourglassHigh, +} from "@phosphor-icons/react"; import ReactGA from "react-ga4"; import { searchQueryAtom } from "@/state"; diff --git a/src/components/SettingsActions/SettingsActions.css b/src/components/SettingsActions/SettingsActions.css index b853be1..80aeb78 100644 --- a/src/components/SettingsActions/SettingsActions.css +++ b/src/components/SettingsActions/SettingsActions.css @@ -1,17 +1,17 @@ -button.action-button { +button.tool-button { background-color: var(--scrim); color: white; - padding: 8px; + padding: 12px; border-radius: 8px; cursor: pointer; } -button.action-button:active { +button.tool-button:active { background-color: var(--sheer); } @media screen and (max-width: 558px) { - .toolbar .action-button { + .toolbar .tool-button { display: none; } } diff --git a/src/components/SettingsActions/SettingsActions.tsx b/src/components/SettingsActions/SettingsActions.tsx index 69c89ef..ac5ef8c 100644 --- a/src/components/SettingsActions/SettingsActions.tsx +++ b/src/components/SettingsActions/SettingsActions.tsx @@ -1,5 +1,13 @@ -import { useRecoilValue, useResetRecoilState } from "recoil"; -import { ArrowCounterClockwise, CheckCircle, Link } from "@phosphor-icons/react"; +import { useState } from "react"; +import ReactGA from "react-ga4"; +import { useRecoilState, useResetRecoilState } from "recoil"; +import { + ArrowCounterClockwise, + CheckCircle, + DiceFive, + Link, +} from "@phosphor-icons/react"; +import { IconStyle } from "@phosphor-icons/core"; import { useTransientState } from "@/hooks"; import { @@ -12,12 +20,13 @@ import { import "./SettingsActions.css"; const SettingsActions = () => { - const weight = useRecoilValue(iconWeightAtom); - const size = useRecoilValue(iconSizeAtom); - const color = useRecoilValue(iconColorAtom); + const [weight, setWeight] = useRecoilState(iconWeightAtom); + const [size, setSize] = useRecoilState(iconSizeAtom); + const [color, setColor] = useRecoilState(iconColorAtom); const reset = useResetRecoilState(resetSettingsSelector); const [copied, setCopied] = useTransientState(false, 2000); + const [booped, setBooped] = useState(false); const copyDeepLinkToClipboard = () => { const paramString = new URLSearchParams([ @@ -35,26 +44,60 @@ const SettingsActions = () => { }); }; + const randomizeSettings = () => { + if (booped) setBooped(false); + setBooped(true); + + const rWeight = Object.values(IconStyle).filter((w) => w !== weight)[ + Math.floor(Math.random() * 5) + ]; + const rSize = 16 + Math.floor(Math.random() * 20 + 1) * 4; + const rColor = + "#" + + Math.floor(Math.random() * (0xffffff + 1)) + .toString(16) + .padStart(6, "0"); + + setWeight(rWeight); + setColor(rColor); + setSize(rSize); + + ReactGA.event({ category: "Settings", action: "Random" }); + }; + return ( <> {copied ? ( - + ) : ( )} + + setBooped(false)} + > + + + > ); }; diff --git a/src/components/StyleInput/StyleInput.css b/src/components/StyleInput/StyleInput.css index 279205e..9312a09 100644 --- a/src/components/StyleInput/StyleInput.css +++ b/src/components/StyleInput/StyleInput.css @@ -28,7 +28,7 @@ .react-dropdown-select:focus-within { background-color: white; - color: black; + color: var(--moss); outline: none !important; box-shadow: none !important; } @@ -62,21 +62,21 @@ box-shadow: none; } .react-dropdown-select-item { - color: black; + color: var(--moss); } .react-dropdown-select-item:hover { - background-color: var(--yellow) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item.react-dropdown-select-item-selected, .react-dropdown-select-item.react-dropdown-select-item-active { - color: black !important; - background-color: var(--yellow) !important; + color: var(--moss) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item:focus { - color: black !important; - background-color: var(--yellow) !important; + color: var(--moss) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item.react-dropdown-select-item-disabled { diff --git a/src/components/StyleInput/StyleInput.tsx b/src/components/StyleInput/StyleInput.tsx index c18c285..f5571ec 100644 --- a/src/components/StyleInput/StyleInput.tsx +++ b/src/components/StyleInput/StyleInput.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { useRecoilState } from "recoil"; import Select from "react-dropdown-select"; -import { PencilLine } from "@phosphor-icons/react"; +import { PencilSimpleLine } from "@phosphor-icons/react"; import { IconStyle } from "@phosphor-icons/core"; import { iconWeightAtom } from "@/state"; @@ -14,32 +14,32 @@ const options: WeightOption[] = [ { key: "Thin", value: IconStyle.THIN, - icon: , + icon: , }, { key: "Light", value: IconStyle.LIGHT, - icon: , + icon: , }, { key: "Regular", value: IconStyle.REGULAR, - icon: , + icon: , }, { key: "Bold", value: IconStyle.BOLD, - icon: , + icon: , }, { key: "Fill", value: IconStyle.FILL, - icon: , + icon: , }, { key: "Duotone", value: IconStyle.DUOTONE, - icon: , + icon: , }, ]; diff --git a/src/components/Tabs/Tabs.css b/src/components/Tabs/Tabs.css index 16a8f48..0aff447 100644 --- a/src/components/Tabs/Tabs.css +++ b/src/components/Tabs/Tabs.css @@ -38,17 +38,17 @@ button.tab:hover:not(.active) { } button.tab.active { - background-color: var(--background-tab); + background-color: var(--background-layer); border-bottom: none; } .tab-content { flex: 1; - height: 77px; - max-height: 77px; + height: 86px; + max-height: 86px; padding: 20px 20px 10px; border-radius: 8px; - background-color: var(--background-tab); + background-color: var(--background-layer); overflow-y: auto; } diff --git a/src/hooks/useSessionStorage.ts b/src/hooks/useSessionStorage.ts index 9ce2453..0b7793b 100644 --- a/src/hooks/useSessionStorage.ts +++ b/src/hooks/useSessionStorage.ts @@ -5,7 +5,7 @@ type Initializer = () => S; type Setter = (prev: S) => S; type Action = S | Setter | Initializer; -function expand(action: Action, prev?: S) { +function expand(action: Action, prev?: S) { if (typeof action === "function") { return (action as Setter)(prev!); } else { @@ -13,13 +13,19 @@ function expand(action: Action, prev?: S) { } } -export default function useSessionStorage( +export default function useSessionStorage( key: string, fallbackState: S | (() => S) ): [S, Dispatch>, (partial: Partial) => void] { const [value, setValue] = useState(() => { let val = sessionStorage.getItem(STORAGE_KEY + key); - if (val) return JSON.parse(val) as S; + if (val) { + try { + return JSON.parse(val) as S; + } catch (_) { + return val as S; + } + } return expand(fallbackState); }); diff --git a/src/lib/index.ts b/src/lib/index.ts index 921793a..f03970b 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -8,7 +8,7 @@ export interface IconEntry extends CoreEntry { export enum SnippetType { REACT = "React", VUE = "Vue", - HTML = "HTML/CSS", + HTML = "Web", FLUTTER = "Flutter", ELM = "Elm", }
+ {isWeightSupported ? snippets[type] : "This weight is not yet supported"} handleCopySnippet(e, type)} disabled={!isWeightSupported} - style={ - isWeightSupported - ? { color: "currentColor" } - : snippetButtonStyle - } > {copied === type ? ( - + ) : ( @@ -168,11 +194,6 @@ const DetailFooter = () => { }); }, [entry]); - const buttonBarStyle: CSSProperties = { - color: isDark ? "white" : buttonColor, - backgroundColor: "transparent", - }; - const handleCopySnippet = ( event: React.MouseEvent, type: SnippetType @@ -193,7 +214,39 @@ const DetailFooter = () => { if (!ref.current) return; navigator.clipboard?.writeText(cloneWithSize(ref.current, size).outerHTML); - setCopied("SVG"); + setCopied(CopyType.SVG); + }; + + const handleCopyDataSVG = ( + event: React.MouseEvent + ) => { + event.currentTarget.blur(); + if (!entry) return; + if (!ref.current) return; + + navigator.clipboard?.writeText( + "data:image/svg+xml;base64," + + btoa( + unescape( + encodeURIComponent(cloneWithSize(ref.current, size).outerHTML) + ) + ) + ); + setCopied(CopyType.SVG_DATA); + }; + + const handleCopyRawSVG = async () => { + if (!entry) return; + + const { name } = entry; + const data = await fetch( + `https://raw.githubusercontent.com/phosphor-icons/core/main/raw/${weight}/${name}${ + weight === "regular" ? "" : `-${weight}` + }.svg` + ); + const content = await data.text(); + navigator.clipboard?.writeText(content); + setCopied(CopyType.SVG_RAW); }; const handleDownloadSVG = ( @@ -223,6 +276,40 @@ const DetailFooter = () => { ); }; + const handleCopyPNG = async ( + event: React.MouseEvent + ) => { + event.currentTarget.blur(); + if (!entry) return; + if (!ref.current) return; + + Svg2Png.toDataURL(cloneWithSize(ref.current, size)) + .then((data) => fetch(data)) + .then((res) => res.blob()) + .then((blob) => + navigator.clipboard.write([ + new ClipboardItem({ + [blob.type]: blob, + }), + ]) + ) + .then(() => { + setCopied(CopyType.PNG); + }); + }; + + // const handleCopyDataPNG = async ( + // event: React.MouseEvent + // ) => { + // event.currentTarget.blur(); + // if (!entry) return; + // if (!ref.current) return; + + // const data = await Svg2Png.toDataURL(cloneWithSize(ref.current, size)); + // navigator.clipboard?.writeText(data); + // setCopied(CopyType.PNG_DATA); + // }; + return ( {!!entry && ( @@ -244,46 +331,81 @@ const DetailFooter = () => { - - - {" "} - PNG - - - {" "} - SVG - - - {copied === "SVG" ? ( - + + + + {!showMoreActions ? ( + <> + + + + + + > ) : ( - + <> + + + + + + > + )} + + setShowMoreActions((s) => !s)} + > + {!showMoreActions ? ( + + ) : ( + )} - {copied === "SVG" ? "Copied!" : " SVG"} - setInitialTab({ i })} - /> + { ); }; -export default DetailFooter; +export default Panel; diff --git a/src/components/IconGrid/TagCloud.css b/src/components/IconGrid/TagCloud.css index 57ee857..64f3729 100644 --- a/src/components/IconGrid/TagCloud.css +++ b/src/components/IconGrid/TagCloud.css @@ -1,25 +1,25 @@ .tag-cloud { display: flex; flex-wrap: wrap; - justify-content: center; + justify-content: flex-start; + gap: 6px; } button.tag-button { - margin: 4px; border-radius: 4px; - background-color: var(--sheer); + background-color: var(--background-card); outline: none; cursor: pointer; - transition: background-color 200ms ease, box-shadow 200ms ease; + transition: background-color 150ms ease, box-shadow 150ms ease; color: var(--foreground); } button.tag-button:hover { - background-color: var(--soft); + background-color: var(--sheer); } button.tag-button:focus-visible { - box-shadow: 0 0 0 1px var(--soft); + box-shadow: 0 0 0 1px var(--sheer); } .tag-button code { diff --git a/src/components/Links/Links.tsx b/src/components/Links/Links.tsx index 72a66d9..5a87a38 100644 --- a/src/components/Links/Links.tsx +++ b/src/components/Links/Links.tsx @@ -26,18 +26,18 @@ const Links = (_: LinksProps) => { - - Figma library - - {" / "} - plugin + Figma plugin + + {" / "} + + library @@ -56,18 +56,12 @@ const Links = (_: LinksProps) => { - - - Donate on PayPal - - {" / "} - - Patreon - - + + Showcase + @@ -91,17 +85,27 @@ const Links = (_: LinksProps) => { - - TKTK - + + + Donate on PayPal + + {" / "} + + Patreon + + + - Showcase TK + Twitter diff --git a/src/components/Notice/Notice.tsx b/src/components/Notice/Notice.tsx index d22cd76..1c353af 100644 --- a/src/components/Notice/Notice.tsx +++ b/src/components/Notice/Notice.tsx @@ -1,19 +1,18 @@ import { ReactNode } from "react"; import { motion } from "framer-motion"; -import { useRecoilValue } from "recoil"; import { HourglassMedium, Question, SmileyXEyes } from "@phosphor-icons/react"; -import { searchQueryAtom } from "@/state"; - interface NoticeProps { - message?: string; + message?: ReactNode; type?: "wait" | "help" | "warn" | "none"; children?: ReactNode; } -const Notice = ({ message, type = "warn", children }: NoticeProps) => { - const query = useRecoilValue(searchQueryAtom); - +const Notice = ({ + message = "An error occurred.", + type = "warn", + children, +}: NoticeProps) => { return ( { animate={{ opacity: 1 }} transition={{ duration: 0.5 }} > - {type === "wait" && ( - - )} - {type === "help" && ( - - )} - {type === "warn" && ( - - )} - {message ?? ( - - No results for "{query}" - - )} - {children} + + {type === "wait" && } + {type === "help" && } + {type === "warn" && } + {message} + {children} + ); diff --git a/src/components/SearchInput/SearchInput.css b/src/components/SearchInput/SearchInput.css index 9e96243..71f45fa 100644 --- a/src/components/SearchInput/SearchInput.css +++ b/src/components/SearchInput/SearchInput.css @@ -1,4 +1,5 @@ .search-bar { + position: relative; display: flex; flex: 2; align-items: center; @@ -11,7 +12,7 @@ .search-bar:focus-within { outline: none; - color: black !important; + color: var(--moss) !important; background-color: white !important; } @@ -37,7 +38,7 @@ .search-bar input:focus { outline: none; - color: black; + color: var(--moss); } .search-bar input::placeholder { @@ -53,6 +54,9 @@ } .keys { + position: absolute; + top: 16px; + right: 24px; display: inline-flex; align-items: center; justify-content: flex-end; diff --git a/src/components/SearchInput/SearchInput.tsx b/src/components/SearchInput/SearchInput.tsx index 414d55f..3c9a995 100644 --- a/src/components/SearchInput/SearchInput.tsx +++ b/src/components/SearchInput/SearchInput.tsx @@ -8,7 +8,12 @@ import { import { useRecoilState } from "recoil"; import { useDebounce } from "react-use"; import { useHotkeys } from "react-hotkeys-hook"; -import { Command, MagnifyingGlass, X, HourglassHigh } from "@phosphor-icons/react"; +import { + Command, + MagnifyingGlass, + X, + HourglassHigh, +} from "@phosphor-icons/react"; import ReactGA from "react-ga4"; import { searchQueryAtom } from "@/state"; diff --git a/src/components/SettingsActions/SettingsActions.css b/src/components/SettingsActions/SettingsActions.css index b853be1..80aeb78 100644 --- a/src/components/SettingsActions/SettingsActions.css +++ b/src/components/SettingsActions/SettingsActions.css @@ -1,17 +1,17 @@ -button.action-button { +button.tool-button { background-color: var(--scrim); color: white; - padding: 8px; + padding: 12px; border-radius: 8px; cursor: pointer; } -button.action-button:active { +button.tool-button:active { background-color: var(--sheer); } @media screen and (max-width: 558px) { - .toolbar .action-button { + .toolbar .tool-button { display: none; } } diff --git a/src/components/SettingsActions/SettingsActions.tsx b/src/components/SettingsActions/SettingsActions.tsx index 69c89ef..ac5ef8c 100644 --- a/src/components/SettingsActions/SettingsActions.tsx +++ b/src/components/SettingsActions/SettingsActions.tsx @@ -1,5 +1,13 @@ -import { useRecoilValue, useResetRecoilState } from "recoil"; -import { ArrowCounterClockwise, CheckCircle, Link } from "@phosphor-icons/react"; +import { useState } from "react"; +import ReactGA from "react-ga4"; +import { useRecoilState, useResetRecoilState } from "recoil"; +import { + ArrowCounterClockwise, + CheckCircle, + DiceFive, + Link, +} from "@phosphor-icons/react"; +import { IconStyle } from "@phosphor-icons/core"; import { useTransientState } from "@/hooks"; import { @@ -12,12 +20,13 @@ import { import "./SettingsActions.css"; const SettingsActions = () => { - const weight = useRecoilValue(iconWeightAtom); - const size = useRecoilValue(iconSizeAtom); - const color = useRecoilValue(iconColorAtom); + const [weight, setWeight] = useRecoilState(iconWeightAtom); + const [size, setSize] = useRecoilState(iconSizeAtom); + const [color, setColor] = useRecoilState(iconColorAtom); const reset = useResetRecoilState(resetSettingsSelector); const [copied, setCopied] = useTransientState(false, 2000); + const [booped, setBooped] = useState(false); const copyDeepLinkToClipboard = () => { const paramString = new URLSearchParams([ @@ -35,26 +44,60 @@ const SettingsActions = () => { }); }; + const randomizeSettings = () => { + if (booped) setBooped(false); + setBooped(true); + + const rWeight = Object.values(IconStyle).filter((w) => w !== weight)[ + Math.floor(Math.random() * 5) + ]; + const rSize = 16 + Math.floor(Math.random() * 20 + 1) * 4; + const rColor = + "#" + + Math.floor(Math.random() * (0xffffff + 1)) + .toString(16) + .padStart(6, "0"); + + setWeight(rWeight); + setColor(rColor); + setSize(rSize); + + ReactGA.event({ category: "Settings", action: "Random" }); + }; + return ( <> {copied ? ( - + ) : ( )} + + setBooped(false)} + > + + + > ); }; diff --git a/src/components/StyleInput/StyleInput.css b/src/components/StyleInput/StyleInput.css index 279205e..9312a09 100644 --- a/src/components/StyleInput/StyleInput.css +++ b/src/components/StyleInput/StyleInput.css @@ -28,7 +28,7 @@ .react-dropdown-select:focus-within { background-color: white; - color: black; + color: var(--moss); outline: none !important; box-shadow: none !important; } @@ -62,21 +62,21 @@ box-shadow: none; } .react-dropdown-select-item { - color: black; + color: var(--moss); } .react-dropdown-select-item:hover { - background-color: var(--yellow) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item.react-dropdown-select-item-selected, .react-dropdown-select-item.react-dropdown-select-item-active { - color: black !important; - background-color: var(--yellow) !important; + color: var(--moss) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item:focus { - color: black !important; - background-color: var(--yellow) !important; + color: var(--moss) !important; + background-color: var(--acid) !important; } .react-dropdown-select-item.react-dropdown-select-item-disabled { diff --git a/src/components/StyleInput/StyleInput.tsx b/src/components/StyleInput/StyleInput.tsx index c18c285..f5571ec 100644 --- a/src/components/StyleInput/StyleInput.tsx +++ b/src/components/StyleInput/StyleInput.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { useRecoilState } from "recoil"; import Select from "react-dropdown-select"; -import { PencilLine } from "@phosphor-icons/react"; +import { PencilSimpleLine } from "@phosphor-icons/react"; import { IconStyle } from "@phosphor-icons/core"; import { iconWeightAtom } from "@/state"; @@ -14,32 +14,32 @@ const options: WeightOption[] = [ { key: "Thin", value: IconStyle.THIN, - icon: , + icon: , }, { key: "Light", value: IconStyle.LIGHT, - icon: , + icon: , }, { key: "Regular", value: IconStyle.REGULAR, - icon: , + icon: , }, { key: "Bold", value: IconStyle.BOLD, - icon: , + icon: , }, { key: "Fill", value: IconStyle.FILL, - icon: , + icon: , }, { key: "Duotone", value: IconStyle.DUOTONE, - icon: , + icon: , }, ]; diff --git a/src/components/Tabs/Tabs.css b/src/components/Tabs/Tabs.css index 16a8f48..0aff447 100644 --- a/src/components/Tabs/Tabs.css +++ b/src/components/Tabs/Tabs.css @@ -38,17 +38,17 @@ button.tab:hover:not(.active) { } button.tab.active { - background-color: var(--background-tab); + background-color: var(--background-layer); border-bottom: none; } .tab-content { flex: 1; - height: 77px; - max-height: 77px; + height: 86px; + max-height: 86px; padding: 20px 20px 10px; border-radius: 8px; - background-color: var(--background-tab); + background-color: var(--background-layer); overflow-y: auto; } diff --git a/src/hooks/useSessionStorage.ts b/src/hooks/useSessionStorage.ts index 9ce2453..0b7793b 100644 --- a/src/hooks/useSessionStorage.ts +++ b/src/hooks/useSessionStorage.ts @@ -5,7 +5,7 @@ type Initializer = () => S; type Setter = (prev: S) => S; type Action = S | Setter | Initializer; -function expand(action: Action, prev?: S) { +function expand(action: Action, prev?: S) { if (typeof action === "function") { return (action as Setter)(prev!); } else { @@ -13,13 +13,19 @@ function expand(action: Action, prev?: S) { } } -export default function useSessionStorage( +export default function useSessionStorage( key: string, fallbackState: S | (() => S) ): [S, Dispatch>, (partial: Partial) => void] { const [value, setValue] = useState(() => { let val = sessionStorage.getItem(STORAGE_KEY + key); - if (val) return JSON.parse(val) as S; + if (val) { + try { + return JSON.parse(val) as S; + } catch (_) { + return val as S; + } + } return expand(fallbackState); }); diff --git a/src/lib/index.ts b/src/lib/index.ts index 921793a..f03970b 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -8,7 +8,7 @@ export interface IconEntry extends CoreEntry { export enum SnippetType { REACT = "React", VUE = "Vue", - HTML = "HTML/CSS", + HTML = "Web", FLUTTER = "Flutter", ELM = "Elm", }
- No results for "{query}" -
{message}