Skip to content

Commit b3cd266

Browse files
committed
Fix styles
1 parent db4e951 commit b3cd266

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

.storybook/global.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,3 @@ h6 {
8585
.custom-versions div a {
8686
text-decoration: underline;
8787
}
88-
89-
.custom-search {
90-
margin-left: auto;
91-
margin-right: 20px;
92-
}

src/components/Breadcrumb/Breadcrumb.module.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
display: flex;
55
font-size: 18px;
66
height: 32px;
7-
justify-content: start;
7+
justify-content: space-between;
88
gap: 10px;
99
min-height: 32px;
1010
padding-left: 20px;
@@ -47,3 +47,11 @@
4747
}
4848
}
4949
}
50+
51+
.versions {
52+
margin-left: auto;
53+
54+
[aria-current] {
55+
font-weight: bold;
56+
}
57+
}

src/components/Breadcrumb/Breadcrumb.stories.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ export const Default: Story = {
2020
{ text: 'part2/', sourceId: '/part1/part2/' },
2121
],
2222
versions: {
23-
label: 'Versions',
23+
label: 'Branches',
2424
versions: [
25-
{ label: 'v1.0', sourceId: 'part1/part2/file.txt?version=v1.0' },
26-
{ label: 'v2.0', sourceId: 'part1/part2/file.txt?version=v2.0' },
25+
{ label: 'master', sourceId: '/part1/part2/file.txt' },
26+
{ label: 'dev', sourceId: '/part1/part2/file.txt?branch=dev' },
27+
{ label: 'refs/convert/parquet', sourceId: '/part1/part2/file.txt?branch=refs/convert/parquet' },
2728
],
2829
},
2930
},
@@ -40,7 +41,7 @@ export const Default: Story = {
4041
return (
4142
<ConfigProvider value={config}>
4243
<Breadcrumb {...args}>
43-
<div className="custom-search">SEARCH</div>
44+
<input type='text' placeholder="Search..." />
4445
</Breadcrumb>
4546
</ConfigProvider>
4647
)

src/components/Breadcrumb/Breadcrumb.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { ReactNode } from 'react'
22
import { useConfig } from '../../hooks/useConfig.js'
33
import type { Source } from '../../lib/sources/types.js'
4-
import { Version } from '../../lib/sources/types.js'
54
import { cn } from '../../lib/utils.js'
65
import Dropdown from '../Dropdown/Dropdown.js'
76
import styles from './Breadcrumb.module.css'
@@ -11,12 +10,20 @@ interface BreadcrumbProps {
1110
children?: ReactNode
1211
}
1312

14-
function Versions({ versions, label }: { versions: Version[], label: string }) {
13+
function Versions({ source }: { source: Source }) {
1514
const { routes, customClass } = useConfig()
1615

17-
return <Dropdown label={label} className={customClass?.versions}>
16+
if (!source.versions) return null
17+
const { label, versions } = source.versions
18+
19+
return <Dropdown label={label} className={cn(styles.versions, customClass?.versions)} align="right">
1820
{versions.map(({ label, sourceId }) => {
19-
return <a key={sourceId} role="menuitem" href={routes?.getSourceRouteUrl?.({ sourceId })}>{label}</a>
21+
return <a
22+
key={sourceId}
23+
role="menuitem"
24+
href={routes?.getSourceRouteUrl?.({ sourceId })}
25+
aria-current={sourceId === source.sourceId ? 'true' : undefined}
26+
>{label}</a>
2027
})}
2128
</Dropdown>
2229
}
@@ -33,7 +40,7 @@ export default function Breadcrumb({ source, children }: BreadcrumbProps) {
3340
<a href={routes?.getSourceRouteUrl?.({ sourceId: part.sourceId }) ?? ''} key={depth}>{part.text}</a>
3441
)}
3542
</div>
36-
{source.versions && <Versions label={source.versions.label} versions={source.versions.versions} />}
43+
{source.versions && <Versions source={source} />}
3744
{children}
3845
</nav>
3946
}

0 commit comments

Comments
 (0)