IconGrid: adjust grid item and info panel hover/active states
This is now in compliance with the spec, using a single color with opacity to render open/hovered/active GridItems and InfoPanels. We also properly show background on open GridItems.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
.grid-container {
|
.grid-container {
|
||||||
padding: 0px 16px 8px;
|
padding: 4px 16px;
|
||||||
/* background-color: #35313D;
|
/* background-color: #35313D;
|
||||||
color: white; */
|
color: white; */
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,11 @@
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
/* background-color: rgba(255, 255, 255, 0); */
|
}
|
||||||
|
|
||||||
|
.grid-item:hover {
|
||||||
|
background-color: rgba(163, 159, 171, 0.1);
|
||||||
|
transition: background-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-item:focus {
|
.grid-item:focus {
|
||||||
@@ -43,7 +47,7 @@
|
|||||||
.grid-item p {
|
.grid-item p {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
color: #7F7F7F;
|
color: #86838B;
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
|
||||||
MutableRefObject,
|
MutableRefObject,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
@@ -36,7 +35,7 @@ const itemVariants = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const IconGridItem: React.FC<IconGridItemProps> = (props) => {
|
const IconGridItem: React.FC<IconGridItemProps> = (props) => {
|
||||||
const { index, isDark, originOffset, name, Icon } = props;
|
const { index, originOffset, name, Icon } = props;
|
||||||
const [open, setOpen] = useRecoilState(iconPreviewOpenAtom);
|
const [open, setOpen] = useRecoilState(iconPreviewOpenAtom);
|
||||||
const isOpen = open === name;
|
const isOpen = open === name;
|
||||||
const delayRef = useRef<number>(0);
|
const delayRef = useRef<number>(0);
|
||||||
@@ -45,13 +44,6 @@ const IconGridItem: React.FC<IconGridItemProps> = (props) => {
|
|||||||
|
|
||||||
const handleOpen = () => setOpen(isOpen ? false : name);
|
const handleOpen = () => setOpen(isOpen ? false : name);
|
||||||
|
|
||||||
const whileHover = useMemo(
|
|
||||||
() => ({
|
|
||||||
backgroundColor: isDark ? "rgb(73, 70, 80)" : "rgb(246, 242, 243)",
|
|
||||||
}),
|
|
||||||
[isDark]
|
|
||||||
);
|
|
||||||
|
|
||||||
// The measurement for all elements happens in the layoutEffect cycle
|
// The measurement for all elements happens in the layoutEffect cycle
|
||||||
// This ensures that when we calculate distance in the effect cycle
|
// This ensures that when we calculate distance in the effect cycle
|
||||||
// all elements have already been measured
|
// all elements have already been measured
|
||||||
@@ -82,15 +74,11 @@ const IconGridItem: React.FC<IconGridItemProps> = (props) => {
|
|||||||
key={name}
|
key={name}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
// onFocus={console.log}
|
|
||||||
style={{
|
style={{
|
||||||
order: index,
|
order: index,
|
||||||
backgroundColor: isDark
|
backgroundColor: isOpen ? "rgba(163, 159, 171, 0.1)" : undefined,
|
||||||
? "rgba(73, 70, 80, 0)"
|
|
||||||
: "rgba(246, 242, 243, 0)",
|
|
||||||
}}
|
}}
|
||||||
custom={delayRef}
|
custom={delayRef}
|
||||||
whileHover={whileHover}
|
|
||||||
whileTap={whileTap}
|
whileTap={whileTap}
|
||||||
transition={transition}
|
transition={transition}
|
||||||
variants={itemVariants}
|
variants={itemVariants}
|
||||||
@@ -100,11 +88,11 @@ const IconGridItem: React.FC<IconGridItemProps> = (props) => {
|
|||||||
<Icon />
|
<Icon />
|
||||||
<p>{name}</p>
|
<p>{name}</p>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
<ErrorBoundary>
|
||||||
<AnimatePresence initial={false}>
|
<AnimatePresence initial={false}>
|
||||||
<ErrorBoundary fallback={<p>NOOOOOO</p>}>
|
|
||||||
{isOpen && <InfoPanel {...props} />}
|
{isOpen && <InfoPanel {...props} />}
|
||||||
</ErrorBoundary>
|
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
</ErrorBoundary>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
|
|||||||
html: `<i class="ph-${name}${
|
html: `<i class="ph-${name}${
|
||||||
weight === "regular" ? "" : `-${weight}`
|
weight === "regular" ? "" : `-${weight}`
|
||||||
}"></i>`,
|
}"></i>`,
|
||||||
react: `<${Icon.displayName} size={${size}} color="${color}" ${
|
react: `<${Icon.displayName} size={${size}} ${color !== "#000000" ? `color="${color}" ` : ""}${
|
||||||
weight === "regular" ? "" : `weight="${weight}" `
|
weight === "regular" ? "" : `weight="${weight}" `
|
||||||
}/>`,
|
}/>`,
|
||||||
};
|
};
|
||||||
@@ -66,6 +66,7 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
|
|||||||
event.currentTarget.blur();
|
event.currentTarget.blur();
|
||||||
setCopied(type);
|
setCopied(type);
|
||||||
const data = snippets[type];
|
const data = snippets[type];
|
||||||
|
if (!navigator.clipboard) throw new Error("no clipboard!");
|
||||||
data && navigator.clipboard.writeText(data);
|
data && navigator.clipboard.writeText(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ const InfoPanel: React.FC<InfoPanelProps> = (props) => {
|
|||||||
variants={infoVariants}
|
variants={infoVariants}
|
||||||
style={{
|
style={{
|
||||||
order: index + (spans - (index % spans)),
|
order: index + (spans - (index % spans)),
|
||||||
backgroundColor: isDark ? "rgb(73, 70, 80)" : "rgb(246, 242, 243)",
|
backgroundColor: "rgba(163, 159, 171, 0.1)",
|
||||||
color: isDark ? "white" : "black",
|
color: isDark ? "white" : "black",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
padding: 0 24px;
|
padding: 0 24px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #494650;
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-bar:focus-within {
|
.search-bar:focus-within {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
padding: 0 24px;
|
padding: 0 24px;
|
||||||
color: white;
|
color: white;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background-color: #494650;
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
font-family: "Manrope", sans-serif;
|
font-family: "Manrope", sans-serif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
-webkit-appearance: none; /* Override default CSS styles */
|
-webkit-appearance: none; /* Override default CSS styles */
|
||||||
appearance: none;
|
appearance: none;
|
||||||
height: 1px; /* Specified height */
|
height: 1px; /* Specified height */
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
outline: none; /* Remove outline */
|
outline: none; /* Remove outline */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
padding: 0 24px !important;
|
padding: 0 24px !important;
|
||||||
color: white;
|
color: white;
|
||||||
border-radius: 8px !important;
|
border-radius: 8px !important;
|
||||||
background-color: #494650;
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user