Skip to content

Commit 79ea516

Browse files
authored
Merge pull request #13900 from ethereum/ui-divider
refactor: extract ui/divider
2 parents 949c867 + 1260c45 commit 79ea516

File tree

17 files changed

+39
-87
lines changed

17 files changed

+39
-87
lines changed

src/@chakra-ui/components/components.utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const {
99
Checkbox: checkboxDefaultTheme,
1010
CloseButton: closeButtonDefaultTheme,
1111
Code: codeDefaultTheme,
12-
Divider: dividerDefaultTheme,
1312
Drawer: drawerDefaultTheme,
1413
Form: formDefaultTheme,
1514
FormLabel: formLabelDefaultTheme,
@@ -37,7 +36,6 @@ export {
3736
checkboxDefaultTheme,
3837
closeButtonDefaultTheme,
3938
codeDefaultTheme,
40-
dividerDefaultTheme,
4139
drawerDefaultTheme,
4240
formDefaultTheme,
4341
formLabelDefaultTheme,

src/@chakra-ui/components/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Checkbox } from "./Checkbox"
88
import {
99
closeButtonDefaultTheme,
1010
codeDefaultTheme,
11-
dividerDefaultTheme,
1211
drawerDefaultTheme,
1312
formDefaultTheme,
1413
formLabelDefaultTheme,
@@ -39,7 +38,6 @@ export default {
3938
Checkbox,
4039
CloseButton: closeButtonDefaultTheme,
4140
Code: codeDefaultTheme,
42-
Divider: dividerDefaultTheme,
4341
Drawer: drawerDefaultTheme,
4442
Form: formDefaultTheme,
4543
FormLabel: formLabelDefaultTheme,

src/components/MdComponents/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import LocaleDateTime from "../LocaleDateTime"
2727
import MainArticle from "../MainArticle"
2828
import { StandaloneQuizWidget } from "../Quiz/QuizWidget"
2929
import { ButtonLink } from "../ui/buttons/Button"
30+
import { Divider } from "../ui/divider"
3031
import { Flex } from "../ui/flex"
3132
import { ListItem, OrderedList, UnorderedList } from "../ui/list"
3233
import { mdxTableComponents } from "../ui/Table"
@@ -180,10 +181,6 @@ export const MobileButtonDropdown = ({
180181
<StyledButtonDropdown className={cn("mb-0", className)} {...props} />
181182
)
182183

183-
export const Divider = () => (
184-
<div className="my-16 h-1 w-[10%] bg-primary-high-contrast" />
185-
)
186-
187184
// All custom React components
188185
export const reactComponents = {
189186
Badge,

src/components/ui/divider.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { forwardRef } from "react"
2+
3+
import { cn } from "@/lib/utils/cn"
4+
5+
const Divider = forwardRef<
6+
HTMLDivElement,
7+
React.HTMLAttributes<HTMLDivElement>
8+
>(({ className, ...props }, ref) => (
9+
<div
10+
ref={ref}
11+
className={cn("my-16 h-1 w-[10%] bg-primary-high-contrast", className)}
12+
{...props}
13+
/>
14+
))
15+
16+
Divider.displayName = "Divider"
17+
18+
export { Divider }

src/layouts/Docs.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Badge,
55
Box,
66
type BoxProps,
7-
Divider as ChakraDivider,
87
Flex,
98
type FlexProps,
109
type ListProps,
@@ -42,6 +41,7 @@ import SideNav from "@/components/SideNav"
4241
import SideNavMobile from "@/components/SideNavMobile"
4342
import TableOfContents from "@/components/TableOfContents"
4443
import Translation from "@/components/Translation"
44+
import { Divider } from "@/components/ui/divider"
4545
import { mdxTableComponents } from "@/components/ui/Table"
4646
import YouTube from "@/components/YouTube"
4747

@@ -58,15 +58,6 @@ const Page = (props: ChildOnlyProp & Pick<FlexProps, "dir">) => (
5858
/>
5959
)
6060

61-
const Divider = () => (
62-
<ChakraDivider
63-
my={16}
64-
w="10%"
65-
borderBottomWidth={1}
66-
borderColor="homeDivider"
67-
/>
68-
)
69-
7061
type ContentContainerProps = Pick<BoxProps, "children" | "dir">
7162

7263
const ContentContainer = (props: ContentContainerProps) => (

src/layouts/Tutorial.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Badge,
55
Box,
66
type BoxProps,
7-
Divider,
87
Flex,
98
Kbd,
109
Text,
@@ -35,6 +34,7 @@ import {
3534
import TableOfContents from "@/components/TableOfContents"
3635
import TooltipLink from "@/components/TooltipLink"
3736
import TutorialMetadata from "@/components/TutorialMetadata"
37+
import { Divider } from "@/components/ui/divider"
3838
import { mdxTableComponents } from "@/components/ui/Table"
3939
import YouTube from "@/components/YouTube"
4040

@@ -93,16 +93,7 @@ const Heading4 = (props: HTMLAttributes<HTMLHeadingElement>) => (
9393
/>
9494
)
9595

96-
const StyledDivider = (props) => (
97-
<Divider
98-
my={16}
99-
w="10%"
100-
h="1"
101-
opacity="1"
102-
backgroundColor="homeDivider"
103-
{...props}
104-
/>
105-
)
96+
const StyledDivider = (props) => <Divider {...props} />
10697

10798
const Paragraph = (props: TextProps) => (
10899
<Text as="p" mt={8} mb={4} mx={0} color="text300" fontSize="md" {...props} />

src/pages/bug-bounty.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import OldHeading from "@/components/OldHeading"
2828
import Text from "@/components/OldText"
2929
import PageMetadata from "@/components/PageMetadata"
3030
import Translation from "@/components/Translation"
31+
import { Divider } from "@/components/ui/divider"
3132

3233
import { existsNamespace } from "@/lib/utils/existsNamespace"
3334
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
@@ -168,10 +169,6 @@ const FullLeaderboardContainer = (props: ChildOnlyProp) => (
168169

169170
const On = () => <Box w="8px" h="8px" bg="success400" borderRadius="64px" />
170171

171-
const Divider = () => (
172-
<Box my="16" mx="0" w="10%" h="1" backgroundColor="homeDivider" />
173-
)
174-
175172
const Contact = (props: ChildOnlyProp) => (
176173
<Box
177174
borderRadius="2px"

src/pages/community.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Image } from "@/components/Image"
2424
import MainArticle from "@/components/MainArticle"
2525
import OldHeading from "@/components/OldHeading"
2626
import PageMetadata from "@/components/PageMetadata"
27+
import { Divider } from "@/components/ui/divider"
2728

2829
import { existsNamespace } from "@/lib/utils/existsNamespace"
2930
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
@@ -79,10 +80,6 @@ const Content = ({ children }: ChildOnlyProp) => {
7980
)
8081
}
8182

82-
const Divider = () => {
83-
return <Box my={16} w="10%" h={1} bgColor="homeDivider" />
84-
}
85-
8683
const Page = ({ children }: ChildOnlyProp) => {
8784
return (
8885
<Flex

src/pages/dapps.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
Box,
1515
Button,
1616
type ButtonProps,
17-
Divider as ChakraDivider,
18-
type DividerProps,
1917
Flex,
2018
type FlexProps,
2119
Heading,
@@ -48,6 +46,7 @@ import ProductListComponent, {
4846
type ProductListProps,
4947
} from "@/components/ProductList"
5048
import Translation from "@/components/Translation"
49+
import { Divider } from "@/components/ui/divider"
5150

5251
import { existsNamespace } from "@/lib/utils/existsNamespace"
5352
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
@@ -137,19 +136,6 @@ const Page = (props: ChildOnlyProp & FlexProps) => (
137136
/>
138137
)
139138

140-
const Divider = (props: DividerProps) => (
141-
<ChakraDivider
142-
opacity={1}
143-
my={16}
144-
w="10%"
145-
borderBottomWidth="0.25rem"
146-
borderColor="homeDivider"
147-
{...props}
148-
/>
149-
)
150-
151-
const CenterDivider = () => <Divider display="flex" justifyContent="center" />
152-
153139
const Content = (props: ChildOnlyProp) => (
154140
<Box py={4} px={8} w="full" {...props} />
155141
)
@@ -1826,7 +1812,7 @@ const DappsPage = () => {
18261812
)}
18271813
{/* General content for all categories */}
18281814
<Content>
1829-
<CenterDivider />
1815+
<Divider />
18301816
{categories[selectedCategory].benefits && (
18311817
<Box mt={12}>
18321818
<H2>

src/pages/eth.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Text from "@/components/OldText"
3232
import PageMetadata from "@/components/PageMetadata"
3333
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
3434
import Translation from "@/components/Translation"
35+
import { Divider } from "@/components/ui/divider"
3536

3637
import { existsNamespace } from "@/lib/utils/existsNamespace"
3738
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
@@ -59,10 +60,6 @@ const Content = (props: ChildOnlyProp) => (
5960
<Box w="full" px={8} py={4} {...props} />
6061
)
6162

62-
const Divider = () => (
63-
<Box my={16} mx={0} w="10%" h={1} backgroundColor="homeDivider" />
64-
)
65-
6663
const GrayContainer = (props: ChildOnlyProp) => (
6764
<Box
6865
width="full"

0 commit comments

Comments
 (0)