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

fix(cell): unify the demos of Cell #1998

Merged
merged 7 commits into from
Mar 8, 2024
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
206 changes: 18 additions & 188 deletions src/packages/cell/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react'
import { User, ArrowRight } from '@nutui/icons-react-taro'
import Taro, { redirectTo, navigateTo } from '@tarojs/taro'
import Taro from '@tarojs/taro'
import { useTranslate } from '@/sites/assets/locale/taro'
import { Switch, Cell, Button } from '@/packages/nutui.react.taro'
import Header from '@/sites/components/header'
import '@/packages/cell/demo.scss'
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 Demo6 from './demos/taro/demo6'
import Demo7 from './demos/taro/demo7'

interface T {
basic: string
Expand Down Expand Up @@ -87,198 +91,24 @@ const CellDemo = () => {
},
})

const testClick = (
event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>
) => {
Taro.showToast({ title: translated.clickEventToast })
}

const onJumpclick = (
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
link: string
) => {
const replace = false
if (link) {
replace ? redirectTo({ url: link }) : navigateTo({ url: link })
}
}

return (
<>
<Header />
<div className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<h2>{translated.basic}</h2>
<Cell title={translated.title} extra={translated.extra} />
<Cell
title={translated.title}
description={translated.title1}
extra={translated.extra}
/>
<Cell
title={translated.title2}
onClick={(
event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>
) => testClick(event)}
/>
<Cell title={translated.title3} radius="0" />
<Demo1 />
<h2>{translated.content}</h2>
<Cell>
<div>{translated.content}</div>
</Cell>
<Demo2 />
<h2>{translated.title6}</h2>
<Cell
title={
<div style={{ display: 'inline-flex', alignItems: 'center' }}>
<User />
<span
style={{
marginInlineStart: '5px',
}}
>
{translated.title}
</span>
</div>
}
description={
<span>
{translated.title1} <b style={{ color: 'red' }}>1</b>
</span>
}
extra={translated.extra}
/>
<Cell.Group title={translated.customRight}>
<Cell title="Switch" extra={<Switch defaultChecked />} />
</Cell.Group>
<Demo3 />
<h2>{translated.customRight}</h2>
<Demo4 />
<h2>{translated.title5}</h2>
<Cell
align="center"
title={translated.title}
description={translated.title1}
extra={translated.extra}
/>
<Cell.Group
title={translated.title4}
description={translated.description}
>
<Cell
className="nutui-cell-clickable"
title={translated.link}
align="center"
extra={<ArrowRight />}
/>
<Cell
className="nutui-cell-clickable"
title={translated.urlJump}
extra={
<>
<span>/pages/index/index</span>
<ArrowRight
style={{
marginInlineStart: '5px',
}}
/>
</>
}
align="center"
onClick={(
event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>
) => onJumpclick(event, '/pages/index/index')}
/>
</Cell.Group>

<Cell.Group>
<Cell
title={
<div style={{ display: 'flex', alignItems: 'flex-end' }}>
<span style={{ fontWeight: '500' }}>{translated.title}</span>
<span
style={{
color: '#8C8C8C',
fontSize: '10px',
marginInlineStart: '5px',
lineHeight: 1.5,
}}
>
{translated.title1}
</span>
</div>
}
extra={
<div style={{ display: 'flex', alignItems: 'center' }}>
More
<ArrowRight
size={12}
style={{
marginInlineStart: '5px',
}}
/>
</div>
}
/>
<Cell>
<div style={{ minHeight: '50px' }}>{translated.content}</div>
</Cell>
<Cell
align="center"
title={
<div
style={{
color: '#8C8C8C',
fontSize: '12px',
}}
>
{translated.title1}
</div>
}
extra={<Button type="primary">Action</Button>}
/>
</Cell.Group>

<Cell.Group>
<Cell
title={
<div style={{ display: 'flex', alignItems: 'center' }}>
<User />
<span
style={{
marginInlineStart: '5px',
}}
>
{translated.title}
</span>
</div>
}
extra={<ArrowRight />}
/>
<Cell>
<div style={{ minHeight: '50px' }}>{translated.content}</div>
</Cell>
<Cell align="center" extra={<Button type="primary">Action</Button>} />
</Cell.Group>

<Cell.Group>
<Cell
title={
<div
style={{ display: 'flex', alignItems: 'center', color: 'blue' }}
>
{translated.title}
</div>
}
/>
<Cell>
<div style={{ color: '#26bf26' }}>{translated.content}</div>
</Cell>
</Cell.Group>

<Cell.Group
divider={false}
title={translated.title7}
description={translated.description1}
>
<Cell title={translated.title} extra={translated.extra} />
<Cell title={translated.title} extra={translated.extra} />
</Cell.Group>
<Demo5 />
<h2>{translated.title4}</h2>
<Demo6 />
<h2>{translated.title7}</h2>
<Demo7 />
</div>
</>
)
Expand Down
Loading
Loading