Skip to content

fix(configprovider): 调整demo展示 #3232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions src/packages/configprovider/demo.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,36 @@ import Header from '@/sites/components/header'
import Demo1 from './demos/taro/demo1'
import Demo2 from './demos/taro/demo2'
import Demo3 from './demos/taro/demo3'
import Demo4 from './demos/taro/demo4'
import Demo5 from './demos/taro/demo5'
import { useTranslate } from '@/sites/assets/locale/taro'

const ConfigProviderDemo = () => {
const [translated] = useTranslate({
'zh-CN': {
title1: 'Textarea 默认-禁用',
title2: 'Textarea 英文-禁用',
defaultTheme: '默认主题',
customTheme: `定制主题${harmony() ? '【暂不支持】' : ''}`,
text: 'Textarea 中文与英文',
theme: '默认主题与定制主题',
RTL: harmony() ? 'RTL【暂不支持】' : 'RTL',
},
'zh-TW': {
title1: 'Textarea 默認用法-禁用',
title2: 'Textarea 英文-禁用',
defaultTheme: '默認主題',
customTheme: `定制主題${harmony() ? '【暂不支持】' : ''}`,
text: 'Textarea 中文与英文',
theme: '默認主題与定制主題',
RTL: harmony() ? 'RTL【暂不支持】' : 'RTL',
},
'en-US': {
title1: 'Textarea default + disabled',
title2: 'Textarea en-US + disabled',
customTheme: 'Custom Theme',
defaultTheme: `Default Theme ${harmony() ? '[Pendding]' : ''}`,
text: 'Textarea zh-CN and en-US',
theme: 'Default Theme And Custom Theme',
RTL: harmony() ? 'RTL[Pendding]' : 'RTL',
},
})
return (
<>
<Header />
<ScrollView className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<View className="h2">{translated.defaultTheme}</View>
<View className="h2">{translated.theme}</View>
<Demo1 />
<View className="h2">{translated.customTheme}</View>
<View className="h2">{translated.text}</View>
<Demo2 />
<View className="h2">{translated.title1}</View>
<Demo3 />
<View className="h2">{translated.title2}</View>
<Demo4 />
<View className="h2">{translated.RTL}</View>
<Demo5 />
<Demo3 />
</ScrollView>
</>
)
Expand Down
30 changes: 9 additions & 21 deletions src/packages/configprovider/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,32 @@ import React from 'react'
import Demo1 from './demos/h5/demo1'
import Demo2 from './demos/h5/demo2'
import Demo3 from './demos/h5/demo3'
import Demo4 from './demos/h5/demo4'
import Demo5 from './demos/h5/demo5'
import { useTranslate } from '@/sites/assets/locale'

const ConfigProviderDemo = () => {
const [translated] = useTranslate({
'zh-CN': {
title1: 'Textarea 默认',
title2: 'Textarea 英文',
defaultTheme: '默认主题',
customTheme: '定制主题',
text: 'Textarea 中文与英文',
theme: '默认主题与定制主题',
},
'zh-TW': {
title1: '默認用法',
title2: 'Textarea 英文',
defaultTheme: '默認主題',
customTheme: '定制主題',
text: 'Textarea 中文与英文',
theme: '默認主題与定制主題',
},
'en-US': {
title1: 'Textarea default',
title2: 'Textarea en-US',
customTheme: 'Custom Theme',
defaultTheme: 'Default Theme',
text: 'Textarea zh-CN and en-US',
theme: 'Default Theme And Custom Theme',
},
})
return (
<>
<div className="demo">
<h2>{translated.defaultTheme}</h2>
<h2>{translated.theme}</h2>
<Demo1 />
<h2>{translated.customTheme}</h2>
<h2>{translated.text}</h2>
<Demo2 />
<h2>{translated.title1}</h2>
<Demo3 />
<h2>{translated.title2}</h2>
<Demo4 />
<h2>RTL</h2>
<Demo5 />
<Demo3 />
</div>
</>
)
Expand Down
21 changes: 19 additions & 2 deletions src/packages/configprovider/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react'
import { ConfigProvider, Cell, Rate, Button } from '@nutui/nutui-react'

const Demo1 = () => {
const Demo = () => {
const darkTheme = {
nutuiColorPrimaryIcon: 'green',
nutuiColorPrimaryStop1: 'green',
nutuiColorPrimaryStop2: 'green',
}
return (
<>
<ConfigProvider>
Expand All @@ -16,8 +21,20 @@ const Demo1 = () => {
</Cell>
</Cell.Group>
</ConfigProvider>
<ConfigProvider theme={darkTheme}>
<Cell.Group>
<Cell>
<Rate defaultValue={3} />
</Cell>
<Cell>
<Button type="primary" block>
提交
</Button>
</Cell>
</Cell.Group>
</ConfigProvider>
</>
)
}

export default Demo1
export default Demo
32 changes: 13 additions & 19 deletions src/packages/configprovider/demos/h5/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import React from 'react'
import { ConfigProvider, Cell, Rate, Button } from '@nutui/nutui-react'
import { ConfigProvider, TextArea, Cell } from '@nutui/nutui-react'
import enUS from '@nutui/nutui-react/dist/es/locale/en-US'

const Demo2 = () => {
const darkTheme = {
nutuiColorPrimaryIcon: 'green',
nutuiColorPrimaryStop1: 'green',
nutuiColorPrimaryStop2: 'green',
}
const Demo = () => {
return (
<>
<ConfigProvider theme={darkTheme}>
<Cell.Group>
<Cell>
<Rate defaultValue={3} />
</Cell>
<Cell>
<Button type="primary" block>
提交
</Button>
</Cell>
</Cell.Group>
<ConfigProvider>
<Cell>
<TextArea disabled showCount maxLength={20} />
</Cell>
</ConfigProvider>
<ConfigProvider locale={enUS}>
<Cell>
<TextArea disabled showCount maxLength={20} />
</Cell>
</ConfigProvider>
</>
)
}

export default Demo2
export default Demo
18 changes: 13 additions & 5 deletions src/packages/configprovider/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import React from 'react'
import { ConfigProvider, TextArea } from '@nutui/nutui-react'
import { ConfigProvider, Cell } from '@nutui/nutui-react'

const Demo3 = () => {
const Demo = () => {
return (
<>
<ConfigProvider>
<TextArea disabled showCount maxLength={20} />
<ConfigProvider direction="rtl">
<Cell
title={
<div>
<span>我是标题</span>
</div>
}
description={<span>我是描述</span>}
extra="描述文字"
/>
</ConfigProvider>
</>
)
}

export default Demo3
export default Demo
15 changes: 0 additions & 15 deletions src/packages/configprovider/demos/h5/demo4.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/packages/configprovider/demos/h5/demo5.tsx

This file was deleted.

21 changes: 19 additions & 2 deletions src/packages/configprovider/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react'
import { ConfigProvider, Cell, Button, Rate } from '@nutui/nutui-react-taro'

const Demo1 = () => {
const Demo = () => {
const darkTheme = {
nutuiColorPrimaryIcon: 'green',
nutuiColorPrimaryStop1: 'green',
nutuiColorPrimaryStop2: 'green',
}
return (
<>
<ConfigProvider>
Expand All @@ -16,8 +21,20 @@ const Demo1 = () => {
</Cell>
</Cell.Group>
</ConfigProvider>
<ConfigProvider theme={darkTheme}>
<Cell.Group>
<Cell>
<Rate defaultValue={3} />
</Cell>
<Cell>
<Button type="primary" block>
提交
</Button>
</Cell>
</Cell.Group>
</ConfigProvider>
</>
)
}

export default Demo1
export default Demo
32 changes: 13 additions & 19 deletions src/packages/configprovider/demos/taro/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import React from 'react'
import { ConfigProvider, Cell, Button, Rate } from '@nutui/nutui-react-taro'
import { ConfigProvider, TextArea, Cell } from '@nutui/nutui-react-taro'
import enUS from '@nutui/nutui-react-taro/dist/es/locales/en-US'

const Demo2 = () => {
const darkTheme = {
nutuiColorPrimaryIcon: 'green',
nutuiColorPrimaryStop1: 'green',
nutuiColorPrimaryStop2: 'green',
}
const Demo = () => {
return (
<>
<ConfigProvider theme={darkTheme}>
<Cell.Group>
<Cell>
<Rate defaultValue={3} />
</Cell>
<Cell>
<Button type="primary" block>
提交
</Button>
</Cell>
</Cell.Group>
<ConfigProvider>
<Cell>
<TextArea disabled showCount maxLength={20} />
</Cell>
</ConfigProvider>
<ConfigProvider locale={enUS}>
<Cell>
<TextArea disabled showCount maxLength={20} />
</Cell>
</ConfigProvider>
</>
)
}

export default Demo2
export default Demo
23 changes: 18 additions & 5 deletions src/packages/configprovider/demos/taro/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import React from 'react'
import { ConfigProvider, TextArea } from '@nutui/nutui-react-taro'
import { View, Text } from '@tarojs/components'
import { ConfigProvider, Cell, pxTransform } from '@nutui/nutui-react-taro'

const Demo3 = () => {
const Demo = () => {
return (
<>
<ConfigProvider>
<TextArea disabled showCount maxLength={20} />
<ConfigProvider direction="rtl">
<Cell
title={
<View>
<Text style={{ fontSize: pxTransform(14) }}>我是标题</Text>
</View>
}
description={
<Text style={{ fontSize: pxTransform(12), color: '#ccc' }}>
我是描述
</Text>
}
extra="描述文字"
/>
</ConfigProvider>
</>
)
}

export default Demo3
export default Demo
15 changes: 0 additions & 15 deletions src/packages/configprovider/demos/taro/demo4.tsx

This file was deleted.

Loading
Loading