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:
@@ -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;
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
// ...
|
// ...
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
|
import StateDemo from './_components/state';
|
||||||
|
|
||||||
import $styles from './page.module.css';
|
import $styles from './page.module.css';
|
||||||
|
|
||||||
@@ -15,6 +16,9 @@ const DemoPage: FC = () => (
|
|||||||
3R教室
|
3R教室
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className={$styles.demo}>
|
||||||
|
<StateDemo />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user