forked from Comcast/react-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNav.tsx
More file actions
151 lines (132 loc) · 4.19 KB
/
Nav.tsx
File metadata and controls
151 lines (132 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { useId, useState } from 'react';
import { Link } from '@tanstack/react-router';
import { css } from 'ecij';
import type { Direction } from '../src/types';
const headerClassname = css`
border-inline-start: 4px solid light-dark(hsl(210deg 50% 80%), hsl(210deg 50% 40%));
h1 {
font-size: 24px;
}
h1,
h2 {
margin: 8px;
}
`;
const navClassname = css`
display: flex;
flex-direction: column;
white-space: nowrap;
a {
color: inherit;
font-size: 14px;
line-height: 22px;
text-decoration: none;
padding-block: 2px;
padding-inline: 16px;
transition: 0.1s background-color;
&:hover {
background-color: light-dark(hsl(210deg 50% 90%), hsl(210deg 50% 30%));
}
&[aria-current='page'] {
font-weight: 500;
background-color: light-dark(hsl(210deg 50% 80%), hsl(210deg 50% 40%));
&:hover {
background-color: light-dark(hsl(210deg 50% 70%), hsl(210deg 50% 50%));
}
}
}
`;
const labelClassname = css`
padding-inline-start: 8px;
`;
export type Theme = 'light' | 'dark' | 'system';
interface Props {
direction: Direction;
onDirectionChange: (direction: Direction) => void;
}
export default function Nav({ direction, onDirectionChange }: Props) {
const demosNavId = useId();
const linksNavId = useId();
const [theme, setTheme] = useState<Theme>('system');
function onThemeChange(theme: Theme) {
document.startViewTransition(() => {
setTheme(theme);
});
}
return (
<header className={headerClassname}>
<h1>react-data-grid</h1>
<label className={labelClassname}>
Theme{' '}
<select value={theme} onChange={(e) => onThemeChange(e.target.value as Theme)}>
<option value="light">Light</option>
<option value="dark">Dark</option>
<option value="system">System</option>
</select>
</label>
<nav aria-labelledby={demosNavId} className={navClassname}>
<h2 id={demosNavId}>Demos</h2>
<Link to="/CommonFeatures">Common Features</Link>
<Link to="/AllFeatures">All Features</Link>
<Link to="/CellNavigation">Cell Navigation</Link>
<Link to="/ColumnSpanning">Column Spanning</Link>
<Link to="/ColumnGrouping">Column Grouping</Link>
<Link to="/ColumnsReordering">Columns Reordering</Link>
<Link to="/ContextMenu">Context Menu</Link>
<Link to="/CustomizableRenderers">Customizable Renderers</Link>
<Link to="/RowGrouping">Row Grouping</Link>
<Link to="/HeaderFilters">Header Filters</Link>
<Link to="/InfiniteScrolling">Infinite Scrolling</Link>
<Link to="/MasterDetail">Master Detail</Link>
<Link to="/MillionCells">A Million Cells</Link>
<Link to="/NoRows">No Rows</Link>
<Link to="/ResizableGrid">Resizable Grid</Link>
<Link to="/RowsReordering">Rows Reordering</Link>
<Link to="/ScrollToCell">Scroll To Cell</Link>
<Link to="/TreeView">Tree View</Link>
<Link to="/VariableRowHeight">Variable Row Height</Link>
<Link to="/Animation">Animation</Link>
</nav>
<nav aria-labelledby={linksNavId} className={navClassname}>
<h2 id={linksNavId}>Links</h2>
<a
href="https://github.com/Comcast/react-data-grid/blob/main/README.md"
target="_blank"
rel="noreferrer"
>
Documentation
</a>
<a
href="https://github.com/Comcast/react-data-grid/blob/main/CHANGELOG.md"
target="_blank"
rel="noreferrer"
>
Changelog
</a>
<a
href="https://github.com/Comcast/react-data-grid/discussions"
target="_blank"
rel="noreferrer"
>
Discussions
</a>
<a
href="https://github.com/Comcast/react-data-grid/issues"
target="_blank"
rel="noreferrer"
>
Issues
</a>
</nav>
<h2>Direction</h2>
<label className={labelClassname}>
<input
type="checkbox"
checked={direction === 'rtl'}
onChange={() => onDirectionChange(direction === 'rtl' ? 'ltr' : 'rtl')}
/>
Right to left
</label>
</header>
);
}