feat: switched to official lottie react and adjusted all the existings ones

This commit is contained in:
=
2025-01-06 14:55:13 +05:30
parent 19d32a1a3b
commit c56f598115
24 changed files with 61 additions and 101 deletions
+19 -20
View File
@@ -22,6 +22,7 @@
"@hcaptcha/react-hcaptcha": "^1.11.0", "@hcaptcha/react-hcaptcha": "^1.11.0",
"@headlessui/react": "^1.7.19", "@headlessui/react": "^1.7.19",
"@hookform/resolvers": "^3.9.1", "@hookform/resolvers": "^3.9.1",
"@lottiefiles/dotlottie-react": "^0.12.0",
"@octokit/rest": "^21.0.2", "@octokit/rest": "^21.0.2",
"@peculiar/x509": "^1.12.3", "@peculiar/x509": "^1.12.3",
"@radix-ui/react-accordion": "^1.2.2", "@radix-ui/react-accordion": "^1.2.2",
@@ -61,7 +62,6 @@
"jspdf": "^2.5.2", "jspdf": "^2.5.2",
"jsrp": "^0.2.4", "jsrp": "^0.2.4",
"jwt-decode": "^4.0.0", "jwt-decode": "^4.0.0",
"lottie-react": "^2.4.0",
"ms": "^2.1.3", "ms": "^2.1.3",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"picomatch": "^4.0.2", "picomatch": "^4.0.2",
@@ -1512,6 +1512,24 @@
} }
} }
}, },
"node_modules/@lottiefiles/dotlottie-react": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@lottiefiles/dotlottie-react/-/dotlottie-react-0.12.0.tgz",
"integrity": "sha512-33Tsd67vlotrm43R8oko30Krwyuqb0YdOLra7L5m2mVfrTvDPEDBt8jfjgiveoLJ0jG/FlTLiCPXi/vCaBSXrg==",
"license": "MIT",
"dependencies": {
"@lottiefiles/dotlottie-web": "0.38.2"
},
"peerDependencies": {
"react": "^17 || ^18 || ^19"
}
},
"node_modules/@lottiefiles/dotlottie-web": {
"version": "0.38.2",
"resolved": "https://registry.npmjs.org/@lottiefiles/dotlottie-web/-/dotlottie-web-0.38.2.tgz",
"integrity": "sha512-01d+UjJ8NG7ZStYQxtb8FPzknzGmauG7gEkcH+wHfSdiSQJY9PoBNVSTB9V6F5hAnmFqOxaocTtd7TIEEnzMnA==",
"license": "MIT"
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -8472,25 +8490,6 @@
"loose-envify": "cli.js" "loose-envify": "cli.js"
} }
}, },
"node_modules/lottie-react": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/lottie-react/-/lottie-react-2.4.0.tgz",
"integrity": "sha512-pDJGj+AQlnlyHvOHFK7vLdsDcvbuqvwPZdMlJ360wrzGFurXeKPr8SiRCjLf3LrNYKANQtSsh5dz9UYQHuqx4w==",
"license": "MIT",
"dependencies": {
"lottie-web": "^5.10.2"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/lottie-web": {
"version": "5.12.2",
"resolved": "https://registry.npmjs.org/lottie-web/-/lottie-web-5.12.2.tgz",
"integrity": "sha512-uvhvYPC8kGPjXT3MyKMrL3JitEAmDMp30lVkuq/590Mw9ok6pWcFCwXJveo0t5uqYw1UREQHofD+jVpdjBv8wg==",
"license": "MIT"
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "10.4.3", "version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
+1 -1
View File
@@ -26,6 +26,7 @@
"@hcaptcha/react-hcaptcha": "^1.11.0", "@hcaptcha/react-hcaptcha": "^1.11.0",
"@headlessui/react": "^1.7.19", "@headlessui/react": "^1.7.19",
"@hookform/resolvers": "^3.9.1", "@hookform/resolvers": "^3.9.1",
"@lottiefiles/dotlottie-react": "^0.12.0",
"@octokit/rest": "^21.0.2", "@octokit/rest": "^21.0.2",
"@peculiar/x509": "^1.12.3", "@peculiar/x509": "^1.12.3",
"@radix-ui/react-accordion": "^1.2.2", "@radix-ui/react-accordion": "^1.2.2",
@@ -65,7 +66,6 @@
"jspdf": "^2.5.2", "jspdf": "^2.5.2",
"jsrp": "^0.2.4", "jsrp": "^0.2.4",
"jwt-decode": "^4.0.0", "jwt-decode": "^4.0.0",
"lottie-react": "^2.4.0",
"ms": "^2.1.3", "ms": "^2.1.3",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"picomatch": "^4.0.2", "picomatch": "^4.0.2",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14 -39
View File
@@ -1,18 +1,8 @@
import { import { ComponentPropsWithRef, ElementType, ReactNode, Ref, useRef } from "react";
ComponentPropsWithRef, import { DotLottie, DotLottieReact } from "@lottiefiles/dotlottie-react";
ElementType,
ReactNode,
Ref,
useEffect,
useRef,
useState
} from "react";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import Lottie, { LottieRefCurrentProps } from "lottie-react";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
export type MenuProps = { export type MenuProps = {
children: ReactNode; children: ReactNode;
className?: string; className?: string;
@@ -46,23 +36,7 @@ export const MenuItem = <T extends ElementType = "button">({
inputRef, inputRef,
...props ...props
}: MenuItemProps<T> & ComponentPropsWithRef<T>): JSX.Element => { }: MenuItemProps<T> & ComponentPropsWithRef<T>): JSX.Element => {
const iconRef = useRef<LottieRefCurrentProps | null>(null); const iconRef = useRef<DotLottie | null>(null);
// to trigger ref change
const [shouldRenderLottie, setShouldRenderLottie] = useState(false);
const animationData = useRef();
useEffect(() => {
if (icon) {
import(`../../../assets/lotties/${icon}.json`)
.then((el) => {
animationData.current = { ...el };
setShouldRenderLottie(true);
})
.catch(() => {
createNotification({ type: "error", title: "Failed to load icon", text: "Missing icon" });
});
}
}, [icon]);
return ( return (
<div onMouseEnter={() => iconRef.current?.play()} onMouseLeave={() => iconRef.current?.stop()}> <div onMouseEnter={() => iconRef.current?.play()} onMouseLeave={() => iconRef.current?.stop()}>
<li <li
@@ -86,16 +60,17 @@ export const MenuItem = <T extends ElementType = "button">({
isSelected ? "visisble" : "invisible" isSelected ? "visisble" : "invisible"
} absolute -left-[0.28rem] h-5 w-[0.07rem] rounded-md bg-primary`} } absolute -left-[0.28rem] h-5 w-[0.07rem] rounded-md bg-primary`}
/> />
{/* {icon && <span className="mr-3 ml-4 w-5 block group-hover:hidden">{icon}</span>} */} {icon && (
{icon && shouldRenderLottie && animationData.current && ( <div style={{ width: "22px", height: "22px" }} className="my-auto ml-1 mr-3">
<Lottie <DotLottieReact
lottieRef={iconRef} dotLottieRefCallback={(el) => {
style={{ width: 22, height: 22 }} iconRef.current = el;
animationData={animationData.current} }}
loop={false} src={`/lotties/${icon}.json`}
autoplay={false} loop
className="my-auto ml-[0.1rem] mr-3" className="h-full w-full"
/> />
</div>
)} )}
<span className="flex-grow text-left">{children}</span> <span className="flex-grow text-left">{children}</span>
</Item> </Item>
@@ -73,7 +73,7 @@ export const OrganizationLayout = () => {
<Menu className="mt-4"> <Menu className="mt-4">
<Link to={`/organization/${ProjectType.SecretManager}/overview` as const}> <Link to={`/organization/${ProjectType.SecretManager}/overview` as const}>
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-165-view-carousel"> <MenuItem isSelected={isActive} icon="sliding-carousel">
Secret Management Secret Management
</MenuItem> </MenuItem>
)} )}
@@ -87,38 +87,35 @@ export const OrganizationLayout = () => {
</Link> </Link>
<Link to={`/organization/${ProjectType.KMS}/overview` as const}> <Link to={`/organization/${ProjectType.KMS}/overview` as const}>
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="note"> <MenuItem isSelected={isActive} icon="unlock">
Key Management Key Management
</MenuItem> </MenuItem>
)} )}
</Link> </Link>
<Link to={`/organization/${ProjectType.SSH}/overview` as const}> <Link to={`/organization/${ProjectType.SSH}/overview` as const}>
{({ isActive }) => ( {({ isActive }) => (
<MenuItem <MenuItem isSelected={isActive} icon="verified">
isSelected={isActive}
icon="system-regular-126-verified-hover-verified"
>
SSH SSH
</MenuItem> </MenuItem>
)} )}
</Link> </Link>
<Link to="/organization/access-management"> <Link to="/organization/access-management">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-96-groups"> <MenuItem isSelected={isActive} icon="groups">
Access Control Access Control
</MenuItem> </MenuItem>
)} )}
</Link> </Link>
<Link to="/organization/secret-scanning"> <Link to="/organization/secret-scanning">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-69-document-scan"> <MenuItem isSelected={isActive} icon="secret-scan" className="text-white">
Secret Scanning Secret Scanning
</MenuItem> </MenuItem>
)} )}
</Link> </Link>
<Link to="/organization/secret-sharing"> <Link to="/organization/secret-sharing">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-90-lock-closed"> <MenuItem isSelected={isActive} icon="lock-closed">
Secret Sharing Secret Sharing
</MenuItem> </MenuItem>
)} )}
@@ -128,10 +125,7 @@ export const OrganizationLayout = () => {
window.location.origin.includes("https://gamma.infisical.com")) && ( window.location.origin.includes("https://gamma.infisical.com")) && (
<Link to="/organization/billing"> <Link to="/organization/billing">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem <MenuItem isSelected={isActive} icon="spinning-coin">
isSelected={isActive}
icon="system-outline-103-coin-cash-monetization"
>
Usage &amps; Billing Usage &amps; Billing
</MenuItem> </MenuItem>
)} )}
@@ -139,17 +133,14 @@ export const OrganizationLayout = () => {
)} )}
<Link to="/organization/audit-logs"> <Link to="/organization/audit-logs">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-168-view-headline"> <MenuItem isSelected={isActive} icon="moving-block">
Audit Logs Audit Logs
</MenuItem> </MenuItem>
)} )}
</Link> </Link>
<Link to="/organization/settings"> <Link to="/organization/settings">
{({ isActive }) => ( {({ isActive }) => (
<MenuItem <MenuItem isSelected={isActive} icon="toggle-settings">
isSelected={isActive}
icon="system-outline-109-slider-toggle-settings"
>
Organization Settings Organization Settings
</MenuItem> </MenuItem>
)} )}
@@ -100,7 +100,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-90-lock-closed"> <MenuItem isSelected={isActive} icon="lock-closed">
{t("nav.menu.secrets")} {t("nav.menu.secrets")}
</MenuItem> </MenuItem>
)} )}
@@ -114,7 +114,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-90-lock-closed"> <MenuItem isSelected={isActive} icon="lock-closed">
Overview Overview
</MenuItem> </MenuItem>
)} )}
@@ -128,7 +128,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-90-lock-closed"> <MenuItem isSelected={isActive} icon="lock-closed">
Overview Overview
</MenuItem> </MenuItem>
)} )}
@@ -142,7 +142,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-90-lock-closed"> <MenuItem isSelected={isActive} icon="lock-closed">
Overview Overview
</MenuItem> </MenuItem>
)} )}
@@ -155,7 +155,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-96-groups"> <MenuItem isSelected={isActive} icon="groups">
Access Control Access Control
</MenuItem> </MenuItem>
)} )}
@@ -168,7 +168,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem isSelected={isActive} icon="system-outline-82-extension"> <MenuItem isSelected={isActive} icon="jigsaw-puzzle">
{t("nav.menu.integrations")} {t("nav.menu.integrations")}
</MenuItem> </MenuItem>
)} )}
@@ -196,10 +196,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem <MenuItem isSelected={isActive} icon="circular-check">
isSelected={isActive}
icon="system-outline-189-domain-verification"
>
Approvals Approvals
{Boolean( {Boolean(
secretApprovalReqCount?.open || secretApprovalReqCount?.open ||
@@ -220,10 +217,7 @@ export const ProjectLayout = () => {
}} }}
> >
{({ isActive }) => ( {({ isActive }) => (
<MenuItem <MenuItem isSelected={isActive} icon="toggle-settings">
isSelected={isActive}
icon="system-outline-109-slider-toggle-settings"
>
{t("nav.menu.project-settings")} {t("nav.menu.project-settings")}
</MenuItem> </MenuItem>
)} )}