dify/web/app/components/base/spinner/index.stories.tsx
非法操作 f092bc1912
chore: add more stories (#27403)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-29 14:33:43 +08:00

51 lines
1.4 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/nextjs'
import { useState } from 'react'
import Spinner from '.'
const SpinnerPlayground = ({
loading = true,
}: {
loading?: boolean
}) => {
const [isLoading, setIsLoading] = useState(loading)
return (
<div className="flex w-full max-w-xs flex-col items-center gap-4 rounded-2xl border border-divider-subtle bg-components-panel-bg p-6">
<p className="text-xs uppercase tracking-[0.18em] text-text-tertiary">Spinner</p>
<Spinner loading={isLoading} className="text-primary-500" />
<button
type="button"
className="rounded-md border border-divider-subtle bg-background-default px-3 py-1 text-xs font-medium text-text-secondary hover:bg-state-base-hover"
onClick={() => setIsLoading(prev => !prev)}
>
{isLoading ? 'Stop' : 'Start'} loading
</button>
</div>
)
}
const meta = {
title: 'Base/Feedback/Spinner',
component: SpinnerPlayground,
parameters: {
layout: 'centered',
docs: {
description: {
component: 'Minimal spinner powered by Tailwind utilities. Toggle the state to inspect motion-reduced behaviour.',
},
},
},
argTypes: {
loading: { control: 'boolean' },
},
args: {
loading: true,
},
tags: ['autodocs'],
} satisfies Meta<typeof SpinnerPlayground>
export default meta
type Story = StoryObj<typeof meta>
export const Playground: Story = {}