|
| 1 | +import React from 'react' |
| 2 | +import {DataTable, Table} from '@primer/react/drafts' |
| 3 | +import './BorderTesting.css' |
| 4 | +import { |
| 5 | + ThreeBarsIcon, |
| 6 | + MarkGithubIcon, |
| 7 | + ArrowSwitchIcon, |
| 8 | + GearIcon, |
| 9 | + CodeIcon, |
| 10 | + CreditCardIcon, |
| 11 | + MailIcon, |
| 12 | + ShieldLockIcon, |
| 13 | + BroadcastIcon, |
| 14 | + KeyIcon, |
| 15 | + OrganizationIcon, |
| 16 | + GlobeIcon, |
| 17 | + ReportIcon, |
| 18 | + RepoIcon, |
| 19 | + CodespacesIcon, |
| 20 | + PackageIcon, |
| 21 | + CopilotIcon, |
| 22 | + BrowserIcon, |
| 23 | + ReplyIcon, |
| 24 | + AppsIcon, |
| 25 | + ClockIcon, |
| 26 | + LogIcon, |
| 27 | + EyeIcon, |
| 28 | + FileCodeIcon, |
| 29 | + PeopleIcon, |
| 30 | + SearchIcon, |
| 31 | +} from '@primer/octicons-react' |
| 32 | +import {PageLayout, Button, TextInput, SegmentedControl, NavList, Box, Text, IconButton, Octicon} from '@primer/react' |
| 33 | + |
| 34 | +export default { |
| 35 | + title: 'Testing/Borders', |
| 36 | + parameters: { |
| 37 | + controls: {hideNoControlsWarning: true}, |
| 38 | + options: { |
| 39 | + showPanel: false, |
| 40 | + }, |
| 41 | + }, |
| 42 | +} |
| 43 | + |
| 44 | +type NavItem = { |
| 45 | + Icon: React.ElementType |
| 46 | + title: string |
| 47 | + ariaCurrent?: boolean |
| 48 | +} |
| 49 | + |
| 50 | +type NavGroup = { |
| 51 | + title?: string |
| 52 | + items: NavItem[] |
| 53 | +} |
| 54 | + |
| 55 | +const navGroups: NavGroup[] = [ |
| 56 | + { |
| 57 | + items: [ |
| 58 | + {Icon: GearIcon, title: 'General settings'}, |
| 59 | + {Icon: CodeIcon, title: 'Developer settings'}, |
| 60 | + ], |
| 61 | + }, |
| 62 | + { |
| 63 | + title: 'Access', |
| 64 | + items: [ |
| 65 | + {Icon: CreditCardIcon, title: 'Billing and plans'}, |
| 66 | + {Icon: MailIcon, title: 'Emails'}, |
| 67 | + {Icon: ShieldLockIcon, title: 'Password and authentication'}, |
| 68 | + {Icon: BroadcastIcon, title: 'Sessions'}, |
| 69 | + {Icon: KeyIcon, title: 'SSH and GPG keys'}, |
| 70 | + {Icon: OrganizationIcon, title: 'Organizations'}, |
| 71 | + {Icon: GlobeIcon, title: 'Enterprises'}, |
| 72 | + {Icon: ReportIcon, title: 'Moderation'}, |
| 73 | + ], |
| 74 | + }, |
| 75 | + { |
| 76 | + title: 'Code, planning, and automation', |
| 77 | + items: [ |
| 78 | + {Icon: RepoIcon, title: 'Repositories'}, |
| 79 | + {Icon: CodespacesIcon, title: 'Codespaces'}, |
| 80 | + {Icon: PackageIcon, title: 'Packages'}, |
| 81 | + {Icon: CopilotIcon, title: 'Copilot'}, |
| 82 | + {Icon: BrowserIcon, title: 'Pages'}, |
| 83 | + {Icon: ReplyIcon, title: 'Saved replies'}, |
| 84 | + ], |
| 85 | + }, |
| 86 | + { |
| 87 | + title: 'Security', |
| 88 | + items: [{Icon: ShieldLockIcon, title: 'Code security and analysis'}], |
| 89 | + }, |
| 90 | + { |
| 91 | + title: 'Integrations', |
| 92 | + items: [ |
| 93 | + {Icon: AppsIcon, title: 'Applications'}, |
| 94 | + {Icon: ClockIcon, title: 'Scheduled reminders'}, |
| 95 | + ], |
| 96 | + }, |
| 97 | + { |
| 98 | + title: 'Archives', |
| 99 | + items: [ |
| 100 | + {Icon: LogIcon, title: 'Security log'}, |
| 101 | + {Icon: LogIcon, title: 'Sponsorship log'}, |
| 102 | + ], |
| 103 | + }, |
| 104 | +] |
| 105 | + |
| 106 | +const data = [ |
| 107 | + {name: 'John Doe', age: 30, occupation: 'Software Engineer'}, |
| 108 | + {name: 'Jane Smith', age: 25, occupation: 'Product Manager'}, |
| 109 | + {name: 'Bob Johnson', age: 35, occupation: 'UX Designer'}, |
| 110 | +] |
| 111 | + |
| 112 | +export const BorderDemo = () => { |
| 113 | + return ( |
| 114 | + <> |
| 115 | + <Box sx={{backgroundColor: 'canvas.default', minHeight: '100vh'}}> |
| 116 | + <Box sx={{bg: 'canvas.inset', width: '100%', maxWidth: '100%'}}> |
| 117 | + <Box |
| 118 | + sx={{ |
| 119 | + px: 3, |
| 120 | + pt: 3, |
| 121 | + pb: 3, |
| 122 | + display: 'flex', |
| 123 | + gap: 3, |
| 124 | + alignItems: 'center', |
| 125 | + borderBottomColor: 'border.default', |
| 126 | + borderBottomWidth: 1, |
| 127 | + borderBottomStyle: 'solid', |
| 128 | + }} |
| 129 | + > |
| 130 | + <IconButton icon={ThreeBarsIcon} aria-label="Menu" /> |
| 131 | + <Octicon icon={MarkGithubIcon} size={32} /> |
| 132 | + <Box sx={{display: 'flex', gap: 2}}> |
| 133 | + <Text sx={{fontSize: 1, fontWeight: 'bold'}}>Settings</Text> |
| 134 | + </Box> |
| 135 | + </Box> |
| 136 | + </Box> |
| 137 | + <PageLayout |
| 138 | + containerWidth="xlarge" |
| 139 | + sx={{ |
| 140 | + pr: [0, 5, 5, 5, 5], |
| 141 | + pl: [0, 3, 3, 3, 3], |
| 142 | + maxWidth: 1280, |
| 143 | + backgroundColor: 'canvas.default', |
| 144 | + margin: '0 auto', |
| 145 | + borderColor: ['transparent', 'transparent', 'transparent', 'transparent', 'border.subtle'], |
| 146 | + }} |
| 147 | + > |
| 148 | + <PageLayout.Pane width="large" position="start" sx={{overflow: 'visible', mb: [0, 'inherit']}}> |
| 149 | + <Box sx={{px: 3, py: [0, 2]}}> |
| 150 | + <Box |
| 151 | + sx={{ |
| 152 | + display: 'flex', |
| 153 | + alignItems: 'center', |
| 154 | + px: 2, |
| 155 | + borderColor: 'border.default', |
| 156 | + borderBottomWidth: ['1px', 'none'], |
| 157 | + borderBottomStyle: ['solid', 'none'], |
| 158 | + pb: [3, 0], |
| 159 | + mb: [2, 0], |
| 160 | + }} |
| 161 | + > |
| 162 | + {/* <GitHubAvatar src="https://github.com/ghavatar/u/9919?s=200&v=4" size={40} /> */} |
| 163 | + <Box sx={{ml: 2}}> |
| 164 | + <Box sx={{fontWeight: 'bold'}}>tbenning</Box> |
| 165 | + <Box sx={{fontSize: 1, color: 'fg.muted'}}>Personal account</Box> |
| 166 | + </Box> |
| 167 | + <Box sx={{ml: 'auto'}}> |
| 168 | + <IconButton icon={ArrowSwitchIcon} aria-label="Switch settings context" sx={{color: 'fg.subtle'}} /> |
| 169 | + </Box> |
| 170 | + </Box> |
| 171 | + <Box sx={{display: ['none', 'block']}}> |
| 172 | + <NavList> |
| 173 | + {navGroups.map((group, groupIndex) => ( |
| 174 | + <NavList.Group key={groupIndex} title={group.title}> |
| 175 | + {group.items.map((item, itemIndex) => ( |
| 176 | + <NavList.Item key={itemIndex}> |
| 177 | + <NavList.LeadingVisual> |
| 178 | + <item.Icon /> |
| 179 | + </NavList.LeadingVisual> |
| 180 | + {item.title} |
| 181 | + </NavList.Item> |
| 182 | + ))} |
| 183 | + </NavList.Group> |
| 184 | + ))} |
| 185 | + </NavList> |
| 186 | + </Box> |
| 187 | + </Box> |
| 188 | + </PageLayout.Pane> |
| 189 | + <PageLayout.Content> |
| 190 | + <Box sx={{py: 1, px: [3, 0, 0, 0, 0], display: 'flex', flexDirection: 'column', gap: 3}}> |
| 191 | + <h1>Heading</h1> |
| 192 | + <Box sx={{display: 'flex', gap: '8px'}}> |
| 193 | + <TextInput leadingVisual={SearchIcon} /> |
| 194 | + <Button>A default button</Button> |
| 195 | + <Button variant="invisible">An invisible button</Button> |
| 196 | + <Button variant="primary">A primary button</Button> |
| 197 | + </Box> |
| 198 | + |
| 199 | + <Box |
| 200 | + sx={{ |
| 201 | + border: 'solid 1px var(--borderColor-default)', |
| 202 | + borderRadius: 'var(--borderRadius-medium)', |
| 203 | + backgroundColor: 'var(--bgColor-muted)', |
| 204 | + marginBottom: 'var(--base-size-24)', |
| 205 | + width: '100%', |
| 206 | + }} |
| 207 | + > |
| 208 | + <Box |
| 209 | + sx={{ |
| 210 | + padding: 'var(--base-size-8)', |
| 211 | + borderBottom: 'solid 1px var(--borderColor-default)', |
| 212 | + display: 'flex', |
| 213 | + gap: '8px', |
| 214 | + }} |
| 215 | + > |
| 216 | + <Button>A default button</Button> |
| 217 | + <Button variant="invisible">An invisible button</Button> |
| 218 | + <SegmentedControl aria-label="File view"> |
| 219 | + <SegmentedControl.IconButton defaultSelected aria-label={'Preview'} icon={EyeIcon} /> |
| 220 | + <SegmentedControl.IconButton aria-label={'Raw'} icon={FileCodeIcon} /> |
| 221 | + <SegmentedControl.IconButton aria-label={'Blame'} icon={PeopleIcon} /> |
| 222 | + </SegmentedControl> |
| 223 | + </Box> |
| 224 | + <Box sx={{backgroundColor: 'var(--bgColor-default)', padding: 'var(--base-size-36)'}}> |
| 225 | + This is a box oh wow |
| 226 | + </Box> |
| 227 | + </Box> |
| 228 | + <Table.Container> |
| 229 | + <h1 className="sr-only" id="table-heading"> |
| 230 | + Avatar |
| 231 | + </h1> |
| 232 | + <DataTable |
| 233 | + aria-labelledby="table-heading" |
| 234 | + data={data} |
| 235 | + columns={[ |
| 236 | + {header: 'Name', field: 'name', rowHeader: true}, |
| 237 | + {header: 'Age', field: 'age'}, |
| 238 | + {header: 'Occupation', field: 'occupation'}, |
| 239 | + ]} |
| 240 | + /> |
| 241 | + </Table.Container> |
| 242 | + </Box> |
| 243 | + </PageLayout.Content> |
| 244 | + </PageLayout> |
| 245 | + </Box> |
| 246 | + </> |
| 247 | + ) |
| 248 | +} |
0 commit comments