chore: add more stories (#27403)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
非法操作
2025-10-29 14:33:43 +08:00
committed by GitHub
parent 23b49b8304
commit f092bc1912
100 changed files with 6144 additions and 30 deletions

View File

@@ -0,0 +1,59 @@
import type { Meta, StoryObj } from '@storybook/nextjs'
import { useMemo, useState } from 'react'
import Sort from '.'
const SORT_ITEMS = [
{ value: 'created_at', name: 'Created time' },
{ value: 'updated_at', name: 'Updated time' },
{ value: 'latency', name: 'Latency' },
]
const SortPlayground = () => {
const [sortBy, setSortBy] = useState('-created_at')
const { order, value } = useMemo(() => {
const isDesc = sortBy.startsWith('-')
return {
order: isDesc ? '-' : '',
value: sortBy.replace('-', '') || 'created_at',
}
}, [sortBy])
return (
<div className="flex w-full max-w-xl flex-col gap-4 rounded-2xl border border-divider-subtle bg-components-panel-bg p-6">
<div className="flex items-center justify-between text-xs uppercase tracking-[0.18em] text-text-tertiary">
<span>Sort control</span>
<code className="rounded-md bg-background-default px-2 py-1 text-[11px] text-text-tertiary">
sort_by="{sortBy}"
</code>
</div>
<Sort
order={order}
value={value}
items={SORT_ITEMS}
onSelect={(next) => {
setSortBy(next as string)
}}
/>
</div>
)
}
const meta = {
title: 'Base/Data Display/Sort',
component: SortPlayground,
parameters: {
layout: 'centered',
docs: {
description: {
component: 'Sorting trigger used in log tables. Includes dropdown selection and quick toggle between ascending and descending.',
},
},
},
tags: ['autodocs'],
} satisfies Meta<typeof SortPlayground>
export default meta
type Story = StoryObj<typeof meta>
export const Playground: Story = {}