Skip to content

Commit

Permalink
docs(SafeArea): 调整demo (#2020)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaoyatong <hanyuxingint@sina.cn>
  • Loading branch information
xiaoyatong and xiaoyatong authored Mar 14, 2024
1 parent f848fcb commit 3770b6d
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 239 deletions.
42 changes: 2 additions & 40 deletions src/packages/button/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React from 'react'
import Taro from '@tarojs/taro'
import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header'
Expand All @@ -14,36 +14,8 @@ import Demo8 from './demos/taro/demo8'
import Demo9 from './demos/taro/demo9'
import Demo10 from './demos/taro/demo10'

interface T {
ce5c5446: string
ce5c5447: string
c38a08ef: string
b840c88f: string
b840c881: string
b840c882: string
a74a1fd4: string
'8dab2f66': string
cfbdc781: string
c3a3a1d2: string
e51e4582: string
'7db1a8b2': string
a52bef0c: string
d04fcbda: string
'0aaad622': string
'0aaad620': string
'60a53514': string
b8a453e3: string
'248be9e1': string
ea3d02f2: string
ea379d01: string
c9e6df49: string
'781b07fd': string
'1076d771': string
'6ab47cd2': string
}

const ButtonDemo = () => {
const [translated] = useTranslate<T>({
const [translated] = useTranslate({
'zh-CN': {
ce5c5446: '按钮类型',
ce5c5447: '按钮形状',
Expand Down Expand Up @@ -126,11 +98,6 @@ const ButtonDemo = () => {
'6ab47cd2': 'Gradient button',
},
})
const openType: any = Taro.getEnv() === 'WEB' ? {} : { openType: 'share' }
const openSetting: any =
Taro.getEnv() === 'WEB' ? {} : { openType: 'openSetting' }
const [loading, setLoading] = useState(false)
const marginStyle = { margin: 8 }
return (
<>
<Header />
Expand All @@ -143,12 +110,10 @@ const ButtonDemo = () => {
<Cell style={{ flexWrap: 'wrap' }}>
<Demo2 />
</Cell>

<h2>{translated.e51e4582}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo3 />
</Cell>

<h2>{translated['0aaad622']}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo4 />
Expand All @@ -165,7 +130,6 @@ const ButtonDemo = () => {
<Cell style={{ flexWrap: 'wrap' }}>
<Demo7 />
</Cell>

<h2>{translated['0aaad620']}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo8 />
Expand All @@ -174,9 +138,7 @@ const ButtonDemo = () => {
<Cell>
<Demo9 />
</Cell>

<h2>{translated['781b07fd']}</h2>

<Cell style={{ flexWrap: 'wrap' }}>
<Demo10 />
</Cell>
Expand Down
36 changes: 1 addition & 35 deletions src/packages/button/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,8 @@ import Demo7 from './demos/h5/demo7'
import Demo8 from './demos/h5/demo8'
import Demo9 from './demos/h5/demo9'

interface T {
ce5c5446: string
ce5c5447: string
c38a08ef: string
b840c88f: string
b840c881: string
b840c882: string
a74a1fd4: string
'8dab2f66': string
cfbdc781: string
c3a3a1d2: string
e51e4582: string
'7db1a8b2': string
a52bef0c: string
d04fcbda: string
'0aaad622': string
'0aaad620': string
'60a53514': string
b8a453e3: string
'248be9e1': string
ea3d02f2: string
ea379d01: string
c9e6df49: string
'781b07fd': string
'1076d771': string
'6ab47cd2': string
}

const ButtonDemo = () => {
const [translated] = useTranslate<T>({
const [translated] = useTranslate({
'zh-CN': {
ce5c5446: '按钮类型',
ce5c5447: '按钮形状',
Expand Down Expand Up @@ -131,17 +103,14 @@ const ButtonDemo = () => {
<Cell style={{ flexWrap: 'wrap' }}>
<Demo1 />
</Cell>

<h2>{translated.e51e4582}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo2 />
</Cell>

<h2>{translated['0aaad622']}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo3 />
</Cell>

<h2>{translated['7db1a8b2']}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo4 />
Expand All @@ -154,7 +123,6 @@ const ButtonDemo = () => {
<Cell style={{ flexWrap: 'wrap' }}>
<Demo6 />
</Cell>

<h2>{translated['0aaad620']}</h2>
<Cell style={{ flexWrap: 'wrap' }}>
<Demo7 />
Expand All @@ -163,9 +131,7 @@ const ButtonDemo = () => {
<Cell>
<Demo8 />
</Cell>

<h2>{translated['781b07fd']}</h2>

<Cell style={{ flexWrap: 'wrap' }}>
<Demo9 />
</Cell>
Expand Down
20 changes: 2 additions & 18 deletions src/packages/safearea/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { SafeArea } from '@/packages/nutui.react.taro'
import Header from '@/sites/components/header'
import { useTranslate } from '@/sites/assets/locale/taro'
import Demo1 from './demos/taro/demo1'

const SafeAreaDemo = () => {
const [translated] = useTranslate({
Expand All @@ -17,28 +17,12 @@ const SafeAreaDemo = () => {
},
})

function generateRandomTextArray(count: number) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4 // 随机生成长度在4到8之间的数
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}

return (
<>
<Header />
<div className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<h2>{translated.basic}</h2>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
<Demo1 />
</div>
</>
)
Expand Down
20 changes: 2 additions & 18 deletions src/packages/safearea/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { SafeArea } from './safearea'
import { useTranslate } from '@/sites/assets/locale'
import Demo1 from './demos/h5/demo1'

const SafeAreaDemo = () => {
const [translated] = useTranslate({
Expand All @@ -15,27 +15,11 @@ const SafeAreaDemo = () => {
},
})

function generateRandomTextArray(count: number) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4 // 随机生成长度在4到8之间的数
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}

return (
<>
<div className="demo">
<h2>{translated.basic}</h2>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
<Demo1 />
</div>
</>
)
Expand Down
28 changes: 28 additions & 0 deletions src/packages/safearea/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import { SafeArea } from '@nutui/nutui-react'

function generateRandomTextArray(count: number) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4 // 随机生成长度在4到8之间的数
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}

const Demo1 = () => {
return (
<>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
</>
)
}

export default Demo1
28 changes: 28 additions & 0 deletions src/packages/safearea/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import { SafeArea } from '@nutui/nutui-react-taro'

function generateRandomTextArray(count: number) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4 // 随机生成长度在4到8之间的数
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}

const Demo1 = () => {
return (
<>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
</>
)
}

export default Demo1
36 changes: 4 additions & 32 deletions src/packages/safearea/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,10 @@ import { SafeArea } from '@nutui/nutui-react';

### Basic Usage

:::demo

```tsx
import React from 'react'
import { SafeArea } from '@nutui/nutui-react'

function generateRandomTextArray(count) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}
const App = () => {
return (
<>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
</>
)
}
export default App

```

:::demo

<CodeBlock src='h5/demo1.tsx'></CodeBlock>

:::


Expand Down
36 changes: 4 additions & 32 deletions src/packages/safearea/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,10 @@ import { SafeArea } from '@nutui/nutui-react';

### 基础用法

:::demo

```tsx
import React from 'react'
import { SafeArea } from '@nutui/nutui-react'

function generateRandomTextArray(count) {
const characters = 'abcdefghijklmnopqrstuvwxyz'
const textArray = []
for (let j = 0; j < count; j++) {
const randomLength = Math.floor(Math.random() * 5) + 4
let randomText = ''
for (let i = 0; i < randomLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length)
randomText += characters.charAt(randomIndex)
}
textArray.push(randomText)
}
return textArray
}
const App = () => {
return (
<>
<div>{generateRandomTextArray(900).join(' ')}</div>
<SafeArea position="bottom" />
</>
)
}
export default App

```

:::demo

<CodeBlock src='h5/demo1.tsx'></CodeBlock>

:::


Expand Down
Loading

0 comments on commit 3770b6d

Please sign in to comment.