MCPcopy Index your code
hub / github.com/primer/react / WithSorting

Function WithSorting

packages/react/src/DataTable/DataTable.features.stories.tsx:261–331  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259)
260
261export const WithSorting = () => {
262 const rows = Array.from(data).sort((a, b) => {
263 return b.updatedAt - a.updatedAt
264 })
265 return (
266 <Table.Container>
267 <Table.Title as="h2" id="repositories">
268 Repositories
269 </Table.Title>
270 <Table.Subtitle as="p" id="repositories-subtitle">
271 A subtitle could appear here to give extra context to the data.
272 </Table.Subtitle>
273 <DataTable
274 aria-labelledby="repositories"
275 aria-describedby="repositories-subtitle"
276 data={rows}
277 columns={[
278 {
279 header: 'Repository',
280 field: 'name',
281 rowHeader: true,
282 sortBy: 'alphanumeric',
283 },
284 {
285 header: 'Type',
286 field: 'type',
287 renderCell: row => {
288 return <Label>{uppercase(row.type)}</Label>
289 },
290 },
291 {
292 header: 'Updated',
293 field: 'updatedAt',
294 sortBy: 'datetime',
295 renderCell: row => {
296 return <RelativeTime date={new Date(row.updatedAt)} />
297 },
298 },
299 {
300 header: 'Dependabot',
301 field: 'securityFeatures.dependabot',
302 renderCell: row => {
303 return row.securityFeatures.dependabot.length > 0 ? (
304 <LabelGroup>
305 {row.securityFeatures.dependabot.map(feature => {
306 return <Label key={feature}>{uppercase(feature)}</Label>
307 })}
308 </LabelGroup>
309 ) : null
310 },
311 },
312 {
313 header: 'Code scanning',
314 field: 'securityFeatures.codeScanning',
315 renderCell: row => {
316 return row.securityFeatures.codeScanning.length > 0 ? (
317 <LabelGroup>
318 {row.securityFeatures.codeScanning.map(feature => {

Callers

nothing calls this directly

Calls 1

uppercaseFunction · 0.70

Tested by

no test coverage detected