card.stories.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. import React, { useState } from 'react';
  2. import {
  3. Space,
  4. Button,
  5. Avatar,
  6. Typography,
  7. Row,
  8. Tabs,
  9. TabPane,
  10. Col,
  11. Skeleton,
  12. Switch,
  13. Rating,
  14. } from '@douyinfe/semi-ui/';
  15. import Card from '../index';
  16. import CardGroup from '../cardGroup';
  17. import {
  18. IconChevronRight,
  19. IconLikeThumb,
  20. IconLikeHeart,
  21. IconEdit,
  22. IconWrench,
  23. } from '@douyinfe/semi-icons';
  24. const { Text } = Typography;
  25. const { Meta } = Card;
  26. export default {
  27. title: 'Card',
  28. }
  29. export const Default = () => (
  30. <Space wrap>
  31. <Card
  32. title="基础卡片"
  33. style={{
  34. width: 360,
  35. }}
  36. aria-label='basic card'
  37. headerExtraContent={<Text link={{}}>更多</Text>}
  38. >
  39. Semi Design 是由互娱社区前端团队与 UED
  40. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  41. Web 应用。
  42. </Card>
  43. <Card
  44. title="titleisstringtitleisstringtitleisstringtitleisstringtitleisstring"
  45. style={{
  46. width: 360,
  47. }}
  48. headerExtraContent={<Text link={{}}>更多</Text>}
  49. >
  50. Semi Design 是由互娱社区前端团队与 UED
  51. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  52. Web 应用。
  53. </Card>
  54. <Card
  55. title="标题为字符串标题特别长标题特别长标题特别长标题特别长标题特别长"
  56. style={{
  57. width: 360,
  58. }}
  59. headerExtraContent={<Text link={{}}>更多</Text>}
  60. >
  61. Semi Design 是由互娱社区前端团队与 UED
  62. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  63. Web 应用。
  64. </Card>
  65. <Card
  66. title={<div>标题为node标题特别长标题特别长标题特别长标题特别长标题特别长</div>}
  67. style={{
  68. width: 360,
  69. }}
  70. headerExtraContent={<Text link={{}}>更多</Text>}
  71. >
  72. Semi Design 是由互娱社区前端团队与 UED
  73. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  74. Web 应用。
  75. </Card>
  76. <Card
  77. header={
  78. <div>
  79. 头部内容为node头部内容特别长头部内容特别长头部内容特别长头部内容特别长头部内容特别长
  80. </div>
  81. }
  82. style={{
  83. width: 360,
  84. }}
  85. headerExtraContent={<Text link={{}}>更多</Text>}
  86. >
  87. Semi Design 是由互娱社区前端团队与 UED
  88. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  89. Web 应用。
  90. </Card>
  91. <Card
  92. header={<div>headerheaderheaderheaderheaderheaderheaderheaderheaderheader</div>}
  93. style={{
  94. width: 360,
  95. }}
  96. headerExtraContent={<Text link={{}}>更多</Text>}
  97. >
  98. Semi Design 是由互娱社区前端团队与 UED
  99. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  100. Web 应用。
  101. </Card>
  102. </Space>
  103. );
  104. export function Simple() {
  105. return (
  106. <Space align="start" vertical spacing="medium">
  107. <Card
  108. style={{
  109. width: 360,
  110. }}
  111. >
  112. Semi Design 是由互娱社区前端团队与 UED 团队共同设计开发并维护的设计系统。
  113. </Card>
  114. <Card
  115. style={{
  116. width: 360,
  117. }}
  118. bodyStyle={{
  119. display: 'flex',
  120. alignItems: 'center',
  121. justifyContent: 'space-between',
  122. }}
  123. >
  124. <Meta
  125. title="Semi Doc"
  126. avatar={
  127. <Avatar
  128. size="default"
  129. alt="Card meta avatar"
  130. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  131. />
  132. }
  133. />
  134. <Text link={{}}>
  135. <IconChevronRight />
  136. </Text>
  137. </Card>
  138. </Space>
  139. );
  140. }
  141. export const Cover = () => (
  142. <Card
  143. style={{
  144. width: 360,
  145. }}
  146. cover={
  147. <img
  148. alt="example"
  149. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/card-cover-docs-demo.jpeg"
  150. />
  151. }
  152. >
  153. <Meta title="卡片封面" />
  154. </Card>
  155. );
  156. export const Bordered = () => (
  157. <div
  158. style={{
  159. display: 'inline-block',
  160. padding: 20,
  161. backgroundColor: 'var(--semi-color-fill-0)',
  162. }}
  163. >
  164. <Card
  165. style={{
  166. width: 360,
  167. }}
  168. bordered={false}
  169. title="Semi Design"
  170. >
  171. 基于 Semi Design 的中后台设计案例聚合分享平台,海量案例和模板代码助力体验 & 效率提升。
  172. </Card>
  173. </div>
  174. );
  175. export const HeaderLineFooterLine = () => (
  176. <Card
  177. style={{
  178. width: 360,
  179. }}
  180. title="Semi Design"
  181. headerLine={true}
  182. footerLine={false}
  183. footer="footer"
  184. >
  185. 基于 Semi Design 的中后台设计案例聚合分享平台,海量案例和模板代码助力体验 & 效率提升。
  186. </Card>
  187. );
  188. export const Shadows = () => (
  189. <Space>
  190. <Card
  191. style={{
  192. width: 360,
  193. }}
  194. title="没有设置shadows"
  195. >
  196. 基于 Semi Design 的中后台设计案例聚合分享平台,海量案例和模板代码助力体验 & 效率提升。
  197. </Card>
  198. <Card
  199. style={{
  200. width: 360,
  201. }}
  202. title="shadows为hover"
  203. shadows="hover"
  204. >
  205. 基于 Semi Design 的中后台设计案例聚合分享平台,海量案例和模板代码助力体验 & 效率提升。
  206. </Card>
  207. <Card
  208. style={{
  209. width: 360,
  210. }}
  211. title="shadows为always"
  212. shadows="always"
  213. >
  214. 基于 Semi Design 的中后台设计案例聚合分享平台,海量案例和模板代码助力体验 & 效率提升。
  215. </Card>
  216. </Space>
  217. );
  218. export const MetaDemo = () => (
  219. <Card
  220. style={{
  221. width: 360,
  222. }}
  223. title={
  224. <Meta
  225. title="Semi Doc"
  226. description="全面、易用、优质"
  227. avatar={
  228. <Avatar
  229. alt="Card meta avatar"
  230. size="default"
  231. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  232. />
  233. }
  234. />
  235. }
  236. headerExtraContent={<Text link={{}}>More</Text>}
  237. cover={
  238. <img
  239. alt="example"
  240. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/card-cover-docs-demo.jpeg"
  241. />
  242. }
  243. footerLine={true}
  244. footerStyle={{
  245. display: 'flex',
  246. justifyContent: 'flex-end',
  247. }}
  248. footer={
  249. <Space>
  250. <Button theme="borderless" type="primary">
  251. 精选案例
  252. </Button>
  253. <Button theme="solid" type="primary">
  254. 开始使用
  255. </Button>
  256. </Space>
  257. }
  258. >
  259. Semi Design 是由互娱社区前端团队与 UED
  260. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  261. Web 应用。
  262. </Card>
  263. );
  264. export const Inner = () => (
  265. <Card
  266. title="Card title"
  267. style={{
  268. width: 360,
  269. }}
  270. >
  271. <Card
  272. title="Inner Card title"
  273. style={{
  274. marginBottom: 20,
  275. }}
  276. headerExtraContent={<Text link={{}}>More</Text>}
  277. >
  278. Inner Card content
  279. </Card>
  280. <Card title="Inner Card title" headerExtraContent={<Text link={{}}>More</Text>}>
  281. Inner Card content
  282. </Card>
  283. </Card>
  284. );
  285. export const Grid = () => (
  286. <div
  287. style={{
  288. backgroundColor: 'var(--semi-color-fill-0)',
  289. padding: 20,
  290. }}
  291. >
  292. <Row gutter={[16, 16]}>
  293. <Col span={8}>
  294. <Card title="Card Title" bordered={false}>
  295. Card Content
  296. </Card>
  297. </Col>
  298. <Col span={8}>
  299. <Card title="Card Title" bordered={false}>
  300. Card Content
  301. </Card>
  302. </Col>
  303. <Col span={8}>
  304. <Card title="Card Title" bordered={false}>
  305. Card Content
  306. </Card>
  307. </Col>
  308. </Row>
  309. <Row gutter={[16, 16]}>
  310. <Col span={16}>
  311. <Card title="Card Title" bordered={false}>
  312. Card Content
  313. </Card>
  314. </Col>
  315. <Col span={8}>
  316. <Card title="Card Title" bordered={false}>
  317. Card Content
  318. </Card>
  319. </Col>
  320. </Row>
  321. </div>
  322. );
  323. export function Loading() {
  324. const [loading, setLoading] = useState(true);
  325. const { Meta } = Card;
  326. const { Title, Paragraph, Image } = Skeleton;
  327. return (
  328. <Space vertical align="start" spacing="medium">
  329. <Switch onChange={v => setLoading(!v)} aria-label='switch card loading status'/>
  330. <Card
  331. style={{
  332. width: 360,
  333. }}
  334. loading={loading}
  335. aria-busy={loading}
  336. >
  337. <Meta title="Semi Doc" description="全面、易用、优质" />
  338. </Card>
  339. <Card
  340. style={{
  341. width: 360,
  342. }}
  343. title={
  344. <Meta
  345. title={
  346. <Skeleton
  347. style={{
  348. width: 80,
  349. }}
  350. placeholder={<Title />}
  351. loading={loading}
  352. >
  353. <Typography.Title heading={5}>Semi Doc</Typography.Title>
  354. </Skeleton>
  355. }
  356. description={
  357. <Skeleton
  358. style={{
  359. width: 150,
  360. marginTop: 12,
  361. }}
  362. placeholder={<Paragraph rows={1} />}
  363. loading={loading}
  364. >
  365. <Typography.Text>全面、易用、优质</Typography.Text>
  366. </Skeleton>
  367. }
  368. avatar={
  369. <Skeleton placeholder={<Skeleton.Avatar />} loading={loading}>
  370. <Avatar
  371. size="default"
  372. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  373. />
  374. </Skeleton>
  375. }
  376. />
  377. }
  378. headerExtraContent={
  379. <Skeleton
  380. style={{
  381. width: 50,
  382. }}
  383. placeholder={<Paragraph rows={1} />}
  384. loading={loading}
  385. >
  386. <Typography.Text link={{}}>More</Typography.Text>
  387. </Skeleton>
  388. }
  389. cover={
  390. <Skeleton
  391. style={{
  392. width: '100%',
  393. height: 110,
  394. }}
  395. placeholder={<Image />}
  396. loading={loading}
  397. >
  398. <img
  399. alt="example"
  400. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/card-cover-docs-demo.jpeg"
  401. />
  402. </Skeleton>
  403. }
  404. ></Card>
  405. </Space>
  406. );
  407. }
  408. export const WithTabs = () => (
  409. <Card title="Card title">
  410. <Tabs
  411. type="line"
  412. style={{
  413. marginTop: -20,
  414. marginBottom: -20,
  415. }}
  416. >
  417. <TabPane tab="Tab 1" itemKey="1">
  418. <p>content1</p>
  419. <p>content1</p>
  420. <p>content1</p>
  421. </TabPane>
  422. <TabPane tab="Tab 2" itemKey="2">
  423. <p>content2</p>
  424. <p>content2</p>
  425. <p>content2</p>
  426. </TabPane>
  427. </Tabs>
  428. </Card>
  429. );
  430. export const Actions = () => (
  431. <Space align="start">
  432. <Card
  433. style={{
  434. width: 360,
  435. }}
  436. title={
  437. <Meta
  438. title="Semi Doc"
  439. description="全面、易用、优质"
  440. avatar={
  441. <Avatar
  442. size="default"
  443. alt="Card meta avatar"
  444. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  445. />
  446. }
  447. />
  448. }
  449. actions={[<Rating defaultValue={4} />]}
  450. headerLine={false}
  451. footerLine={false}
  452. footerStyle={{
  453. display: 'flex',
  454. justifyContent: 'flex-end',
  455. }}
  456. footer={
  457. <Space>
  458. <Button theme="solid" type="primary">
  459. 打分
  460. </Button>
  461. </Space>
  462. }
  463. >
  464. Semi Design 是由互娱社区前端团队与 UED
  465. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  466. Web 应用。
  467. </Card>
  468. <Card
  469. style={{
  470. width: 360,
  471. }}
  472. title={
  473. <Meta
  474. title="Semi Doc"
  475. description="全面、易用、优质"
  476. avatar={
  477. <Avatar
  478. alt="Card meta avatar"
  479. size="default"
  480. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  481. />
  482. }
  483. />
  484. }
  485. actions={[<IconLikeThumb />, <IconLikeHeart />, <IconEdit />, <IconWrench />]}
  486. headerLine={false}
  487. >
  488. Semi Design 是由互娱社区前端团队与 UED
  489. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  490. Web 应用。
  491. </Card>
  492. </Space>
  493. );
  494. export const CardGroupDemo = () => (
  495. <CardGroup spacing={12}>
  496. {new Array(3).fill(null).map((v, idx) => (
  497. <Card
  498. key={idx}
  499. style={{
  500. width: 300,
  501. }}
  502. title={
  503. <Meta
  504. title="Semi Doc"
  505. description="全面、易用、优质"
  506. avatar={
  507. <Avatar
  508. alt="Card meta avatar"
  509. size="default"
  510. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/card-meta-avatar-docs-demo.jpg"
  511. />
  512. }
  513. />
  514. }
  515. headerExtraContent={<Text link>More</Text>}
  516. cover={
  517. <img
  518. alt="example"
  519. src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/card-cover-docs-demo.jpeg"
  520. />
  521. }
  522. >
  523. Semi Design 是由互娱社区前端团队与 UED 团队共同设计开发并维护的设计系统。
  524. </Card>
  525. ))}
  526. </CardGroup>
  527. );
  528. export const CardGroupGrid = () => (
  529. <CardGroup type="grid">
  530. {new Array(7).fill(null).map((v, idx) => (
  531. <Card
  532. key={idx}
  533. shadows="hover"
  534. title="Card title"
  535. headerLine={false}
  536. style={{
  537. width: 260,
  538. }}
  539. headerExtraContent={<Text link>More</Text>}
  540. >
  541. <Text>Card content</Text>
  542. </Card>
  543. ))}
  544. </CardGroup>
  545. );