diff --git a/.changeset/chilly-radios-relax.md b/.changeset/chilly-radios-relax.md new file mode 100644 index 00000000..bbc43571 --- /dev/null +++ b/.changeset/chilly-radios-relax.md @@ -0,0 +1,5 @@ +--- +"@worldcoin/mini-apps-ui-kit-react": minor +--- + +Add title animation to TopBar diff --git a/packages/mini-apps-ui-kit-react/src/components/TopBar/TopBar.tsx b/packages/mini-apps-ui-kit-react/src/components/TopBar/TopBar.tsx index 67ef05b5..dffb1ecd 100644 --- a/packages/mini-apps-ui-kit-react/src/components/TopBar/TopBar.tsx +++ b/packages/mini-apps-ui-kit-react/src/components/TopBar/TopBar.tsx @@ -1,4 +1,5 @@ import { cn } from "@/lib/utils"; +import { useWindowScroll } from "@uidotdev/usehooks"; import React from "react"; import { Typography } from "../Typography"; @@ -15,37 +16,48 @@ interface TopBarProps { } function TopBar({ title, startAdornment, endAdornment, className }: TopBarProps) { + const [{ y }] = useWindowScroll(); + const isScrolled = (y ?? 0) > 0; const hasStartAdornment = Boolean(startAdornment); - const hasEndAdornment = Boolean(endAdornment); - - const textAlignment = hasStartAdornment ? "text-center" : "text-left"; - const justifyContent = - hasStartAdornment || hasEndAdornment ? "justify-between" : "justify-start"; - return (