Skip to content
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

refactor(demos): add multi-language switch feature #2933

Draft
wants to merge 8 commits into
base: feat_v3.x
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"*.{ts,tsx,js}": "eslint"
},
"dependencies": {
"@babel/runtime": "^7.23.9",
"@nutui/icons-react": "^3.0.0-beta.2",
"@nutui/icons-react-taro": "^3.0.0-beta.2",
"@nutui/jdesign-icons-react-taro": "1.0.6-beta.2",
Expand All @@ -118,6 +117,10 @@
"react-transition-group": "^4.4.5"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/runtime": "^7.23.9",
"@babel/standalone": "^7.26.4",
"@babel/types": "^7.26.3",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
Expand Down
12,981 changes: 7,223 additions & 5,758 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions src/packages/backtop/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react'
import { BackTop, Cell } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo1 = () => {
const Demo1 = ({ t }: propsType) => {
return (
<>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
return (
<Cell key={index}>
{t.testData}
{index}
</Cell>
)
})}
<BackTop target="target" />
</>
)
}
export default Demo1

export default withTranslation(Demo1)
13 changes: 10 additions & 3 deletions src/packages/backtop/demos/h5/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react'
import { BackTop, Cell } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo2 = () => {
const Demo2 = ({ t }: propsType) => {
return (
<>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
return (
<Cell key={index}>
{t.testData}
{index}
</Cell>
)
})}
<BackTop target="target" threshold={200} />
</>
)
}
export default Demo2

export default withTranslation(Demo2)
15 changes: 11 additions & 4 deletions src/packages/backtop/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import React from 'react'
import { Top } from '@nutui/icons-react'
import { BackTop, Cell } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo3 = () => {
const Demo3 = ({ t }: propsType) => {
return (
<>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
return (
<Cell key={index}>
{t.testData}
{index}
</Cell>
)
})}
<BackTop threshold={100} target="target">
<Top width={12} height={12} />
<div style={{ fontSize: '12px' }}>顶部</div>
<div style={{ fontSize: '12px' }}>{t.top}</div>
</BackTop>
</>
)
}
export default Demo3

export default withTranslation(Demo3)
13 changes: 10 additions & 3 deletions src/packages/backtop/demos/h5/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react'
import { BackTop, Cell } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo4 = () => {
const Demo4 = ({ t }: propsType) => {
return (
<div id="target2" style={{ height: '800px', overflowY: 'auto' }}>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
return (
<Cell key={index}>
{t.testData}
{index}
</Cell>
)
})}
<BackTop target="target2" threshold={100} />
</div>
)
}
export default Demo4

export default withTranslation(Demo4)
14 changes: 11 additions & 3 deletions src/packages/backtop/demos/h5/demo5.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react'
import { BackTop, Cell } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo5 = () => {
const Demo5 = ({ t }: propsType) => {
const handleClick = () => {
const ele = document.getElementsByClassName('backtop-button')[0]
}

return (
<>
{new Array(24).fill(0).map((_, index) => {
return <Cell key={index}>我是测试数据{index}</Cell>
return (
<Cell key={index}>
{t.testData}
{index}
</Cell>
)
})}
<BackTop
onClick={() => {
Expand All @@ -20,4 +27,5 @@ const Demo5 = () => {
</>
)
}
export default Demo5

export default withTranslation(Demo5)
17 changes: 9 additions & 8 deletions src/packages/button/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import React from 'react'
import { Button } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo1 = () => {
const Demo1 = ({ t }: propsType) => {
const marginStyle = { margin: 8 }
return (
<>
<Button type="primary" style={marginStyle}>
Primary
{t.primary}
</Button>
<Button type="info" style={marginStyle}>
Info
{t.info}
</Button>
<Button type="default" style={marginStyle}>
Default
{t.default}
</Button>
<Button type="danger" style={marginStyle}>
Danger
{t.danger}
</Button>
<Button type="warning" style={marginStyle}>
Warning
{t.warning}
</Button>
<Button type="success" style={marginStyle}>
Success
{t.success}
</Button>
</>
)
}
export default Demo1
export default withTranslation(Demo1)
14 changes: 8 additions & 6 deletions src/packages/button/demos/h5/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import React from 'react'
import { Button } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo2 = () => {
const Demo2 = ({ t }: propsType) => {
const marginStyle = { margin: 8 }
return (
<>
<Button type="primary" fill="solid" style={marginStyle}>
Solid
{t.solid}
</Button>
<Button type="primary" fill="outline" style={marginStyle}>
Outline
{t.outline}
</Button>
<Button type="primary" fill="dashed" style={marginStyle}>
Dashed
{t.dashed}
</Button>
<Button fill="none" style={marginStyle}>
None
{t.none}
</Button>
</>
)
}
export default Demo2

export default withTranslation(Demo2)
46 changes: 22 additions & 24 deletions src/packages/button/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react'
import { Star, Plus } from '@nutui/icons-react'
import { Button } from '@nutui/nutui-react'
import { withTranslation, propsType } from '@/translation/demo.translation'

const Demo3 = () => {
const Demo3 = ({ t }: propsType) => {
const marginStyle = { margin: 8 }
return (
<>
Expand All @@ -12,7 +13,7 @@ const Demo3 = () => {
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
<Button
type="primary"
Expand All @@ -21,7 +22,7 @@ const Demo3 = () => {
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
<Button
type="primary"
Expand All @@ -30,7 +31,7 @@ const Demo3 = () => {
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
<Button
icon={<Star />}
Expand All @@ -42,7 +43,7 @@ const Demo3 = () => {
color: `var(--nutui-color-primary)`,
}}
>
Button
{t.button}
</Button>
<Button
type="default"
Expand All @@ -55,7 +56,7 @@ const Demo3 = () => {
color: `var(--nutui-gray-7)`,
}}
>
Button
{t.button}
</Button>
<Button
type="default"
Expand All @@ -68,43 +69,39 @@ const Demo3 = () => {
color: `var(--nutui-gray-7)`,
}}
>
Button
{t.button}
</Button>
<Button
type="default"
icon={<Star />}
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
<Button
shape="square"
fill="outline"
type="primary"
icon={<Plus />}
style={marginStyle}
/>
<Button
fill="outline"
type="primary"
icon={<Plus />}
style={marginStyle}
/>
<Button
type="primary"
fill="dashed"
icon={<Plus />}
style={marginStyle}
/>
>
{t.button}
</Button>
<Button fill="outline" type="primary" icon={<Plus />} style={marginStyle}>
{t.button}
</Button>
<Button type="primary" fill="dashed" icon={<Plus />} style={marginStyle}>
{t.button}
</Button>
<Button
type="primary"
size="large"
icon={<Star />}
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
<Button
type="primary"
Expand All @@ -113,9 +110,10 @@ const Demo3 = () => {
rightIcon={<Star />}
style={marginStyle}
>
Button
{t.button}
</Button>
</>
)
}
export default Demo3

export default withTranslation(Demo3)
Loading
Loading