refactor(ui): update button elements to include type attribute

- Added type="button" to button elements in DividerWithText and Icon stories for better accessibility and to prevent unintended form submissions.
- Improved code consistency across button components in the UI stories.
This commit is contained in:
MyPrototypeWhat 2025-09-16 17:15:40 +08:00
parent f83c3e171e
commit 56af6f43c0
2 changed files with 18 additions and 10 deletions

View File

@ -92,12 +92,18 @@ export const MultipleUsage: Story = {
placeholder="请输入密码"
/>
</div>
<button className="w-full bg-blue-600 text-white py-2 rounded-md hover:bg-blue-700"></button>
<button type="button" className="w-full bg-blue-600 text-white py-2 rounded-md hover:bg-blue-700">
</button>
<DividerWithText text="或" />
<button className="w-full border border-gray-300 py-2 rounded-md hover:bg-gray-50">使 Google </button>
<button className="w-full border border-gray-300 py-2 rounded-md hover:bg-gray-50">使 GitHub </button>
<button type="button" className="w-full border border-gray-300 py-2 rounded-md hover:bg-gray-50">
使 Google
</button>
<button type="button" className="w-full border border-gray-300 py-2 rounded-md hover:bg-gray-50">
使 GitHub
</button>
</div>
</div>
</div>

View File

@ -178,13 +178,13 @@ export const IconStates: Story = {
render: () => (
<div className="space-y-4">
<div className="flex items-center gap-4">
<button className="rounded p-2 hover:bg-gray-100">
<button type="button" className="rounded p-2 hover:bg-gray-100">
<EditIcon size={20} />
</button>
<button className="rounded p-2 hover:bg-gray-100" disabled>
<button type="button" className="rounded p-2 hover:bg-gray-100" disabled>
<EditIcon size={20} className="opacity-50" />
</button>
<button className="rounded bg-blue-500 p-2 text-white hover:bg-blue-600">
<button type="button" className="rounded bg-blue-500 p-2 text-white hover:bg-blue-600">
<EditIcon size={20} />
</button>
</div>
@ -205,13 +205,13 @@ export const InContext: Story = {
<div className="flex items-center justify-between">
<h3 className="font-semibold">Document.pdf</h3>
<div className="flex gap-2">
<button className="rounded p-1 hover:bg-gray-100">
<button type="button" className="rounded p-1 hover:bg-gray-100">
<CopyIcon size={16} />
</button>
<button className="rounded p-1 hover:bg-gray-100">
<button type="button" className="rounded p-1 hover:bg-gray-100">
<EditIcon size={16} />
</button>
<button className="rounded p-1 hover:bg-gray-100">
<button type="button" className="rounded p-1 hover:bg-gray-100">
<DeleteIcon size={16} />
</button>
</div>
@ -224,7 +224,9 @@ export const InContext: Story = {
<span className="font-medium">Image Processing</span>
</div>
<p className="mb-3 text-sm text-gray-600">Process your images with advanced AI tools</p>
<button className="flex items-center gap-2 rounded bg-blue-500 px-3 py-1 text-sm text-white hover:bg-blue-600">
<button
type="button"
className="flex items-center gap-2 rounded bg-blue-500 px-3 py-1 text-sm text-white hover:bg-blue-600">
<OcrIcon size={16} />
<span>Extract Text</span>
</button>