|
1 | | -import { Box, Container, Flex, Icon, IconButton } from "@chakra-ui/react"; |
| 1 | +"use client"; |
| 2 | +import { Button } from "@/components/ui/button"; |
| 3 | +import { TrackedLinkTW } from "@/components/ui/tracked-link"; |
2 | 4 | import { useLocalStorage } from "hooks/useLocalStorage"; |
3 | | -import { FiArrowRight, FiX } from "react-icons/fi"; |
4 | | -import { Heading, TrackedLink } from "tw-components"; |
| 5 | +import { ChevronRightIcon, XIcon } from "lucide-react"; |
5 | 6 |
|
6 | | -export const AnnouncementBanner = () => { |
| 7 | +export function AnnouncementBanner(props: { |
| 8 | + href: string; |
| 9 | + label: string; |
| 10 | + trackingLabel: string; |
| 11 | +}) { |
7 | 12 | const [hasDismissedAnnouncement, setHasDismissedAnnouncement] = |
8 | | - useLocalStorage("dismissed-modular-contracts-announcement", false, true); |
| 13 | + useLocalStorage(`dismissed-${props.trackingLabel}`, false, true); |
9 | 14 |
|
10 | 15 | if (hasDismissedAnnouncement) { |
11 | 16 | return null; |
12 | 17 | } |
13 | 18 |
|
14 | 19 | return ( |
15 | | - <Box |
16 | | - position="sticky" |
17 | | - zIndex="10" |
18 | | - py={3} |
19 | | - bgImage="linear-gradient(145.96deg, #410AB6 5.07%, #7bdefe 100%)" |
| 20 | + <div |
| 21 | + className="fade-in-0 relative w-full animate-in bg-background py-2.5 pr-14 duration-400" |
| 22 | + style={{ |
| 23 | + backgroundImage: |
| 24 | + "linear-gradient(145deg, hsl(290deg 85% 50%), hsl(220deg 85% 50%))", |
| 25 | + }} |
20 | 26 | > |
21 | | - <Flex |
22 | | - w="full" |
23 | | - justifyContent="space-between" |
24 | | - alignItems="center" |
25 | | - gap={{ base: 1, md: 2 }} |
26 | | - px={4} |
| 27 | + <TrackedLinkTW |
| 28 | + href={props.href} |
| 29 | + category="announcement" |
| 30 | + label={props.trackingLabel} |
| 31 | + target={props.href.startsWith("http") ? "_blank" : undefined} |
| 32 | + className="container flex cursor-pointer items-center gap-2 lg:justify-center" |
27 | 33 | > |
28 | | - <Box display={{ base: "none", md: "block" }} /> |
29 | | - <TrackedLink |
30 | | - href="https://thirdweb.com/explore/modular-contracts" |
31 | | - category="announcement" |
32 | | - label="onchain-olympics" |
33 | | - isExternal |
34 | | - > |
35 | | - <Container maxW="container.page" display="flex" px={0}> |
36 | | - <Flex |
37 | | - cursor="pointer" |
38 | | - mx="auto" |
39 | | - align="center" |
40 | | - gap={{ base: 0.5, md: 2 }} |
41 | | - color="white" |
42 | | - > |
43 | | - <Heading |
44 | | - size="label.lg" |
45 | | - as="p" |
46 | | - lineHeight={{ base: 1.5, md: undefined }} |
47 | | - color="white" |
48 | | - fontWeight={500} |
49 | | - > |
50 | | - Modular Contracts Beta: Secure, Customizable, and Easy to |
51 | | - Integrate contracts |
52 | | - </Heading> |
53 | | - <Icon display={{ base: "none", md: "block" }} as={FiArrowRight} /> |
54 | | - </Flex> |
55 | | - </Container> |
56 | | - </TrackedLink> |
| 34 | + <span className="inline-block font-semibold text-white leading-normal hover:underline"> |
| 35 | + {props.label} |
| 36 | + </span> |
| 37 | + <ChevronRightIcon className="hidden size-5 opacity-80 lg:block" /> |
| 38 | + </TrackedLinkTW> |
57 | 39 |
|
58 | | - <IconButton |
59 | | - size="xs" |
60 | | - aria-label="Close announcement" |
61 | | - icon={<FiX />} |
62 | | - colorScheme="blackAlpha" |
63 | | - color={{ base: "white", md: "black" }} |
64 | | - variant="ghost" |
65 | | - onClick={() => setHasDismissedAnnouncement(true)} |
66 | | - /> |
67 | | - </Flex> |
68 | | - </Box> |
| 40 | + <Button |
| 41 | + size="icon" |
| 42 | + variant="ghost" |
| 43 | + onClick={() => setHasDismissedAnnouncement(true)} |
| 44 | + aria-label="Close announcement" |
| 45 | + className="-translate-y-1/2 !text-white absolute top-1/2 right-2 h-auto w-auto p-2 hover:bg-white/15" |
| 46 | + > |
| 47 | + <XIcon className="size-5" /> |
| 48 | + </Button> |
| 49 | + </div> |
69 | 50 | ); |
70 | | -}; |
| 51 | +} |
0 commit comments