11import React , { useState } from 'react' ;
2- import { Button } from 'tdesign-mobile-react' ;
2+ import { Button , Skeleton } from 'tdesign-mobile-react' ;
33import TDemoBlock from '../../../site/mobile/components/DemoBlock' ;
44import TDemoHeader from '../../../site/mobile/components/DemoHeader' ;
55import './style/index.less' ;
66import BaseDemo from './base' ;
77import TextDemo from './advance' ;
8+ import DraggableDemo from './draggable' ;
9+ import CollapsibleDemo from './collapsible' ;
810
911export default function FabDemo ( ) {
1012 const [ type , setType ] = useState ( 'base' ) ;
1113
1214 const changeType = ( type ) => setType ( type ) ;
15+ const rowCols = [ { size : '163.5px' , borderRadius : '12px' } , 1 , { width : '61%' } ] ;
16+
17+ const getButtonNode = ( type : string , name : string ) => (
18+ < Button className = "fab-btn" theme = "primary" variant = "outline" size = "large" block onClick = { ( ) => changeType ( type ) } >
19+ { name }
20+ </ Button >
21+ ) ;
1322 return (
1423 < div className = "tdesign-mobile-demo" >
1524 < TDemoHeader
@@ -18,31 +27,30 @@ export default function FabDemo() {
1827 />
1928
2029 < TDemoBlock title = "01 类型" summary = "纯图标悬浮按钮" padding >
21- < Button
22- className = "fab-btn"
23- theme = "primary"
24- variant = "outline"
25- size = "large"
26- block
27- onClick = { ( ) => changeType ( 'base' ) }
28- >
29- 纯图标悬浮按钮
30- </ Button >
30+ { getButtonNode ( 'base' , '纯图标悬浮按钮' ) }
3131 </ TDemoBlock >
3232 < TDemoBlock summary = "图标加文字悬浮按钮" padding >
33- < Button
34- className = "fab-btn"
35- theme = "primary"
36- variant = "outline"
37- size = "large"
38- block
39- onClick = { ( ) => changeType ( 'advance' ) }
40- >
41- 图标加文字悬浮按钮
42- </ Button >
33+ { getButtonNode ( 'advance' , '图标加文字悬浮按钮' ) }
34+ </ TDemoBlock >
35+ < TDemoBlock title = "02 组件样式" summary = "可移动悬浮按钮" padding >
36+ { getButtonNode ( 'draggable' , '可移动悬浮按钮' ) }
37+ </ TDemoBlock >
38+ < TDemoBlock summary = "带自动收缩功能" padding >
39+ { getButtonNode ( 'collapsible' , '带自动收缩功能' ) }
40+ </ TDemoBlock >
41+ < TDemoBlock padding >
42+ { [ 1 , 2 ] . map ( ( item ) => (
43+ < div className = "group" key = { item } >
44+ < Skeleton rowCol = { rowCols } loading = { true } />
45+ < Skeleton rowCol = { rowCols } loading = { true } />
46+ </ div >
47+ ) ) }
4348 </ TDemoBlock >
4449
45- { type === 'base' ? < BaseDemo /> : < TextDemo /> }
50+ { type === 'base' && < BaseDemo /> }
51+ { type === 'advance' && < TextDemo /> }
52+ { type === 'draggable' && < DraggableDemo /> }
53+ { type === 'collapsible' && < CollapsibleDemo /> }
4654 </ div >
4755 ) ;
4856}
0 commit comments