Skip to content

Commit 477a880

Browse files
committed
addressing PR comments
1 parent 3647024 commit 477a880

5 files changed

Lines changed: 70 additions & 61 deletions

File tree

.changeset/petite-symbols-lie.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@braid-design-system/docs-ui': minor
3+
---
4+
5+
**HeaderNavigation:** Added `onSearchClick` prop to support triggering the search interaction.
6+
7+
**KeyboardShortcut:** Added new component for displaying keyboard shortcut hints.
8+
9+
**EXAMPLE USAGE:**
10+
```jsx
11+
<KeyboardShortcut keys={['CTRL', 'S']} shortcutLabel="Save" />
12+
```
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import { style } from '@vanilla-extract/css';
2-
import { vars } from 'braid-design-system/css';
1+
import { createVar, style } from '@vanilla-extract/css';
2+
import { vars, colorModeStyle } from 'braid-design-system/css';
33

4-
export const searchButton = style({
5-
':hover': {
6-
background: vars.backgroundColor.neutralSoft,
4+
const searchBg = createVar();
5+
export const searchButton = style([
6+
{
7+
':hover': {
8+
background: searchBg,
9+
},
710
},
8-
});
9-
10-
11-
// import { style } from '@vanilla-extract/css';
12-
// import { vars, colorModeStyle } from 'braid-design-system/css';
13-
14-
// export const searchButton = style({
15-
// ':hover': (
16-
// colorModeStyle({
17-
// lightMode: {
18-
// background: vars.backgroundColor.neutralSoft,
19-
// },
20-
// darkMode: {
21-
// background: vars.backgroundColor.neutralSoft,
22-
// },
23-
// })
24-
// )
25-
// })
11+
colorModeStyle({
12+
lightMode: {
13+
vars: {
14+
[searchBg]: vars.backgroundColor.neutralSoft,
15+
}
16+
},
17+
darkMode: {
18+
vars: {
19+
[searchBg]: vars.backgroundColor.neutral,
20+
}
21+
},
22+
})
23+
]);

packages/docs-ui/src/components/HeaderNavigation/HeaderNavigation.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
HiddenVisually,
66
IconSearch,
77
Link,
8-
Stack,
98
Text,
109
} from 'braid-design-system';
1110
import type { ReactNode } from 'react';
@@ -55,7 +54,7 @@ export const HeaderNavigation = ({
5554
</Link>
5655
</Text>
5756
</Box>
58-
<Stack space="none">
57+
<div>
5958
<>{themeToggle}</>
6059
<Bleed horizontal="xxsmall" bottom="xxsmall">
6160
<Box
@@ -80,6 +79,6 @@ export const HeaderNavigation = ({
8079
/>
8180
</Box>
8281
</Bleed>
83-
</Stack>
82+
</div>
8483
</Box>
8584
);

site/src/App/CategoryHeading/CategoryHeading.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Box, Text } from 'braid-design-system';
2-
import type { ElementType } from 'react';
2+
import type { ComponentProps } from 'react';
33

44
export const CategoryHeading = ({
55
children,
66
component,
77
}: {
88
children: React.ReactNode;
9-
component?: ElementType;
9+
component?: ComponentProps<typeof Text>['component'];
1010
}) => (
1111
<Box style={{ textTransform: 'uppercase' }}>
1212
<Text size="xsmall" weight="medium" component={component}>

site/src/App/JumpToModal/SearchResults.tsx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { KeyboardShortcut } from '@braid-design-system/docs-ui';
2-
import { Box, Stack, Text, Bleed, ButtonLink } from 'braid-src/lib/components';
2+
import {
3+
Box,
4+
Stack,
5+
Text,
6+
Bleed,
7+
ButtonLink,
8+
Spread,
9+
} from 'braid-src/lib/components';
310

411
import { CategoryHeading } from '../CategoryHeading/CategoryHeading';
512

@@ -43,7 +50,7 @@ export const SearchResults = ({
4350
}
4451

4552
return (
46-
<Stack space="large">
53+
<Stack space="large" test-id="search-results">
4754
{(['Foundations', 'Components', 'CSS', 'Logic'] as const).map(
4855
(category) => {
4956
const items = groupedResults[category];
@@ -52,26 +59,19 @@ export const SearchResults = ({
5259
}
5360

5461
return (
55-
<Stack key={category} space="xxsmall" component="ul">
56-
<Box marginBottom="xsmall" component="li">
57-
<CategoryHeading component="h2">{category}</CategoryHeading>
58-
</Box>
59-
{items.map((item) => {
60-
const globalIndex = flatResults.findIndex(
61-
(r) => r.path === item.path,
62-
);
63-
const isSelected = globalIndex === selectedIndex;
62+
<Stack space="xsmall" key={category}>
63+
<CategoryHeading component="h2">{category}</CategoryHeading>
64+
<Stack space="xxsmall" component="ul">
65+
{items.map((item) => {
66+
const globalIndex = flatResults.findIndex(
67+
(r) => r.path === item.path,
68+
);
69+
const isSelected = globalIndex === selectedIndex;
6470

65-
return (
66-
<Box key={item.path} component="li">
67-
<Bleed horizontal="small">
68-
<Box
69-
display="flex"
70-
alignItems="center"
71-
justifyContent="spaceBetween"
72-
gap="small"
73-
>
74-
<Box>
71+
return (
72+
<Box key={item.path} component="li">
73+
<Bleed left="small">
74+
<Spread space="small" alignY="center">
7575
<ButtonLink
7676
variant={isSelected ? 'soft' : 'transparent'}
7777
tone="formAccent"
@@ -83,19 +83,19 @@ export const SearchResults = ({
8383
>
8484
{item.name}
8585
</ButtonLink>
86-
</Box>
8786

88-
{item.hasProps && isSelected && (
89-
<KeyboardShortcut
90-
keys={['⇧', '⏎']}
91-
shortcutLabel="Props"
92-
/>
93-
)}
94-
</Box>
95-
</Bleed>
96-
</Box>
97-
);
98-
})}
87+
{item.hasProps && isSelected && (
88+
<KeyboardShortcut
89+
keys={['⇧', '⏎']}
90+
shortcutLabel="Props"
91+
/>
92+
)}
93+
</Spread>
94+
</Bleed>
95+
</Box>
96+
);
97+
})}
98+
</Stack>
9999
</Stack>
100100
);
101101
},

0 commit comments

Comments
 (0)