Skip to content

Commit 514ecba

Browse files
committed
Merge branch 'dev' into shadcn-get-eth
2 parents 1fdd32a + 6f443d6 commit 514ecba

File tree

6 files changed

+52
-51
lines changed

6 files changed

+52
-51
lines changed

src/components/Banners/BannerNotification.tsx

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
1-
import React from "react"
2-
import { Center, FlexProps, useMediaQuery } from "@chakra-ui/react"
1+
import { cn } from "@/lib/utils/cn"
32

4-
import { lightTheme as oldTheme } from "../../theme"
5-
6-
export type BannerNotificationProps = FlexProps & {
3+
export type BannerNotificationProps = React.HTMLAttributes<HTMLDivElement> & {
74
shouldShow?: boolean
85
}
96

107
const BannerNotification = ({
118
children,
12-
shouldShow = false,
9+
shouldShow,
10+
className,
1311
...props
1412
}: BannerNotificationProps) => {
15-
const [isLGScreen] = useMediaQuery(`min-width: ${oldTheme.breakpoints.l}`)
13+
if (!shouldShow) return <></>
1614
return (
17-
<>
18-
{shouldShow && (
19-
<Center
20-
as="aside"
21-
maxW={isLGScreen ? oldTheme.variables.maxPageWidth : "100%"}
22-
w="100%"
23-
py="4"
24-
px="8"
25-
bg="primary.base"
26-
color="background.base"
27-
sx={{
28-
a: {
29-
color: "background.base",
30-
},
31-
}}
32-
{...props}
33-
>
34-
{children}
35-
</Center>
15+
<aside
16+
className={cn(
17+
"flex items-center justify-center gap-2 bg-primary-action px-8 py-4 text-white [&_a]:text-white [&_a]:hover:text-white/80",
18+
className
3619
)}
37-
</>
20+
{...props}
21+
>
22+
{children}
23+
</aside>
3824
)
3925
}
4026

src/components/Banners/DismissableBanner/index.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
// Libraries
2-
import React, { useEffect, useState } from "react"
3-
import { Center, CloseButton } from "@chakra-ui/react"
1+
import { useEffect, useState } from "react"
2+
import { MdClose } from "react-icons/md"
3+
4+
import { Button } from "@/components/ui/buttons/Button"
5+
import { Center } from "@/components/ui/flex"
6+
7+
import { cn } from "@/lib/utils/cn"
48

5-
// Components
69
import BannerNotification from "../BannerNotification"
710

8-
// Interface
9-
export type DismissableBannerProps = {
10-
children: JSX.Element
11+
type DismissableBannerProps = React.HTMLAttributes<HTMLDivElement> & {
1112
storageKey: string
1213
}
1314

1415
const DismissableBanner = ({
1516
children,
1617
storageKey,
18+
className,
1719
}: DismissableBannerProps) => {
1820
const [show, setShow] = useState<boolean>(false)
1921

@@ -28,13 +30,16 @@ const DismissableBanner = ({
2830
}
2931

3032
return (
31-
<BannerNotification shouldShow={show} gap="8">
32-
<Center marginInlineStart="auto">{children}</Center>
33-
<CloseButton
34-
marginInlineStart="auto"
33+
<BannerNotification shouldShow={show} className={cn("gap-8", className)}>
34+
<Center className="ms-auto">{children}</Center>
35+
<Button
36+
className="ms-auto"
3537
onClick={onClose}
3638
aria-label="Close Banner"
37-
/>
39+
variant="ghost"
40+
>
41+
<MdClose />
42+
</Button>
3843
</BannerNotification>
3944
)
4045
}

src/components/Homepage/useHome.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRouter } from "next/router"
33
import { useTranslation } from "next-i18next"
44
import { FaDiscord, FaGithub, FaXTwitter } from "react-icons/fa6"
55

6-
import type { EventCardProps, Lang } from "@/lib/types"
6+
import type { EventCardProps } from "@/lib/types"
77
import type { CodeExample } from "@/lib/interfaces"
88

99
import { useBentoBox } from "@/components/Homepage/useBentoBox"
@@ -16,8 +16,8 @@ import TryAppsIcon from "@/components/icons/phone-homescreen.svg"
1616
import RoadmapSign from "@/components/icons/roadmap-sign.svg"
1717
import Whitepaper from "@/components/icons/whitepaper.svg"
1818

19+
import { cn } from "@/lib/utils/cn"
1920
import { isValidDate } from "@/lib/utils/date"
20-
import { isLangRightToLeft } from "@/lib/utils/translations"
2121

2222
import events from "@/data/community-events.json"
2323
import CreateWalletContent from "@/data/CreateWallet"
@@ -27,6 +27,7 @@ import { GITHUB_REPO_URL } from "@/lib/constants"
2727
import SimpleDomainRegistryContent from "!!raw-loader!@/data/SimpleDomainRegistry.sol"
2828
import SimpleTokenContent from "!!raw-loader!@/data/SimpleToken.sol"
2929
import SimpleWalletContent from "!!raw-loader!@/data/SimpleWallet.sol"
30+
import { useRtlFlip } from "@/hooks/useRtlFlip"
3031

3132
export const useHome = () => {
3233
const { t } = useTranslation(["common", "page-index"])
@@ -37,7 +38,7 @@ export const useHome = () => {
3738

3839
const bentoItems = useBentoBox()
3940

40-
const dir = isLangRightToLeft(locale as Lang) ? "rtl" : "ltr"
41+
const { direction, isRtl } = useRtlFlip()
4142

4243
const toggleCodeExample = (id: number): void => {
4344
setActiveCode(id)
@@ -106,7 +107,10 @@ export const useHome = () => {
106107
description: t("page-index:page-index-cta-dapps-description"),
107108
href: "/dapps/",
108109
Svg: TryAppsIcon,
109-
className: "text-accent-c hover:text-accent-c-hover",
110+
className: cn(
111+
"text-accent-c hover:text-accent-c-hover",
112+
isRtl && "[&_svg]:-scale-x-100"
113+
),
110114
},
111115
]
112116

@@ -129,11 +133,13 @@ export const useHome = () => {
129133
{
130134
label: t("page-index:page-index-popular-topics-whitepaper"),
131135
Svg: Whitepaper,
136+
className: cn(isRtl && "[&_svg]:-scale-x-100"),
132137
href: "/whitepaper/",
133138
},
134139
{
135140
label: t("page-index:page-index-popular-topics-roadmap"),
136141
Svg: RoadmapSign,
142+
className: cn(isRtl && "[&_svg]:-scale-x-100"),
137143
href: "/roadmap/",
138144
},
139145
]
@@ -188,7 +194,7 @@ export const useHome = () => {
188194
t,
189195
locale,
190196
asPath,
191-
dir,
197+
dir: direction,
192198
isModalOpen,
193199
setModalOpen,
194200
activeCode,

src/components/ui/Link.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
5050
ref
5151
) {
5252
const { asPath } = useRouter()
53-
const { flipForRtl } = useRtlFlip()
53+
const { twFlipForRtl } = useRtlFlip()
5454

5555
if (!href) {
5656
console.warn("Link component is missing href prop")
@@ -102,9 +102,10 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
102102
<VisuallyHidden>(opens in a new tab)</VisuallyHidden>
103103
{!hideArrow && (
104104
<RxExternalLink
105-
className={cn("-me-1 inline h-6 w-6 p-1 align-middle", {
106-
transform: flipForRtl,
107-
})}
105+
className={cn(
106+
"-me-1 inline h-6 w-6 p-1 align-middle",
107+
twFlipForRtl
108+
)}
108109
/>
109110
)}
110111
</a>

src/layouts/UseCases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const UseCasesLayout = ({
177177
width="full"
178178
dir={contentNotTranslated ? "ltr" : "unset"}
179179
>
180-
<BannerNotification shouldShow zIndex="sticky" hideBelow={lgBp}>
180+
<BannerNotification shouldShow className="z-sticky max-lg:hidden">
181181
<Emoji text=":pencil:" className="me-4 shrink-0 text-2xl" />
182182
<Text m={0}>
183183
{t("template-usecase:template-usecase-banner")}{" "}

src/pages/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,15 @@ const HomePage = ({
313313
{t("page-index:page-index-popular-topics-header")}
314314
</h3>
315315
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2 md:grid-cols-1 lg:grid-cols-2">
316-
{popularTopics.map(({ label, Svg, href }) => (
316+
{popularTopics.map(({ label, Svg, href, className }) => (
317317
<SvgButtonLink
318318
key={label}
319319
Svg={Svg}
320320
href={href}
321-
className="text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row"
321+
className={cn(
322+
"text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row",
323+
className
324+
)}
322325
>
323326
<p className="text-start text-xl font-bold text-body group-hover:underline">
324327
{label}

0 commit comments

Comments
 (0)