diff --git a/packages/varlet-cli/site/mobile/App.vue b/packages/varlet-cli/site/mobile/App.vue index 4856f2c742c..b746a9e006d 100644 --- a/packages/varlet-cli/site/mobile/App.vue +++ b/packages/varlet-cli/site/mobile/App.vue @@ -1,15 +1,54 @@ + + diff --git a/packages/varlet-cli/site/mobile/components/AppType.vue b/packages/varlet-cli/site/mobile/components/AppType.vue index 4c750b8f2d4..5ca80be09a6 100644 --- a/packages/varlet-cli/site/mobile/components/AppType.vue +++ b/packages/varlet-cli/site/mobile/components/AppType.vue @@ -1,21 +1,21 @@ diff --git a/packages/varlet-cli/site/pc/App.vue b/packages/varlet-cli/site/pc/App.vue index a05dab3f65a..29562f6c291 100644 --- a/packages/varlet-cli/site/pc/App.vue +++ b/packages/varlet-cli/site/pc/App.vue @@ -48,10 +48,7 @@
- +
@@ -68,14 +65,7 @@ import { } from 'vue' export default defineComponent({ - computed: { - simulatorStyle() { - const height = Math.min(640, window.innerHeight - 90) - return { - height: height + 'px', - } - }, - }, + computed: {}, data() { return { menu: [], @@ -123,6 +113,7 @@ body { iframe { display: block; width: 100%; + height: 100%; border: none; } diff --git a/packages/varlet-ui/src/loading/Loading.vue b/packages/varlet-ui/src/loading/Loading.vue new file mode 100644 index 00000000000..bee611405ef --- /dev/null +++ b/packages/varlet-ui/src/loading/Loading.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/packages/varlet-ui/src/loading/__tests__/index.spec.js b/packages/varlet-ui/src/loading/__tests__/index.spec.js new file mode 100644 index 00000000000..daef029f887 --- /dev/null +++ b/packages/varlet-ui/src/loading/__tests__/index.spec.js @@ -0,0 +1,7 @@ +const Loading = require('../../../cjs/loading').default +const { render } = require('@testing-library/vue') + +test('test loading', async () => { + const wrapper = render(Loading) + console.log(wrapper) +}) diff --git a/packages/varlet-ui/src/loading/docs/en_US.md b/packages/varlet-ui/src/loading/docs/en_US.md new file mode 100644 index 00000000000..de3b46de0ec --- /dev/null +++ b/packages/varlet-ui/src/loading/docs/en_US.md @@ -0,0 +1,68 @@ +# Loading + +### Install + +```js +import { Loading } from '@varlet/ui' + +export default defineComponent({ + components: { + [Loading.name]: Loading, + }, +}) +``` + +### Type + +```html + + + + +``` + +### Size + +```html + + + + +``` + +### Text + +```html +loading +loading +loading +loading +``` + +### Horizontal + +```html +loading +loading +loading +loading +``` + +## API + +### Props + +| Attribute | Description | Type | Default | +| --------- | ---------------------------------------------------- | --------- | --------- | +| color | Loading color | _string_ | `#00BCD4` | +| type | Can be set to `wave` `cube` `rect` `disappear` | _string_ | `wave` | +| size | Can be set to `large` `medium` `small` | _string_ | `medium` | +| fontColor | Text color | _string_ | `#ccc` | +| fontSize | Text font size | _number_ | `14` | +| vertical | Whether to arrange icons and text content vertically | _boolean_ | `true` | + +### Slots + +| Name | Description | +| ------- | ------------ | +| default | Loading text | diff --git a/packages/varlet-ui/src/loading/docs/zh_CN.md b/packages/varlet-ui/src/loading/docs/zh_CN.md new file mode 100644 index 00000000000..6d6e113b53f --- /dev/null +++ b/packages/varlet-ui/src/loading/docs/zh_CN.md @@ -0,0 +1,68 @@ +# Loading 加载 + +### 引入 + +```js +import { Loading } from '@varlet/ui' + +export default defineComponent({ + components: { + [Loading.name]: Loading, + }, +}) +``` + +### Loading 类型 + +```html + + + + +``` + +### Loading 大小 + +```html + + + + +``` + +### Loading 文本 + +```html +加载中 +加载中 +加载中 +加载中 +``` + +### 水平排列 + +```html +加载中 +加载中 +加载中 +加载中 +``` + +## API + +### 属性 + +| 参数 | 说明 | 类型 | 默认值 | +| --------- | --------------------------------------------------------- | --------- | --------- | +| color | loading 的颜色 | _string_ | `#00BCD4` | +| type | loading 的类型,可选值为 `wave` `cube` `rect` `disappear` | _string_ | `wave` | +| size | loading 的大小,可选值位 `large` `medium` `small` | _string_ | `medium` | +| fontColor | 字体颜色 | _string_ | `#ccc` | +| fontSize | 字体大小 | _number_ | `14` | +| vertical | 是否垂直排列图标和文字内容 | _boolean_ | `true` | + +### Slots + +| 名称 | 说明 | +| ------- | -------- | +| default | 加载文案 | diff --git a/packages/varlet-ui/src/loading/example/index.vue b/packages/varlet-ui/src/loading/example/index.vue new file mode 100644 index 00000000000..01d6aeecce8 --- /dev/null +++ b/packages/varlet-ui/src/loading/example/index.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/packages/varlet-ui/src/loading/index.ts b/packages/varlet-ui/src/loading/index.ts new file mode 100644 index 00000000000..d67a70270c1 --- /dev/null +++ b/packages/varlet-ui/src/loading/index.ts @@ -0,0 +1,7 @@ +import Loading from './Loading.vue' + +Loading.install = function (app: any) { + app.component(Loading.name, Loading) +} + +export default Loading diff --git a/packages/varlet-ui/src/loading/loading.less b/packages/varlet-ui/src/loading/loading.less new file mode 100644 index 00000000000..f0eff70319a --- /dev/null +++ b/packages/varlet-ui/src/loading/loading.less @@ -0,0 +1,324 @@ +.varlet-loading { + display: flex; + justify-content: center; + align-items: center; + + &__wave { + @loading-wave-width: 100px; + @loading-wave-height: 50px; + @loading-cube-size-item-width: 6px; + + text-align: center; + + &-large { + width: @loading-wave-width; + height: @loading-wave-height; + } + + &-medium { + width: @loading-wave-width * 0.8; + height: @loading-wave-height * 0.8; + } + + &-small { + width: @loading-wave-width * 0.6; + height: @loading-wave-height * 0.6; + } + + &-item { + height: 100%; + display: inline-block; + margin-left: 5px; + animation: 1.2s ease-in-out infinite wave; + + &:nth-child(1) { + animation-delay: -1.2s; + margin-left: 0; + } + + &:nth-child(2) { + animation-delay: -1.1s; + } + + &:nth-child(3) { + animation-delay: -1s; + } + + &:nth-child(4) { + animation-delay: -.9s; + } + + &:nth-child(5) { + animation-delay: -.8s; + } + } + + &-item-large { + width: @loading-cube-size-item-width; + } + + &-item-medium { + width: @loading-cube-size-item-width - 1; + + } + + &-item-small { + width: @loading-cube-size-item-width - 2; + } + + @keyframes wave { + 0%, 40%, 100% { + transform: scaleY(0.4); + } + 20% { + transform: scaleY(1); + } + } + + } + + &__cube { + @loading-cube-size-width: 100px; + @loading-cube-size-height: 50px; + @loading-cube-size-item-width: 15px; + @loading-cube-size-item-height: 15px; + + display: flex; + align-items: center; + + &-large { + width: @loading-cube-size-width; + height: @loading-cube-size-height; + } + + &-medium { + width: @loading-cube-size-width * 0.8; + height: @loading-cube-size-height * 0.8; + } + + &-small { + width: @loading-cube-size-width * 0.6; + height: @loading-cube-size-height * 0.6; + } + + &-item { + display: inline-block; + margin-right: 5px; + transform-origin: right bottom; + animation: 2s ease infinite cube; + + &:nth-child(1) { + animation-delay: 0.2s; + } + + &:nth-child(2) { + animation-delay: 0.4s; + } + + &:nth-child(3) { + animation-delay: 0.6s; + } + + &:nth-child(4) { + animation-delay: 0.8s; + } + + } + + &-item-large { + height: @loading-cube-size-item-height; + width: @loading-cube-size-item-width; + } + + &-item-medium { + height: @loading-cube-size-item-height * 0.8; + width: @loading-cube-size-item-width * 0.8; + + } + + &-item-small { + height: @loading-cube-size-item-height * 0.6; + width: @loading-cube-size-item-width * 0.6; + } + + @keyframes cube { + 0% { + opacity: 1; + transform: scale(1); + } + 100% { + opacity: 0; + transform: rotate(90deg) scale(0.3); + } + } + + } + + &__rect { + @loading-rect-size-width: 100px; + @loading-rect-size-height: 50px; + @loading-rect-size-item-width: 8px; + @loading-rect-size-item-height: 20px; + + display: flex; + flex-wrap: nowrap; + justify-content: center; + align-items: center; + + &-large { + width: @loading-rect-size-width; + height: @loading-rect-size-height; + } + + &-medium { + width: @loading-rect-size-width * 0.8; + height: @loading-rect-size-height * 0.8; + } + + &-small { + width: @loading-rect-size-width * 0.6; + height: @loading-rect-size-height * 0.6; + } + + &-item { + animation: 4s ease-in-out infinite rect; + + &:nth-child(1) { + animation-delay: 1.75s; + } + + &:nth-child(2) { + animation-delay: 1.5s; + } + + &:nth-child(3) { + animation-delay: 1.25s; + } + + &:nth-child(4) { + animation-delay: 1s; + } + + &:nth-child(5) { + animation-delay: .75s; + } + + &:nth-child(6) { + animation-delay: .5s; + } + + &:nth-child(7) { + animation-delay: .25s; + } + + &:nth-child(8) { + animation-delay: 0s; + } + } + + &-item-large { + height: @loading-rect-size-item-height; + width: @loading-rect-size-item-width; + } + + &-item-medium { + height: @loading-rect-size-item-height * 0.75; + width: @loading-rect-size-item-width * 0.75; + + } + + &-item-small { + height: @loading-rect-size-item-height * 0.5; + width: @loading-rect-size-item-width * 0.5; + } + + @keyframes rect { + 0% { + opacity: .3; + } + 25% { + opacity: 1; + } + 50% { + opacity: .3; + } + 65% { + opacity: 1; + } + 100% { + opacity: .3; + } + } + } + + &__disappear { + @loading-disappear-size-width: 100px; + @loading-disappear-size-height: 50px; + @loading-disappear-size-item-width: 15px; + @loading-disappear-size-item-height: 15px; + + display: flex; + justify-content: space-around; + align-items: center; + flex-flow: nowrap; + + &-large { + width: @loading-disappear-size-width; + height: @loading-disappear-size-height; + } + + &-medium { + width: @loading-disappear-size-width * 0.8; + height: @loading-disappear-size-height * 0.8; + } + + &-small { + width: @loading-disappear-size-width * 0.6; + height: @loading-disappear-size-height * 0.6; + } + + &-item { + width: 12px; + height: 12px; + border-radius: 50%; + animation: 0.8s ease-in-out infinite alternate disappear; + + &:nth-child(1) { + animation-delay: -.4s; + } + + &:nth-child(2) { + animation-delay: -.2s; + } + + &:nth-child(3) { + animation-delay: 0s; + } + } + + &-item-large { + height: @loading-disappear-size-item-height; + width: @loading-disappear-size-item-width; + } + + &-item-medium { + height: @loading-disappear-size-item-height * 0.8; + width: @loading-disappear-size-item-width * 0.8; + + } + + &-item-small { + height: @loading-disappear-size-item-height * 0.6; + width: @loading-disappear-size-item-width * 0.6; + } + } + + @keyframes disappear { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + } + } +} diff --git a/packages/varlet-ui/varlet.config.js b/packages/varlet-ui/varlet.config.js index f378419fb18..7b5951ec70d 100644 --- a/packages/varlet-ui/varlet.config.js +++ b/packages/varlet-ui/varlet.config.js @@ -78,6 +78,13 @@ module.exports = { }, doc: 'skeleton', }, + { + text: { + zh_CN: '加载', + en_US: 'Loading', + }, + doc: 'loading', + }, ], language: 'zh_CN', },