fix(chapter3): use shadcn button variants in state demo

Replace the Ant Design dashed button type with the shadcn outline variant and include the state demo on the demo page.
This commit is contained in:
jiawei
2026-08-30 16:44:28 +08:00
parent f6d90efb0a
commit 7e0e3527e9
2 changed files with 36 additions and 0 deletions
@@ -0,0 +1,32 @@
// src/app/demo/_components/state.tsx
'use client';
import { Button } from '@/app/_components/shadcn/ui/button';
import { FC, useState } from 'react';
import clsx from 'clsx';
import $styles from './style.module.css';
const StateDemo: FC = () => {
const [count, setCount] = useState(1);
const [isShow, toggleShow] = useState(true);
return (
<div className={clsx($styles.container, 'w-[20rem]')}>
<h2 className="text-center">useState Demo</h2>
{isShow && <p className="text-center py-5">{count}</p>}
<div className="flex justify-around">
<Button onClick={() => setCount(count + 1)} variant="outline">
</Button>
<Button onClick={() => setCount(count - 1)} variant="outline">
</Button>
<Button onClick={() => toggleShow(!isShow)} variant="outline">
{isShow ? '显示' : '隐藏'}
</Button>
</div>
</div>
);
};
export default StateDemo;
+4
View File
@@ -2,6 +2,7 @@
// ...
import { FC } from 'react';
import { Button } from 'antd';
import StateDemo from './_components/state';
import $styles from './page.module.css';
@@ -15,6 +16,9 @@ const DemoPage: FC = () => (
3R教室
</Button>
</div>
<div className={$styles.demo}>
<StateDemo />
</div>
</div>
</div>
</div>