|
| 1 | +import React from 'react'; |
| 2 | +import { BasicTypographyEllipsis, ConfigProvider } from '@actiontech/dms-kit'; |
| 3 | +import { Space, Typography } from 'antd'; |
| 4 | + |
| 5 | +const { Text } = Typography; |
| 6 | + |
| 7 | +const BasicTypographyEllipsisDemo = () => { |
| 8 | + const shortText = '这是一段短文本'; |
| 9 | + const longText = |
| 10 | + '这是一段很长的文本内容,用于演示文本超出容器宽度时的省略效果。当文本内容超过容器宽度时,会自动显示省略号,鼠标悬停可以查看完整内容,并且支持复制功能。'; |
| 11 | + const veryLongText = |
| 12 | + '这是一段超长的文本内容,用于演示 tooltipLimitLength 功能。当文本长度超过 tooltipLimitLength 设置的值时,tooltip 中也会显示省略号,避免 tooltip 内容过长影响用户体验。这段文本会持续很长很长,用于测试 tooltip 长度限制功能是否正常工作。在实际应用中,这个功能对于展示日志、错误信息等长文本非常有用。'; |
| 13 | + |
| 14 | + return ( |
| 15 | + <ConfigProvider> |
| 16 | + <Space direction="vertical" size="large" style={{ width: '100%' }}> |
| 17 | + <div> |
| 18 | + <Text strong style={{ display: 'block', marginBottom: 8 }}> |
| 19 | + 基础用法: |
| 20 | + </Text> |
| 21 | + <div style={{ maxWidth: 300 }}> |
| 22 | + <BasicTypographyEllipsis textCont={longText} /> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + |
| 26 | + <div> |
| 27 | + <Text strong style={{ display: 'block', marginBottom: 8 }}> |
| 28 | + 短文本(不会省略): |
| 29 | + </Text> |
| 30 | + <div style={{ maxWidth: 300 }}> |
| 31 | + <BasicTypographyEllipsis textCont={shortText} /> |
| 32 | + </div> |
| 33 | + </div> |
| 34 | + |
| 35 | + <div> |
| 36 | + <Text strong style={{ display: 'block', marginBottom: 8 }}> |
| 37 | + 禁用复制功能: |
| 38 | + </Text> |
| 39 | + <div style={{ maxWidth: 300 }}> |
| 40 | + <BasicTypographyEllipsis textCont={longText} copyable={false} /> |
| 41 | + </div> |
| 42 | + </div> |
| 43 | + |
| 44 | + <div> |
| 45 | + <Text strong style={{ display: 'block', marginBottom: 8 }}> |
| 46 | + 限制 Tooltip 长度(tooltipLimitLength=50): |
| 47 | + </Text> |
| 48 | + <div style={{ maxWidth: 300 }}> |
| 49 | + <BasicTypographyEllipsis |
| 50 | + textCont={veryLongText} |
| 51 | + tooltipLimitLength={50} |
| 52 | + /> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div> |
| 57 | + <Text strong style={{ display: 'block', marginBottom: 8 }}> |
| 58 | + 自定义 Tooltip 最大宽度(tooltipsMaxWidth=400): |
| 59 | + </Text> |
| 60 | + <div style={{ maxWidth: 300 }}> |
| 61 | + <BasicTypographyEllipsis |
| 62 | + textCont={longText} |
| 63 | + tooltipsMaxWidth={400} |
| 64 | + /> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + </Space> |
| 68 | + </ConfigProvider> |
| 69 | + ); |
| 70 | +}; |
| 71 | + |
| 72 | +export default BasicTypographyEllipsisDemo; |
0 commit comments