@varlet/cli 1.27.20 → 2.0.0-alpha.1663742071515
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE +1 -1
- package/lib/commands/commitLint.js +1 -1
- package/lib/commands/compile.d.ts +5 -3
- package/lib/commands/compile.js +2 -2
- package/lib/commands/create.d.ts +8 -3
- package/lib/commands/create.js +100 -51
- package/lib/commands/dev.d.ts +4 -2
- package/lib/commands/dev.js +3 -3
- package/lib/commands/gen.d.ts +8 -1
- package/lib/commands/gen.js +61 -33
- package/lib/commands/jest.js +11 -7
- package/lib/commands/release.d.ts +4 -2
- package/lib/commands/release.js +2 -2
- package/lib/commands/test.d.ts +7 -0
- package/lib/commands/test.js +26 -0
- package/lib/commands/useVite.d.ts +1 -0
- package/lib/commands/useVite.js +70 -0
- package/lib/commands/vite.d.ts +3 -0
- package/lib/commands/vite.js +69 -0
- package/lib/compiler/compileModule.js +9 -5
- package/lib/compiler/compileSFC.js +14 -11
- package/lib/compiler/compileScript.js +4 -12
- package/lib/compiler/compileStyle.d.ts +1 -1
- package/lib/compiler/compileStyle.js +7 -17
- package/lib/compiler/compileTypes.js +4 -7
- package/lib/config/jest.config.js +1 -0
- package/lib/config/vite.config.js +1 -1
- package/lib/config/vitest.config.d.ts +2 -0
- package/lib/config/vitest.config.js +28 -0
- package/lib/index.js +22 -3
- package/lib/shared/constant.js +1 -1
- package/lib/shared/logger.d.ts +1 -0
- package/lib/shared/logger.js +3 -0
- package/package.json +16 -12
- package/site/components/button/Button.vue +45 -23
- package/site/components/button/button.less +6 -6
- package/site/components/button/props.ts +10 -2
- package/site/components/cell/Cell.vue +24 -12
- package/site/components/cell/cell.less +11 -7
- package/site/components/cell/props.ts +2 -2
- package/site/components/code-example/CodeExample.vue +17 -23
- package/site/components/context/index.ts +4 -0
- package/site/components/context/lock.ts +30 -41
- package/site/components/icon/Icon.vue +16 -9
- package/site/components/loading/Loading.vue +54 -25
- package/site/components/loading/loading.less +120 -35
- package/site/components/loading/props.ts +7 -2
- package/site/components/popup/Popup.tsx +102 -0
- package/site/components/popup/index.ts +10 -0
- package/site/components/popup/popup.less +125 -0
- package/site/components/popup/props.ts +63 -0
- package/site/components/progress/Progress.vue +28 -24
- package/site/components/progress/progress.less +16 -13
- package/site/components/progress/props.ts +1 -1
- package/site/components/ripple/index.ts +28 -7
- package/site/components/ripple/ripple.less +3 -0
- package/site/components/snackbar/Snackbar.vue +10 -7
- package/site/components/snackbar/core.vue +37 -22
- package/site/components/snackbar/index.tsx +14 -14
- package/site/components/snackbar/props.ts +10 -7
- package/site/components/utils/components.ts +49 -1
- package/site/components/utils/elements.ts +17 -0
- package/site/mobile/App.vue +42 -42
- package/site/mobile/components/AppHome.vue +1 -1
- package/site/mobile/components/app-bar/AppBar.vue +17 -21
- package/site/mobile/components/app-bar/appBar.less +2 -1
- package/site/mobile/main.ts +6 -2
- package/site/pc/Layout.vue +93 -67
- package/site/pc/components/AnimationBox.vue +3 -15
- package/site/pc/components/AppHeader.vue +110 -97
- package/site/pc/components/AppMobile.vue +8 -2
- package/site/pc/components/AppSidebar.vue +19 -10
- package/site/pc/components/LogoAnimation.vue +29 -31
- package/site/pc/floating.ts +3 -3
- package/site/pc/main.ts +6 -0
- package/site/pc/pages/index/index.less +142 -197
- package/site/pc/pages/index/index.vue +65 -80
- package/site/pc/pages/index/locale/en-US.ts +1 -5
- package/site/pc/pages/index/locale/zh-CN.ts +1 -5
- package/site/useProgress.ts +14 -17
- package/site/utils.ts +32 -20
- package/template/create/__tests__/index.spec.ejs +8 -0
- package/template/create/docs/en-US.md +0 -0
- package/template/create/docs/zh-CN.md +0 -0
- package/template/create/example/index.ejs +15 -0
- package/template/create/example/locale/en-US.ts +3 -0
- package/{generators/config/i18n/sfc/src/button → template/create}/example/locale/index.ts +0 -0
- package/template/create/example/locale/zh-CN.ts +3 -0
- package/template/create/index.ejs +12 -0
- package/template/create/less.ejs +3 -0
- package/template/create/props.ts +1 -0
- package/template/create/tsx.ejs +13 -0
- package/template/create/vue.ejs +17 -0
- package/{generators → template/generators}/base/.prettierignore +0 -0
- package/{generators → template/generators}/base/.prettierrc +0 -0
- package/{generators → template/generators}/base/README.md +0 -0
- package/{generators → template/generators}/base/babel.config.js +0 -0
- package/{generators → template/generators}/base/public/highlight.css +0 -0
- package/{generators → template/generators}/base/public/logo.svg +0 -0
- package/{generators → template/generators}/base/shims/shims-md.d.ts +0 -0
- package/{generators → template/generators}/base/shims/shims-vue.d.ts +0 -0
- package/{generators → template/generators}/base/tsconfig.json +0 -0
- package/{generators → template/generators}/config/default/base/docs/home.zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/base/package.json +1 -1
- package/{generators → template/generators}/config/default/base/types/basicComponent.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/types/button.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/types/index.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/varlet.config.js +1 -1
- package/{generators → template/generators}/config/default/sfc/src/button/Button.vue +6 -6
- package/{generators → template/generators}/config/default/sfc/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/default/tsx → template/generators/config/default/sfc}/src/button/button.less +1 -1
- package/{generators → template/generators}/config/default/sfc/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/index.vue +2 -2
- package/{generators → template/generators}/config/default/sfc/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/Button.tsx +11 -13
- package/{generators → template/generators}/config/default/tsx/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/i18n → template/generators/config/default}/tsx/src/button/button.less +1 -1
- package/{generators → template/generators}/config/default/tsx/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/index.vue +2 -2
- package/{generators → template/generators}/config/default/tsx/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/docs/home.en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/base/docs/home.zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/base/package.json +1 -1
- package/{generators → template/generators}/config/i18n/base/types/basicComponent.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/button.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/index.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/locale.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/varlet.config.js +3 -3
- package/{generators → template/generators}/config/i18n/sfc/src/button/Button.vue +7 -7
- package/{generators → template/generators}/config/i18n/sfc/src/button/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/button.less +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/button/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/index.vue +1 -1
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/en-US.ts +1 -1
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/index.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/en-US.d.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/en-US.ts +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/locale/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/zh-CN.d.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/Button.tsx +12 -14
- package/{generators → template/generators}/config/i18n/tsx/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/default/sfc → template/generators/config/i18n/tsx}/src/button/button.less +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/index.vue +1 -1
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/en-US.ts +1 -1
- package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/en-US.d.ts +0 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/en-US.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/locale/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/zh-CN.d.ts +0 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/zh-CN.ts +1 -1
- package/varlet.default.config.js +137 -15
- package/site/mobile/components/styles/common.less +0 -64
- package/site/mobile/components/styles/elevation.less +0 -126
- package/site/mobile/components/styles/var.less +0 -27
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<button
|
|
3
3
|
v-ripple="{ disabled: disabled || !ripple }"
|
|
4
|
-
class="
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
:class="
|
|
5
|
+
classes(
|
|
6
|
+
n(),
|
|
7
|
+
'var-site--box',
|
|
8
|
+
n(`--${size}`),
|
|
9
|
+
[block, `var-site--flex ${n('--block')}`, 'var-site--inline-flex'],
|
|
10
|
+
[disabled, n('--disabled')],
|
|
11
|
+
[text, `${n(`--text-${type}`)} ${n('--text')}`, `${n(`--${type}`)} var-site-elevation--2`],
|
|
12
|
+
[text && disabled, n('--text-disabled')],
|
|
13
|
+
[round, n('--round')],
|
|
14
|
+
[outline, n('--outline')]
|
|
15
|
+
)
|
|
16
|
+
"
|
|
15
17
|
:style="{
|
|
16
18
|
color: textColor,
|
|
17
19
|
background: color,
|
|
@@ -20,14 +22,16 @@
|
|
|
20
22
|
@click="handleClick"
|
|
21
23
|
@touchstart="handleTouchstart"
|
|
22
24
|
>
|
|
23
|
-
<var-
|
|
24
|
-
class="
|
|
25
|
+
<var-loading
|
|
26
|
+
:class="n('loading')"
|
|
27
|
+
var-site-button-cover
|
|
28
|
+
:color="loadingColor"
|
|
25
29
|
:type="loadingType"
|
|
26
30
|
:size="loadingSize"
|
|
27
31
|
:radius="loadingRadius"
|
|
28
|
-
v-if="loading"
|
|
32
|
+
v-if="loading || pending"
|
|
29
33
|
/>
|
|
30
|
-
<div class="
|
|
34
|
+
<div :class="classes(n('content'), [loading || pending, n('--hidden')])">
|
|
31
35
|
<slot />
|
|
32
36
|
</div>
|
|
33
37
|
</button>
|
|
@@ -35,39 +39,57 @@
|
|
|
35
39
|
|
|
36
40
|
<script lang="ts">
|
|
37
41
|
import Ripple from '../ripple'
|
|
38
|
-
import
|
|
39
|
-
import { defineComponent } from 'vue'
|
|
42
|
+
import VarLoading from '../loading'
|
|
43
|
+
import { defineComponent, ref } from 'vue'
|
|
40
44
|
import { props } from './props'
|
|
45
|
+
import { createNamespace } from '../utils/components'
|
|
46
|
+
import type { Ref } from 'vue'
|
|
47
|
+
|
|
48
|
+
const { n, classes } = createNamespace('button')
|
|
41
49
|
|
|
42
50
|
export default defineComponent({
|
|
43
|
-
name: '
|
|
51
|
+
name: 'VarButton',
|
|
44
52
|
components: {
|
|
45
|
-
|
|
53
|
+
VarLoading,
|
|
46
54
|
},
|
|
47
55
|
directives: { Ripple },
|
|
48
56
|
props,
|
|
49
57
|
setup(props) {
|
|
58
|
+
const pending: Ref<boolean> = ref(false)
|
|
59
|
+
|
|
60
|
+
const attemptAutoLoading = (result: any) => {
|
|
61
|
+
if (props.autoLoading) {
|
|
62
|
+
pending.value = true
|
|
63
|
+
Promise.resolve(result).finally(() => {
|
|
64
|
+
pending.value = false
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
const handleClick = (e: Event) => {
|
|
51
70
|
const { loading, disabled, onClick } = props
|
|
52
71
|
|
|
53
|
-
if (loading || disabled) {
|
|
72
|
+
if (!onClick || loading || disabled || pending.value) {
|
|
54
73
|
return
|
|
55
74
|
}
|
|
56
75
|
|
|
57
|
-
onClick
|
|
76
|
+
attemptAutoLoading(onClick(e))
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
const handleTouchstart = (e: Event) => {
|
|
61
80
|
const { loading, disabled, onTouchstart } = props
|
|
62
81
|
|
|
63
|
-
if (loading || disabled) {
|
|
82
|
+
if (!onTouchstart || loading || disabled || pending.value) {
|
|
64
83
|
return
|
|
65
84
|
}
|
|
66
85
|
|
|
67
|
-
onTouchstart
|
|
86
|
+
attemptAutoLoading(onTouchstart(e))
|
|
68
87
|
}
|
|
69
88
|
|
|
70
89
|
return {
|
|
90
|
+
n,
|
|
91
|
+
classes,
|
|
92
|
+
pending,
|
|
71
93
|
handleClick,
|
|
72
94
|
handleTouchstart,
|
|
73
95
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
@site-button-warning-color: var(--site-color-warning);
|
|
6
6
|
@site-button-info-color: var(--site-color-info);
|
|
7
7
|
@site-button-disabled-color: var(--site-color-disabled);
|
|
8
|
-
@site-button-disabled-text-color:
|
|
8
|
+
@site-button-disabled-text-color: var(--site-color-text-disabled);
|
|
9
9
|
@site-button-border-radius: 4px;
|
|
10
10
|
@site-button-mini-padding: 0 9px;
|
|
11
11
|
@site-button-small-padding: 0 11px;
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
align-items: center;
|
|
45
45
|
outline: none;
|
|
46
46
|
border: none;
|
|
47
|
-
line-height: 1.2;
|
|
48
47
|
border-radius: var(--site-button-border-radius);
|
|
49
48
|
user-select: none;
|
|
50
49
|
cursor: pointer;
|
|
51
50
|
font-family: inherit;
|
|
52
|
-
transition: box-shadow 0.2s;
|
|
51
|
+
transition: box-shadow 0.2s, background-color 0.25s;
|
|
53
52
|
will-change: box-shadow;
|
|
54
53
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
55
54
|
white-space: nowrap;
|
|
55
|
+
line-height: 1;
|
|
56
56
|
|
|
57
57
|
&:active {
|
|
58
|
-
box-shadow: 0 3px 5px -1px var(--
|
|
59
|
-
0 1px 14px 0 var(--
|
|
58
|
+
box-shadow: 0 3px 5px -1px var(--shadow-key-umbra-opacity), 0 5px 8px 0 var(--shadow-key-penumbra-opacity),
|
|
59
|
+
0 1px 14px 0 var(--shadow-key-ambient-opacity);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
&__loading {
|
|
62
|
+
&__loading[var-site-button-cover] {
|
|
63
63
|
position: absolute;
|
|
64
64
|
top: 50%;
|
|
65
65
|
left: 50%;
|
|
@@ -55,16 +55,24 @@ export const props = {
|
|
|
55
55
|
textColor: {
|
|
56
56
|
type: String,
|
|
57
57
|
},
|
|
58
|
+
autoLoading: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
58
62
|
loadingRadius: {
|
|
59
63
|
type: [Number, String],
|
|
60
64
|
default: 12,
|
|
61
65
|
},
|
|
62
66
|
loadingType: pickProps(loadingProps, 'type'),
|
|
63
67
|
loadingSize: pickProps(loadingProps, 'size'),
|
|
68
|
+
loadingColor: {
|
|
69
|
+
...pickProps(loadingProps, 'color'),
|
|
70
|
+
default: 'currentColor',
|
|
71
|
+
},
|
|
64
72
|
onClick: {
|
|
65
|
-
type: Function as PropType<(e: Event) => void
|
|
73
|
+
type: Function as PropType<(e: Event) => void | Promise<any>>,
|
|
66
74
|
},
|
|
67
75
|
onTouchstart: {
|
|
68
|
-
type: Function as PropType<(e: Event) => void
|
|
76
|
+
type: Function as PropType<(e: Event) => void | Promise<any>>,
|
|
69
77
|
},
|
|
70
78
|
}
|
|
@@ -1,37 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="
|
|
3
|
-
<div class="
|
|
2
|
+
<div :class="classes(n(), [border, n('--border')])">
|
|
3
|
+
<div :class="classes(n('icon'), [iconClass, iconClass])" v-if="$slots.icon || icon">
|
|
4
4
|
<slot name="icon">
|
|
5
|
-
<var-
|
|
5
|
+
<var-icon class="var--flex" :name="icon" />
|
|
6
6
|
</slot>
|
|
7
7
|
</div>
|
|
8
|
-
<div class="
|
|
9
|
-
<div class="
|
|
8
|
+
<div :class="n('content')">
|
|
9
|
+
<div :class="classes(n('title'), [titleClass, titleClass])">
|
|
10
10
|
<slot>{{ title }}</slot>
|
|
11
11
|
</div>
|
|
12
|
-
<div
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
<div
|
|
13
|
+
:class="classes(n('description'), [descriptionClass, descriptionClass])"
|
|
14
|
+
v-if="$slots.description || description"
|
|
15
|
+
>
|
|
16
|
+
<slot name="description">
|
|
17
|
+
{{ description }}
|
|
15
18
|
</slot>
|
|
16
19
|
</div>
|
|
17
20
|
</div>
|
|
18
|
-
<div class="
|
|
21
|
+
<div :class="classes(n('extra'), [extraClass, extraClass])" v-if="$slots.extra">
|
|
19
22
|
<slot name="extra" />
|
|
20
23
|
</div>
|
|
21
24
|
</div>
|
|
22
25
|
</template>
|
|
23
26
|
|
|
24
27
|
<script lang="ts">
|
|
28
|
+
import VarIcon from '../icon'
|
|
25
29
|
import { defineComponent } from 'vue'
|
|
26
30
|
import { props } from './props'
|
|
27
|
-
import
|
|
31
|
+
import { createNamespace } from '../utils/components'
|
|
32
|
+
|
|
33
|
+
const { n, classes } = createNamespace('cell')
|
|
28
34
|
|
|
29
35
|
export default defineComponent({
|
|
30
|
-
name: '
|
|
36
|
+
name: 'VarCell',
|
|
31
37
|
components: {
|
|
32
|
-
|
|
38
|
+
VarIcon,
|
|
33
39
|
},
|
|
34
40
|
props,
|
|
41
|
+
setup() {
|
|
42
|
+
return {
|
|
43
|
+
n,
|
|
44
|
+
classes,
|
|
45
|
+
}
|
|
46
|
+
},
|
|
35
47
|
})
|
|
36
48
|
</script>
|
|
37
49
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
@site-cell-color: var(--site-color-text);
|
|
1
2
|
@site-cell-font-size: var(--site-font-size-md);
|
|
2
|
-
@site-cell-
|
|
3
|
-
@site-cell-
|
|
3
|
+
@site-cell-description-font-size: var(--site-font-size-sm);
|
|
4
|
+
@site-cell-description-color: rgba(0, 0, 0, 0.6);
|
|
4
5
|
@site-cell-padding: 10px 12px;
|
|
5
6
|
@site-cell-min-height: 40px;
|
|
6
7
|
@site-cell-border-color: #bcc2cb;
|
|
@@ -10,9 +11,10 @@
|
|
|
10
11
|
@site-cell-extra-left: 8px;
|
|
11
12
|
|
|
12
13
|
:root {
|
|
14
|
+
--site-cell-color: @site-cell-color;
|
|
13
15
|
--site-cell-font-size: @site-cell-font-size;
|
|
14
|
-
--site-cell-
|
|
15
|
-
--site-cell-
|
|
16
|
+
--site-cell-description-font-size: @site-cell-description-font-size;
|
|
17
|
+
--site-cell-description-color: @site-cell-description-color;
|
|
16
18
|
--site-cell-padding: @site-cell-padding;
|
|
17
19
|
--site-cell-min-height: @site-cell-min-height;
|
|
18
20
|
--site-cell-border-color: @site-cell-border-color;
|
|
@@ -27,10 +29,12 @@
|
|
|
27
29
|
display: flex;
|
|
28
30
|
min-height: var(--site-cell-min-height);
|
|
29
31
|
outline: none;
|
|
32
|
+
width: 100%;
|
|
30
33
|
padding: var(--site-cell-padding);
|
|
31
34
|
position: relative;
|
|
32
35
|
box-sizing: border-box;
|
|
33
36
|
font-size: var(--site-cell-font-size);
|
|
37
|
+
color: var(--site-cell-color);
|
|
34
38
|
|
|
35
39
|
&--border {
|
|
36
40
|
&::after {
|
|
@@ -62,9 +66,9 @@
|
|
|
62
66
|
white-space: nowrap;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
&
|
|
66
|
-
font-size: var(--site-cell-
|
|
67
|
-
color: var(--site-cell-
|
|
69
|
+
&__description {
|
|
70
|
+
font-size: var(--site-cell-description-font-size);
|
|
71
|
+
color: var(--site-cell-description-color);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
&__extra {
|
|
@@ -5,7 +5,7 @@ export const props = {
|
|
|
5
5
|
icon: {
|
|
6
6
|
type: String,
|
|
7
7
|
},
|
|
8
|
-
|
|
8
|
+
description: {
|
|
9
9
|
type: String,
|
|
10
10
|
},
|
|
11
11
|
border: {
|
|
@@ -18,7 +18,7 @@ export const props = {
|
|
|
18
18
|
titleClass: {
|
|
19
19
|
type: String,
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
descriptionClass: {
|
|
22
22
|
type: String,
|
|
23
23
|
},
|
|
24
24
|
extraClass: {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="var-site-code-example">
|
|
3
3
|
<div class="var-site-code-example__toolbar">
|
|
4
|
-
<var-
|
|
5
|
-
<var-
|
|
6
|
-
</var-
|
|
4
|
+
<var-button text round @click="toggle" v-if="fold && !disabledFold">
|
|
5
|
+
<var-icon name="xml" size="18" />
|
|
6
|
+
</var-button>
|
|
7
7
|
|
|
8
|
-
<var-
|
|
8
|
+
<var-button
|
|
9
9
|
:id="`clip-trigger-${cid}`"
|
|
10
10
|
:data-clipboard-target="`#clip-target-${cid}`"
|
|
11
11
|
text
|
|
12
12
|
round
|
|
13
13
|
v-if="clipboard"
|
|
14
14
|
>
|
|
15
|
-
<var-
|
|
16
|
-
</var-
|
|
15
|
+
<var-icon name="content-copy" size="18" />
|
|
16
|
+
</var-button>
|
|
17
17
|
|
|
18
|
-
<var-
|
|
19
|
-
<var-
|
|
20
|
-
</var-
|
|
18
|
+
<var-button text round @click="toPlayground" v-if="playground">
|
|
19
|
+
<var-icon name="code-json" size="18" />
|
|
20
|
+
</var-button>
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
23
23
|
:id="`clip-target-${cid}`"
|
|
@@ -38,11 +38,12 @@ import Icon from '../icon'
|
|
|
38
38
|
import Button from '../button'
|
|
39
39
|
import Snackbar from '../snackbar'
|
|
40
40
|
import Clipboard from 'clipboard'
|
|
41
|
+
import context from '../context'
|
|
41
42
|
import config from '@config'
|
|
42
43
|
import { defineComponent, nextTick, ref, onMounted } from 'vue'
|
|
43
44
|
import { doubleRaf } from '../utils/elements'
|
|
44
45
|
import { get } from 'lodash-es'
|
|
45
|
-
import { getPCLocationInfo, utoa } from
|
|
46
|
+
import { getBrowserTheme, getPCLocationInfo, utoa } from "../../utils";
|
|
46
47
|
import type { Ref } from 'vue'
|
|
47
48
|
|
|
48
49
|
let clipId = 0
|
|
@@ -94,21 +95,14 @@ export default defineComponent({
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
const toPlayground = () => {
|
|
97
|
-
const
|
|
98
|
-
const scriptEnd = '<\/script>'
|
|
99
|
-
const injectImport = 'import { installVarletUI } from \'./varlet-repl-plugin.js\'\n'
|
|
100
|
-
const injectCall = '\ninstallVarletUI()\n'
|
|
101
|
-
let codeText = code.value?.innerText ?? ''
|
|
102
|
-
|
|
103
|
-
if (codeText.includes(scriptStart)) {
|
|
104
|
-
codeText = codeText.replace(scriptStart, `${scriptStart}${injectImport}`)
|
|
105
|
-
codeText = codeText.replace(scriptEnd, `${injectCall}${scriptEnd}`)
|
|
106
|
-
} else {
|
|
107
|
-
codeText = `${scriptStart}${injectImport}${injectCall}<\/script>\n\n${codeText}`
|
|
108
|
-
}
|
|
98
|
+
const codeText = code.value?.innerText ?? ''
|
|
109
99
|
|
|
110
100
|
const file = { 'App.vue': codeText }
|
|
111
|
-
|
|
101
|
+
|
|
102
|
+
const initialTheme = getBrowserTheme().replace('Theme', '')
|
|
103
|
+
|
|
104
|
+
context.showPlayground = true
|
|
105
|
+
context.playgroundURL = `${playground.value}/?initialTheme=${initialTheme}#${utoa(JSON.stringify(file))}`
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
onMounted(() => {
|
|
@@ -4,12 +4,16 @@ interface Context {
|
|
|
4
4
|
locks: Record<any, number>
|
|
5
5
|
zIndex: number
|
|
6
6
|
touchmoveForbid: boolean
|
|
7
|
+
showPlayground: boolean,
|
|
8
|
+
playgroundURL: string
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
const context: Context = {
|
|
10
12
|
locks: {},
|
|
11
13
|
zIndex: 2000,
|
|
12
14
|
touchmoveForbid: true,
|
|
15
|
+
showPlayground: false,
|
|
16
|
+
playgroundURL: ''
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export const _ContextComponent = reactive<Context>(context)
|
|
@@ -17,85 +17,74 @@ export function releaseLock(uid: number) {
|
|
|
17
17
|
resolveLock()
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
* 组件锁操作
|
|
22
|
-
* @param props 组件props
|
|
23
|
-
* @param state 组件props中控制组件加锁的开关对应的key值
|
|
24
|
-
* @param use 组件props中控制组件加锁的开关是否可用对应的key值
|
|
25
|
-
*/
|
|
26
|
-
export function useLock(props: any, state: string, use?: string) {
|
|
20
|
+
export function useLock(source: any, useSource?: any) {
|
|
27
21
|
const { uid } = getCurrentInstance() as ComponentInternalInstance
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(newValue
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
addLock(uid)
|
|
38
|
-
}
|
|
22
|
+
|
|
23
|
+
if (useSource) {
|
|
24
|
+
watch(useSource, (newValue: boolean) => {
|
|
25
|
+
if (newValue === false) {
|
|
26
|
+
// 改变为禁用状态 组件解锁
|
|
27
|
+
releaseLock(uid)
|
|
28
|
+
} else if (newValue === true && source() === true) {
|
|
29
|
+
// 改变为启用状态 并且popup处于开启状态 组件加锁
|
|
30
|
+
addLock(uid)
|
|
39
31
|
}
|
|
40
|
-
)
|
|
32
|
+
})
|
|
41
33
|
}
|
|
42
34
|
|
|
43
|
-
watch(
|
|
44
|
-
()
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
}
|
|
35
|
+
watch(source, (newValue: boolean) => {
|
|
36
|
+
if (useSource && useSource() === false) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
40
|
+
if (newValue === true) {
|
|
41
|
+
// popup开启 组件加锁
|
|
42
|
+
addLock(uid)
|
|
43
|
+
} else {
|
|
44
|
+
// popup关闭 组件解锁
|
|
45
|
+
releaseLock(uid)
|
|
57
46
|
}
|
|
58
|
-
)
|
|
47
|
+
})
|
|
59
48
|
|
|
60
49
|
onBeforeMount(() => {
|
|
61
|
-
if (
|
|
50
|
+
if (useSource && useSource() === false) {
|
|
62
51
|
return
|
|
63
52
|
}
|
|
64
53
|
|
|
65
|
-
if (
|
|
54
|
+
if (source() === true) {
|
|
66
55
|
// popup处于开启状态 组件挂载 组件加锁
|
|
67
56
|
addLock(uid)
|
|
68
57
|
}
|
|
69
58
|
})
|
|
70
59
|
|
|
71
60
|
onUnmounted(() => {
|
|
72
|
-
if (
|
|
61
|
+
if (useSource && useSource() === false) {
|
|
73
62
|
return
|
|
74
63
|
}
|
|
75
64
|
|
|
76
|
-
if (
|
|
65
|
+
if (source() === true) {
|
|
77
66
|
// popup处于开启状态 组件卸载 组件解锁
|
|
78
67
|
releaseLock(uid)
|
|
79
68
|
}
|
|
80
69
|
})
|
|
81
70
|
|
|
82
71
|
onActivated(() => {
|
|
83
|
-
if (
|
|
72
|
+
if (useSource && useSource() === false) {
|
|
84
73
|
return
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
if (
|
|
76
|
+
if (source() === true) {
|
|
88
77
|
// popup处于开启状态 组件处于keepalive前台 组件加锁
|
|
89
78
|
addLock(uid)
|
|
90
79
|
}
|
|
91
80
|
})
|
|
92
81
|
|
|
93
82
|
onDeactivated(() => {
|
|
94
|
-
if (
|
|
83
|
+
if (useSource && useSource() === false) {
|
|
95
84
|
return
|
|
96
85
|
}
|
|
97
86
|
|
|
98
|
-
if (
|
|
87
|
+
if (source() === true) {
|
|
99
88
|
// popup处于开启状态 组件处于keepalive后台 组件解锁
|
|
100
89
|
releaseLock(uid)
|
|
101
90
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component
|
|
3
|
-
class="var-site-icon"
|
|
4
3
|
:is="isURL(name) ? 'img' : 'i'"
|
|
5
|
-
:class="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
:class="
|
|
5
|
+
classes(
|
|
6
|
+
n(),
|
|
7
|
+
`${namespace}--set`,
|
|
8
|
+
[isURL(name), n('image'), `${namespace}-${nextName}`],
|
|
9
|
+
[shrinking, n('--shrinking')]
|
|
10
|
+
)
|
|
11
|
+
"
|
|
10
12
|
:style="{
|
|
11
13
|
color,
|
|
12
|
-
transition: `
|
|
14
|
+
transition: `transform ${toNumber(transition)}ms`,
|
|
13
15
|
width: isURL(name) ? toSizeUnit(size) : null,
|
|
14
16
|
height: isURL(name) ? toSizeUnit(size) : null,
|
|
15
17
|
fontSize: toSizeUnit(size),
|
|
@@ -22,12 +24,15 @@
|
|
|
22
24
|
<script lang="ts">
|
|
23
25
|
import { defineComponent, watch, ref, nextTick } from 'vue'
|
|
24
26
|
import { isURL, toNumber } from '@varlet/shared'
|
|
25
|
-
import { toSizeUnit } from '../utils/elements'
|
|
26
27
|
import { props } from './props'
|
|
28
|
+
import { toSizeUnit } from '../utils/elements'
|
|
27
29
|
import type { Ref } from 'vue'
|
|
30
|
+
import { createNamespace } from '../utils/components'
|
|
31
|
+
|
|
32
|
+
const { n, classes } = createNamespace('icon')
|
|
28
33
|
|
|
29
34
|
export default defineComponent({
|
|
30
|
-
name: '
|
|
35
|
+
name: 'VarIcon',
|
|
31
36
|
props,
|
|
32
37
|
setup(props) {
|
|
33
38
|
const nextName: Ref<string | undefined> = ref('')
|
|
@@ -52,6 +57,8 @@ export default defineComponent({
|
|
|
52
57
|
watch(() => props.name, handleNameChange, { immediate: true })
|
|
53
58
|
|
|
54
59
|
return {
|
|
60
|
+
n,
|
|
61
|
+
classes,
|
|
55
62
|
nextName,
|
|
56
63
|
shrinking,
|
|
57
64
|
isURL,
|