-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,080 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/packages/space/__test__/__snapshots__/space.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="nut-space nut-space-horizontal" | ||
> | ||
<div | ||
class="nut-space-item" | ||
> | ||
<button | ||
class="nut-button nut-button--normal nut-button--round" | ||
type="button" | ||
> | ||
<div | ||
class="nut-button__warp" | ||
> | ||
<div | ||
class="" | ||
> | ||
按钮1 | ||
</div> | ||
</div> | ||
</button> | ||
</div> | ||
<div | ||
class="nut-space-item" | ||
> | ||
<button | ||
class="nut-button nut-button--normal nut-button--round" | ||
type="button" | ||
> | ||
<div | ||
class="nut-button__warp" | ||
> | ||
<div | ||
class="" | ||
> | ||
按钮2 | ||
</div> | ||
</div> | ||
</button> | ||
</div> | ||
<div | ||
class="nut-space-item" | ||
> | ||
<button | ||
class="nut-button nut-button--normal nut-button--round" | ||
type="button" | ||
> | ||
<div | ||
class="nut-button__warp" | ||
> | ||
<div | ||
class="" | ||
> | ||
按钮3 | ||
</div> | ||
</div> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as React from 'react' | ||
import { render } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
|
||
import { Space } from '../space' | ||
import Button from '@/packages/button' | ||
|
||
const prefixCls = 'nut-space' | ||
|
||
test('should match snapshot', () => { | ||
const { container } = render( | ||
<Space> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('render with props direction', () => { | ||
const { container } = render( | ||
<Space direction="vertical"> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
) | ||
const nutSpace = container.getElementsByClassName('nut-space')[0] | ||
expect(nutSpace).toHaveClass(`${prefixCls}-vertical`) | ||
}) | ||
|
||
test('render with props align', () => { | ||
const { container } = render( | ||
<Space align="end"> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
) | ||
const nutSpace = container.getElementsByClassName('nut-space')[0] | ||
expect(nutSpace).toHaveClass(`${prefixCls}-align-end`) | ||
}) | ||
|
||
test('render with props justify', () => { | ||
const { container } = render( | ||
<Space justify="center"> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
) | ||
const nutSpace = container.getElementsByClassName('nut-space')[0] | ||
expect(nutSpace).toHaveClass(`${prefixCls}-justify-center`) | ||
}) | ||
|
||
test('render with props wrap', () => { | ||
const { container } = render( | ||
<Space wrap> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
<Button>按钮4</Button> | ||
<Button>按钮5</Button> | ||
<Button>按钮6</Button> | ||
</Space> | ||
) | ||
const nutSpace = container.getElementsByClassName('nut-space')[0] | ||
expect(nutSpace).toHaveClass(`${prefixCls}-wrap`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import React from 'react' | ||
import { | ||
Space, | ||
Button, | ||
Cell, | ||
ConfigProvider, | ||
} from '@/packages/nutui.react.taro' | ||
import { useTranslate } from '@/sites/assets/locale' | ||
|
||
interface Button { | ||
button1: string | ||
button2: string | ||
button3: string | ||
button4: string | ||
button5: string | ||
button6: string | ||
} | ||
interface T extends Button { | ||
basic: string | ||
wrap: string | ||
direction: string | ||
spaceGap: string | ||
} | ||
|
||
const SpaceDemo = () => { | ||
const [translated] = useTranslate<T>({ | ||
'zh-CN': { | ||
basic: '基本用法', | ||
wrap: '换行', | ||
direction: '垂直', | ||
spaceGap: '间距大小', | ||
button1: '按钮1', | ||
button2: '按钮2', | ||
button3: '按钮3', | ||
button4: '按钮4', | ||
button5: '按钮5', | ||
button6: '按钮6', | ||
}, | ||
'zh-TW': { | ||
basic: '基本用法', | ||
wrap: '換行', | ||
direction: '垂直', | ||
spaceGap: '間距大小', | ||
button1: '按钮1', | ||
button2: '按钮2', | ||
button3: '按钮3', | ||
button4: '按钮4', | ||
button5: '按钮5', | ||
button6: '按钮6', | ||
}, | ||
'en-US': { | ||
basic: 'Basic Usage', | ||
wrap: 'wrap', | ||
direction: 'Direction', | ||
spaceGap: 'SpaceGap', | ||
button1: 'button1', | ||
button2: 'button2', | ||
button3: 'button3', | ||
button4: 'button4', | ||
button5: 'button5', | ||
button6: 'button6', | ||
}, | ||
}) | ||
|
||
return ( | ||
<> | ||
<div className="demo"> | ||
<h2>{translated.basic}</h2> | ||
<Cell> | ||
<Space> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.wrap}</h2> | ||
<Cell> | ||
<Space wrap> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
<Button>按钮4</Button> | ||
<Button>按钮5</Button> | ||
<Button>按钮6</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.direction}</h2> | ||
<Cell> | ||
<Space direction="vertical"> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.spaceGap}</h2> | ||
<Cell> | ||
<ConfigProvider | ||
theme={{ | ||
nutuiSpaceGap: '20px', | ||
}} | ||
> | ||
<Space> | ||
<Button>按钮1</Button> | ||
<Button>按钮2</Button> | ||
<Button>按钮3</Button> | ||
</Space> | ||
</ConfigProvider> | ||
</Cell> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default SpaceDemo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import React from 'react' | ||
import { Space } from './space' | ||
import Button from '@/packages/button' | ||
import Cell from '@/packages/cell' | ||
import ConfigProvider from '@/packages/configprovider' | ||
import { useTranslate } from '@/sites/assets/locale' | ||
|
||
interface Button { | ||
button1: string | ||
button2: string | ||
button3: string | ||
button4: string | ||
button5: string | ||
button6: string | ||
} | ||
interface T extends Button { | ||
basic: string | ||
wrap: string | ||
direction: string | ||
spaceGap: string | ||
} | ||
const SpaceDemo = () => { | ||
const [translated] = useTranslate<T>({ | ||
'zh-CN': { | ||
basic: '基本用法', | ||
wrap: '换行', | ||
direction: '垂直', | ||
spaceGap: '间距大小', | ||
button1: '按钮1', | ||
button2: '按钮2', | ||
button3: '按钮3', | ||
button4: '按钮4', | ||
button5: '按钮5', | ||
button6: '按钮6', | ||
}, | ||
'zh-TW': { | ||
basic: '基本用法', | ||
wrap: '換行', | ||
direction: '垂直', | ||
spaceGap: '間距大小', | ||
button1: '按钮1', | ||
button2: '按钮2', | ||
button3: '按钮3', | ||
button4: '按钮4', | ||
button5: '按钮5', | ||
button6: '按钮6', | ||
}, | ||
'en-US': { | ||
basic: 'Basic Usage', | ||
wrap: 'wrap', | ||
direction: 'Direction', | ||
spaceGap: 'SpaceGap', | ||
button1: 'button1', | ||
button2: 'button2', | ||
button3: 'button3', | ||
button4: 'button4', | ||
button5: 'button5', | ||
button6: 'button6', | ||
}, | ||
}) | ||
|
||
return ( | ||
<> | ||
<div className="demo"> | ||
<h2>{translated.basic}</h2> | ||
<Cell> | ||
<Space> | ||
<Button>{translated.button1}</Button> | ||
<Button>{translated.button2}</Button> | ||
<Button>{translated.button3}</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.wrap}</h2> | ||
<Cell> | ||
<Space wrap> | ||
<Button>{translated.button1}</Button> | ||
<Button>{translated.button2}</Button> | ||
<Button>{translated.button3}</Button> | ||
<Button>{translated.button4}</Button> | ||
<Button>{translated.button5}</Button> | ||
<Button>{translated.button6}</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.direction}</h2> | ||
<Cell> | ||
<Space direction="vertical"> | ||
<Button>{translated.button1}</Button> | ||
<Button>{translated.button2}</Button> | ||
<Button>{translated.button3}</Button> | ||
</Space> | ||
</Cell> | ||
|
||
<h2>{translated.spaceGap}</h2> | ||
<Cell> | ||
<ConfigProvider | ||
theme={{ | ||
nutuiSpaceGap: '20px', | ||
}} | ||
> | ||
<Space> | ||
<Button>{translated.button1}</Button> | ||
<Button>{translated.button2}</Button> | ||
<Button>{translated.button3}</Button> | ||
</Space> | ||
</ConfigProvider> | ||
</Cell> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default SpaceDemo |
Oops, something went wrong.