Skip to content

Commit a4073e1

Browse files
authored
Merge pull request #11277 from TylerAPfledderer/refactor/breadcrumb-style
refactor(Breadcrumbs): update style usage
2 parents ac0276b + 61be715 commit a4073e1

File tree

10 files changed

+58
-42
lines changed

10 files changed

+58
-42
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { createMultiStyleConfigHelpers } from "@chakra-ui/react"
2+
import { breadcrumbAnatomy } from "@chakra-ui/anatomy"
3+
import { breadcrumbDefaultTheme, defineMergeStyles } from "./components.utils"
4+
5+
const { defineMultiStyleConfig } = createMultiStyleConfigHelpers(
6+
breadcrumbAnatomy.keys
7+
)
8+
9+
const baseStyle = defineMergeStyles(breadcrumbDefaultTheme.baseStyle, {
10+
list: {
11+
m: 0,
12+
lineHeight: "base",
13+
flexWrap: "wrap",
14+
},
15+
item: {
16+
color: "body.medium",
17+
letterSpacing: "wider",
18+
m: 0,
19+
},
20+
link: {
21+
fontWeight: "normal",
22+
_hover: {
23+
color: "primary.base",
24+
textDecor: "none",
25+
},
26+
_active: {
27+
color: "primary.base",
28+
},
29+
/*
30+
* `&[aria-current="page"]`
31+
* Redundancy to ensure styling on the active
32+
* link is applied.
33+
*/
34+
_activeLink: {
35+
color: "primary.base",
36+
},
37+
},
38+
separator: {
39+
mx: "2.5",
40+
},
41+
})
42+
43+
export const Breadcrumb = defineMultiStyleConfig({
44+
baseStyle,
45+
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Alert } from "./Alert"
22
import { Avatar } from "./Avatar"
33
import { Badge } from "./Badge"
44
import { Button } from "./Button"
5+
import { Breadcrumb } from "./Breadcrumb"
56
import { Heading } from "./Heading"
67
import { Link } from "./Link"
78
import { Tag } from "./Tag"
@@ -17,7 +18,6 @@ import { Switch } from "./Switch"
1718
import { Input } from "./Input"
1819
import {
1920
accordionDefaultTheme,
20-
breadcrumbDefaultTheme,
2121
closeButtonDefaultTheme,
2222
codeDefaultTheme,
2323
dividerDefaultTheme,
@@ -34,7 +34,7 @@ export default {
3434
Alert,
3535
Avatar,
3636
Badge,
37-
Breadcrumb: breadcrumbDefaultTheme,
37+
Breadcrumb,
3838
Button,
3939
Checkbox,
4040
CloseButton: closeButtonDefaultTheme,

src/components/Breadcrumbs/Breadcrumbs.stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from "react"
22
import { Meta, StoryObj } from "@storybook/react"
3+
import { Stack } from "@chakra-ui/react"
34
import BreadcrumbsComponent from "."
45

56
type BreadcumbsType = typeof BreadcrumbsComponent
@@ -15,10 +16,10 @@ type Story = StoryObj<typeof meta>
1516

1617
export const Breadcrumbs: Story = {
1718
render: () => (
18-
<>
19+
<Stack spacing="8">
1920
<BreadcrumbsComponent slug="/en/staking/" />
2021
<BreadcrumbsComponent slug="/en/staking/solo/" />
2122
<BreadcrumbsComponent slug="/en/roadmap/merge/issuance/" />
22-
</>
23+
</Stack>
2324
),
2425
}

src/components/Breadcrumbs/index.tsx

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,15 @@ const Breadcrumbs: React.FC<IProps> = ({
6868
.slice(startDepth)
6969

7070
return (
71-
<Breadcrumb
72-
dir="auto"
73-
position="relative"
74-
zIndex="1"
75-
mb={8}
76-
spacing="2.5"
77-
listProps={{
78-
m: 0,
79-
lineHeight: 1.6,
80-
flexWrap: "wrap",
81-
}}
82-
{...restProps}
83-
>
71+
<Breadcrumb dir="auto" {...restProps}>
8472
{crumbs.map((crumb, idx) => {
8573
const isCurrentPage = slug === crumb.fullPath
8674
return (
87-
<BreadcrumbItem
88-
key={idx}
89-
isCurrentPage={isCurrentPage}
90-
color="body.medium"
91-
letterSpacing="wider"
92-
m={0}
93-
>
75+
<BreadcrumbItem key={idx} isCurrentPage={isCurrentPage}>
9476
<BreadcrumbLink
9577
as={BaseLink}
9678
to={crumb.fullPath}
9779
isPartiallyActive={isCurrentPage}
98-
fontWeight="normal"
99-
_hover={{ color: "primary.base", textDecor: "none" }}
100-
_active={{ color: "primary.base" }}
101-
sx={{
102-
/*
103-
* Redundancy to ensure styling on the active
104-
* link is applied.
105-
*/
106-
'&[aria-current="page"]': {
107-
color: "primary.base",
108-
},
109-
}}
11080
>
11181
{crumb.text.toUpperCase()}
11282
</BreadcrumbLink>

src/pages/bug-bounty.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ const BugBountiesPage = ({
442442
<Content>
443443
<HeroCard>
444444
<HeroContainer>
445-
<Breadcrumbs slug={location.pathname} />
445+
<Breadcrumbs slug={location.pathname} mb="8" />
446446
<Row>
447447
<On />
448448
<Title>

src/pages/roadmap/vision.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const PageDivider = () => (
4747
)
4848

4949
const PageContent = (props: ChildOnlyProp) => (
50-
<Box py={4} px={8} w="full" {...props} />
50+
<Flex flexDirection="column" gap="8" py={4} px={8} w="full" {...props} />
5151
)
5252

5353
const H2 = (props: HeadingProps) => (

src/templates/roadmap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const RoadmapPage = ({
219219
<HeroContainer>
220220
<Flex w="100%" flexDirection={{ base: "column", md: "row" }}>
221221
<TitleCard>
222-
<Breadcrumbs slug={location.pathname} />
222+
<Breadcrumbs slug={location.pathname} mb="8" />
223223
<Title>{mdx.frontmatter.title}</Title>
224224
<Text>{mdx.frontmatter.description}</Text>
225225
{mdx?.frontmatter?.buttons && (

src/templates/staking.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ const StakingPage = ({
401401
<Box position="relative" width="full">
402402
<HeroContainer>
403403
<Flex direction="column" justify="flex-start" w="full" p={8}>
404-
<Breadcrumbs slug={location.pathname} />
404+
<Breadcrumbs slug={location.pathname} mb="8" />
405405
<Title>{mdx.frontmatter.title}</Title>
406406
<UnorderedList>
407407
{(summaryPoints || []).map((point, idx) => (

src/templates/static.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ const StaticPage = ({
285285
},
286286
}}
287287
>
288-
<Breadcrumbs slug={slug} />
288+
<Breadcrumbs slug={slug} mb="8" />
289289
<Text
290290
color="text200"
291291
dir={isLangRightToLeft(language as Lang) ? "rtl" : "ltr"}

src/templates/upgrade.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ const UpgradePage = ({
382382
<Container>
383383
<HeroContainer>
384384
<TitleCard>
385-
<Breadcrumbs slug={slug} startDepth={1} mt={2} />
385+
<Breadcrumbs slug={slug} startDepth={1} mt={2} mb="8" />
386386
<Title>{mdx.frontmatter.title}</Title>
387387
<Box>
388388
<List listStyleType="disc">

0 commit comments

Comments
 (0)