-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
986 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/nutui-taro-demo/src/basic/pages/space/index.config.ts
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,3 @@ | ||
export default { | ||
navigationBarTitleText: 'Space' | ||
}; |
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,60 @@ | ||
<template> | ||
<view class="demo" :class="{ web: env === 'WEB' }"> | ||
<Header v-if="env === 'WEB'" /> | ||
<h2>基础用法</h2> | ||
<nut-cell> | ||
<nut-space> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>垂直排列</h2> | ||
<nut-cell> | ||
<nut-space direction="vertical" fill> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>自定义间距</h2> | ||
<nut-cell> | ||
<nut-space :gutter="20"> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<nut-cell :style="{ '--nut-space-gap': '30px' }"> | ||
<nut-space> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
<nut-button type="primary">按钮</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>自动换行</h2> | ||
<nut-cell> | ||
<nut-space wrap> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
<nut-button type="primary" block>按钮</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
</view> | ||
</template> | ||
|
||
<script setup> | ||
import Taro from '@tarojs/taro'; | ||
import Header from '../../../components/header.vue'; | ||
const env = Taro.getEnv(); | ||
console.log(111); | ||
</script> |
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
33 changes: 33 additions & 0 deletions
33
src/packages/__VUE/space/__tests__/__snapshots__/space.spec.ts.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,33 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`space: should match snapshot 1`] = ` | ||
"<div class=\\"nut-space nut-space-horizontal\\"> | ||
<div class=\\"nut-space-item\\"> | ||
<view class=\\"nut-button nut-button--default nut-button--normal nut-button--round\\"> | ||
<view class=\\"nut-button__wrap\\"> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<view class=\\"\\">按钮</view> | ||
</view> | ||
</view> | ||
</div> | ||
<div class=\\"nut-space-item\\"> | ||
<view class=\\"nut-button nut-button--default nut-button--normal nut-button--round\\"> | ||
<view class=\\"nut-button__wrap\\"> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<view class=\\"\\">按钮</view> | ||
</view> | ||
</view> | ||
</div> | ||
<div class=\\"nut-space-item\\"> | ||
<view class=\\"nut-button nut-button--default nut-button--normal nut-button--round\\"> | ||
<view class=\\"nut-button__wrap\\"> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<view class=\\"\\">按钮</view> | ||
</view> | ||
</view> | ||
</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,101 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Space from '../index.vue'; | ||
import NutButton from '../../button/index.vue'; | ||
import { h } from 'vue'; | ||
|
||
const prefixCls = 'nut-space'; | ||
|
||
test('space: should match snapshot', () => { | ||
const wrapper = mount(Space, { | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
|
||
test('space: with props direction', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
direction: 'vertical' | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.classes()).toContain(`${prefixCls}-vertical`); | ||
}); | ||
|
||
test('space: with props align', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
align: 'end' | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.classes()).toContain(`${prefixCls}-align-end`); | ||
}); | ||
|
||
test('space: with props justify', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
justify: 'center' | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.classes()).toContain(`${prefixCls}-justify-center`); | ||
}); | ||
|
||
test('space: with props wrap', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
wrap: true | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.classes()).toContain(`${prefixCls}-wrap`); | ||
}); | ||
|
||
test('space: with props fill', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
fill: true | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
expect(wrapper.classes()).toContain(`${prefixCls}-fill`); | ||
}); | ||
|
||
test('space: with props gutter number', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
gutter: 20 | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
const nutSpaceItem = wrapper.find('.nut-space-item'); | ||
expect(nutSpaceItem.attributes('style')).toBe('margin-right: 20px;'); | ||
}); | ||
|
||
test('space: with props gutter string', () => { | ||
const wrapper = mount(Space, { | ||
props: { | ||
gutter: '1rem' | ||
}, | ||
slots: { | ||
default: [h(NutButton, () => '按钮'), h(NutButton, () => '按钮'), h(NutButton, () => '按钮')] | ||
} | ||
}); | ||
const nutSpaceItem = wrapper.find('.nut-space-item'); | ||
expect(nutSpaceItem.attributes('style')).toBe('margin-right: 1rem;'); | ||
}); |
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,74 @@ | ||
<template> | ||
<div class="demo full"> | ||
<h2>{{ translate('title1') }}</h2> | ||
<nut-cell> | ||
<nut-space> | ||
<nut-button type="primary">{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary">{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary">{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary">{{ translate('btn') }}</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>{{ translate('title2') }}</h2> | ||
<nut-cell> | ||
<nut-space direction="vertical" fill> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>{{ translate('title3') }}</h2> | ||
<nut-cell> | ||
<nut-space :gutter="20"> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<nut-cell :style="{ '--nut-space-gap': '30px' }"> | ||
<nut-space> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
<h2>{{ translate('title4') }}</h2> | ||
<nut-cell> | ||
<nut-space wrap> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
<nut-button type="primary" block>{{ translate('btn') }}</nut-button> | ||
</nut-space> | ||
</nut-cell> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { createComponent } from '@/packages/utils/create'; | ||
const { translate } = createComponent('cell'); | ||
import { useTranslate } from '@/sites/assets/util/useTranslate'; | ||
const initTranslate = () => | ||
useTranslate({ | ||
'zh-CN': { | ||
title1: '基础用法:默认间距为 8px', | ||
title2: '垂直排列', | ||
title3: '自定义间距', | ||
title4: '自动换行', | ||
btn: '按钮' | ||
}, | ||
'en-US': { | ||
title1: 'Grammar and Usage:The default spacing is 8px', | ||
title2: 'Vertical Alignment', | ||
title3: 'Custom spacing', | ||
title4: 'word wrap', | ||
btn: 'Button' | ||
} | ||
}); | ||
initTranslate(); | ||
</script> |
Oops, something went wrong.