@varlet/cli 1.20.0 → 1.21.1-alpha.64

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.
Files changed (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.en-US.md +11 -0
  3. package/README.md +11 -0
  4. package/generators/sfc/package.json +3 -2
  5. package/generators/sfc/varlet.config.js +5 -0
  6. package/generators/tsx/package.json +3 -2
  7. package/generators/tsx/varlet.config.js +5 -0
  8. package/lib/commands/build.js +19 -15
  9. package/lib/commands/dev.d.ts +3 -2
  10. package/lib/commands/dev.js +23 -34
  11. package/lib/commands/jest.d.ts +3 -3
  12. package/lib/commands/preview.d.ts +1 -0
  13. package/lib/commands/preview.js +65 -0
  14. package/lib/compiler/compileModule.js +7 -14
  15. package/lib/compiler/compileSFC.js +7 -2
  16. package/lib/compiler/compileSiteEntry.d.ts +1 -4
  17. package/lib/compiler/compileSiteEntry.js +10 -20
  18. package/lib/compiler/compileStyle.js +1 -60
  19. package/lib/config/babel.config.js +0 -9
  20. package/lib/config/jest.config.js +1 -1
  21. package/lib/config/jest.lib.mock.d.ts +0 -0
  22. package/lib/config/jest.lib.mock.js +2 -0
  23. package/lib/config/postcss.config.d.ts +4 -1
  24. package/lib/config/postcss.config.js +14 -38
  25. package/lib/config/varlet.config.d.ts +1 -1
  26. package/lib/config/vite.config.d.ts +4 -0
  27. package/lib/config/vite.config.js +128 -0
  28. package/lib/config/webpack.base.config.js +1 -1
  29. package/lib/index.js +7 -2
  30. package/lib/shared/constant.d.ts +2 -8
  31. package/lib/shared/constant.js +3 -9
  32. package/lib/site/components/app-bar/index.d.ts +3 -0
  33. package/lib/site/components/app-bar/index.js +12 -0
  34. package/lib/site/components/app-bar/props.d.ts +21 -0
  35. package/lib/site/components/app-bar/props.js +28 -0
  36. package/lib/site/components/button/index.d.ts +3 -0
  37. package/lib/site/components/button/index.js +12 -0
  38. package/lib/site/components/button/props.d.ts +62 -0
  39. package/lib/site/components/button/props.js +69 -0
  40. package/lib/site/components/cell/index.d.ts +3 -0
  41. package/lib/site/components/cell/index.js +12 -0
  42. package/lib/site/components/cell/props.d.ts +27 -0
  43. package/lib/site/components/cell/props.js +30 -0
  44. package/lib/site/components/context/index.d.ts +15 -0
  45. package/lib/site/components/context/index.js +11 -0
  46. package/lib/site/components/context/lock.d.ts +10 -0
  47. package/lib/site/components/context/lock.js +94 -0
  48. package/lib/site/components/context/zIndex.d.ts +4 -0
  49. package/lib/site/components/context/zIndex.js +19 -0
  50. package/lib/site/components/icon/index.d.ts +3 -0
  51. package/lib/site/components/icon/index.js +12 -0
  52. package/lib/site/components/icon/props.d.ts +23 -0
  53. package/lib/site/components/icon/props.js +25 -0
  54. package/lib/site/components/loading/index.d.ts +3 -0
  55. package/lib/site/components/loading/index.js +12 -0
  56. package/lib/site/components/loading/props.d.ts +26 -0
  57. package/lib/site/components/loading/props.js +34 -0
  58. package/lib/site/components/menu/index.d.ts +3 -0
  59. package/lib/site/components/menu/index.js +12 -0
  60. package/lib/site/components/menu/props.d.ts +40 -0
  61. package/lib/site/components/menu/props.js +43 -0
  62. package/lib/site/components/progress/index.d.ts +3 -0
  63. package/lib/site/components/progress/index.js +12 -0
  64. package/lib/site/components/progress/props.d.ts +43 -0
  65. package/lib/site/components/progress/props.js +57 -0
  66. package/lib/site/components/ripple/index.d.ts +8 -0
  67. package/lib/site/components/ripple/index.js +125 -0
  68. package/lib/site/components/utils/components.d.ts +53 -0
  69. package/lib/site/components/utils/components.js +279 -0
  70. package/lib/site/components/utils/elements.d.ts +30 -0
  71. package/lib/site/components/utils/elements.js +240 -0
  72. package/lib/site/components/utils/shared.d.ts +36 -0
  73. package/lib/site/components/utils/shared.js +181 -0
  74. package/lib/site/mobile/main.d.ts +3 -0
  75. package/lib/site/mobile/main.js +93 -0
  76. package/lib/site/pc/main.d.ts +3 -0
  77. package/lib/site/pc/main.js +69 -0
  78. package/lib/site/useProgress.d.ts +4 -0
  79. package/lib/site/useProgress.js +58 -0
  80. package/lib/site/utils.d.ts +24 -0
  81. package/lib/site/utils.js +133 -0
  82. package/package.json +16 -30
  83. package/site/.DS_Store +0 -0
  84. package/site/components/app-bar/AppBar.vue +45 -0
  85. package/site/components/app-bar/appBar.less +66 -0
  86. package/site/components/app-bar/index.ts +10 -0
  87. package/site/components/app-bar/props.ts +25 -0
  88. package/site/components/button/Button.vue +84 -0
  89. package/site/components/button/button.less +183 -0
  90. package/site/components/button/index.ts +10 -0
  91. package/site/components/button/props.ts +70 -0
  92. package/site/components/cell/Cell.vue +42 -0
  93. package/site/components/cell/cell.less +74 -0
  94. package/site/components/cell/index.ts +10 -0
  95. package/site/components/cell/props.ts +27 -0
  96. package/site/components/context/index.ts +17 -0
  97. package/site/components/context/lock.ts +103 -0
  98. package/site/components/context/zIndex.ts +20 -0
  99. package/site/components/icon/Icon.vue +68 -0
  100. package/site/components/icon/icon.less +25 -0
  101. package/site/components/icon/index.ts +10 -0
  102. package/site/components/icon/props.ts +24 -0
  103. package/site/components/loading/Loading.vue +55 -0
  104. package/site/components/loading/index.ts +10 -0
  105. package/site/components/loading/loading.less +420 -0
  106. package/site/components/loading/props.ts +37 -0
  107. package/site/components/menu/Menu.vue +113 -0
  108. package/site/components/menu/index.ts +10 -0
  109. package/site/components/menu/menu.less +27 -0
  110. package/site/components/menu/props.ts +43 -0
  111. package/site/components/progress/Progress.vue +108 -0
  112. package/site/components/progress/index.ts +10 -0
  113. package/site/components/progress/progress.less +98 -0
  114. package/site/components/progress/props.ts +55 -0
  115. package/site/components/ripple/index.ts +167 -0
  116. package/site/components/ripple/ripple.less +17 -0
  117. package/site/components/styles/common.less +64 -0
  118. package/site/components/styles/elevation.less +126 -0
  119. package/site/components/styles/var.less +27 -0
  120. package/site/components/utils/components.ts +53 -0
  121. package/site/components/utils/elements.ts +83 -0
  122. package/site/components/utils/shared.ts +27 -0
  123. package/site/{pc/index.html → index.html} +6 -4
  124. package/site/mobile/App.vue +20 -18
  125. package/site/mobile/components/AppHome.vue +6 -8
  126. package/site/mobile/main.ts +17 -2
  127. package/site/{mobile/mobile.html → mobile.html} +6 -5
  128. package/site/pc/App.vue +16 -11
  129. package/site/pc/components/AppHeader.vue +15 -13
  130. package/site/pc/components/AppMobile.vue +3 -3
  131. package/site/pc/components/AppSidebar.vue +17 -23
  132. package/site/pc/main.ts +10 -2
  133. package/site/useProgress.ts +11 -9
  134. package/site/utils.ts +14 -3
  135. package/varlet.default.config.js +3 -2
  136. package/generators/sfc/yarn.lock +0 -11231
  137. package/generators/tsx/yarn.lock +0 -11231
@@ -0,0 +1,53 @@
1
+ import { createApp, h } from 'vue'
2
+ import type { Component } from 'vue'
3
+
4
+ export interface MountInstance {
5
+ instance: any
6
+ unmount: () => void
7
+ }
8
+
9
+ export function pickProps(props: any, propsKey: string): any
10
+ export function pickProps(props: any, propsKey: string[]): any
11
+ export function pickProps(props: any, propsKey: any): any {
12
+ return Array.isArray(propsKey)
13
+ ? propsKey.reduce((pickedProps: any, key) => {
14
+ pickedProps[key] = props[key]
15
+ return pickedProps
16
+ }, {})
17
+ : props[propsKey]
18
+ }
19
+
20
+ export function mount(component: Component): MountInstance {
21
+ const app = createApp(component)
22
+ const host = document.createElement('div')
23
+ document.body.appendChild(host)
24
+
25
+ return {
26
+ instance: app.mount(host),
27
+ unmount() {
28
+ app.unmount()
29
+ document.body.removeChild(host)
30
+ }
31
+ }
32
+ }
33
+
34
+ export function mountInstance(
35
+ component: any,
36
+ props: Record<string, any> = {},
37
+ eventListener: Record<string, any> = {}
38
+ ): {
39
+ unmountInstance: () => void
40
+ } {
41
+ const Host = {
42
+ setup() {
43
+ return () =>
44
+ h(component, {
45
+ ...props,
46
+ ...eventListener
47
+ })
48
+ }
49
+ }
50
+
51
+ const { unmount } = mount(Host)
52
+ return { unmountInstance: unmount }
53
+ }
@@ -0,0 +1,83 @@
1
+ import { isNumber, isString, toNumber, kebabCase } from './shared'
2
+ import type { StyleVars } from '../../utils'
3
+
4
+ export function getLeft(element: HTMLElement): number {
5
+ const { left } = element.getBoundingClientRect()
6
+
7
+ return left + (document.body.scrollLeft || document.documentElement.scrollLeft)
8
+ }
9
+
10
+ export function getTop(element: HTMLElement): number {
11
+ const { top } = element.getBoundingClientRect()
12
+
13
+ return top + (document.body.scrollTop || document.documentElement.scrollTop)
14
+ }
15
+
16
+ export const isRem = (value: unknown) => isString(value) && value.endsWith('rem')
17
+
18
+ // example 1 || 1px
19
+ export const isPx = (value: unknown) => (isString(value) && value.endsWith('px')) || isNumber(value)
20
+
21
+ // example 1%
22
+ export const isPercent = (value: unknown) => isString(value) && value.endsWith('%')
23
+
24
+ // example 1vw
25
+ export const isVw = (value: unknown) => isString(value) && value.endsWith('vw')
26
+
27
+ // example 1vh
28
+ export const isVh = (value: unknown) => isString(value) && value.endsWith('vh')
29
+
30
+ // example return 1
31
+ export const toPxNum = (value: unknown): number => {
32
+ if (isNumber(value)) {
33
+ return value
34
+ }
35
+
36
+ if (isPx(value)) {
37
+ return +(value as string).replace('px', '')
38
+ }
39
+
40
+ if (isVw(value)) {
41
+ return (+(value as string).replace('vw', '') * window.innerWidth) / 100
42
+ }
43
+
44
+ if (isVh(value)) {
45
+ return (+(value as string).replace('vh', '') * window.innerHeight) / 100
46
+ }
47
+
48
+ if (isRem(value)) {
49
+ const num = +(value as string).replace('rem', '')
50
+ const rootFontSize = window.getComputedStyle(document.documentElement).fontSize
51
+
52
+ return num * parseFloat(rootFontSize)
53
+ }
54
+
55
+ if (isString(value)) {
56
+ return toNumber(value)
57
+ }
58
+
59
+ // % and other
60
+ return 0
61
+ }
62
+
63
+ // example return 1px 1% 1vw 1vh 1rem null
64
+ export const toSizeUnit = (value: unknown) => {
65
+ if (value == null) {
66
+ return null
67
+ }
68
+
69
+ if (isPercent(value) || isVw(value) || isVh(value) || isRem(value)) {
70
+ return value
71
+ }
72
+
73
+ return `${toPxNum(value)}px`
74
+ }
75
+
76
+ export function formatStyleVars(styleVars: StyleVars) {
77
+ return Object.entries(styleVars).reduce((styles, [key, value]) => {
78
+ const cssVar = key.startsWith('--') ? key : `--${kebabCase(key)}`
79
+ styles[cssVar] = value
80
+
81
+ return styles
82
+ }, {} as StyleVars)
83
+ }
@@ -0,0 +1,27 @@
1
+ export const toNumber = (val: number | string | boolean | undefined | null): number => {
2
+ if (val == null) return 0
3
+
4
+ if (isString(val)) {
5
+ val = parseFloat(val)
6
+ val = Number.isNaN(val) ? 0 : val
7
+ return val
8
+ }
9
+
10
+ if (isBool(val)) return Number(val)
11
+
12
+ return val
13
+ }
14
+
15
+ export function kebabCase(str: string): string {
16
+ const reg = /([^-])([A-Z])/g
17
+
18
+ return str.replace(reg, '$1-$2').replace(reg, '$1-$2').toLowerCase()
19
+ }
20
+
21
+ export const isString = (val: unknown): val is string => typeof val === 'string'
22
+
23
+ export const isBool = (val: unknown): val is boolean => typeof val === 'boolean'
24
+
25
+ export const isNumber = (val: unknown): val is number => typeof val === 'number'
26
+
27
+ export const isURL = (val: string) => /^(http)|(\.*\/)/.test(val)
@@ -2,11 +2,11 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <title><%= htmlWebpackPlugin.options.title %></title>
5
+ <title><%= pcTitle %></title>
6
6
  <meta http-equiv="Cache-Control" content="no-cache">
7
7
  <meta http-equiv="Pragma" content="no-cache">
8
8
  <meta http-equiv="Expires" content="0">
9
- <link href="<%= htmlWebpackPlugin.options.logo %>" rel="icon" type="image/png" />
9
+ <link href="<%= logo %>" rel="icon" type="image/png" />
10
10
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
11
11
  name="viewport" />
12
12
  <style>
@@ -19,11 +19,11 @@
19
19
  }
20
20
  </style>
21
21
  <script>
22
- if ('<%= htmlWebpackPlugin.options.baidu %>') {
22
+ if ('<%= baidu %>') {
23
23
  var _hmt = _hmt || [];
24
24
  (function() {
25
25
  var hm = document.createElement('script')
26
- hm.src = '<%= htmlWebpackPlugin.options.baidu %>'
26
+ hm.src = '<%= baidu %>'
27
27
  var s = document.getElementsByTagName('script')[0]
28
28
  s.parentNode.insertBefore(hm, s)
29
29
  })()
@@ -32,5 +32,7 @@
32
32
  </head>
33
33
  <body>
34
34
  <div id="app"></div>
35
+
36
+ <script type="module" src="/pc/main.ts"></script>
35
37
  </body>
36
38
  </html>
@@ -1,31 +1,31 @@
1
1
  <template>
2
2
  <div style="position: relative">
3
3
  <header>
4
- <var-app-bar
4
+ <var-site-app-bar
5
5
  class="app-bar"
6
6
  :title="bigCamelizeComponentName"
7
7
  title-position="center"
8
8
  >
9
9
  <template #left v-if="showBackIcon">
10
- <var-button round @click="back" color="transparent" text-color="#fff" text>
11
- <var-icon name="chevron-left" :size="28" />
12
- </var-button>
10
+ <var-site-button round @click="back" color="transparent" text-color="#fff" text>
11
+ <var-site-icon name="chevron-left" :size="28" />
12
+ </var-site-button>
13
13
  </template>
14
14
  <template #right>
15
- <var-menu
15
+ <var-site-menu
16
16
  style="background: transparent"
17
17
  :offset-y="38"
18
18
  v-model:show="showMenu"
19
19
  v-if="languages"
20
20
  >
21
- <var-button text color="transparent" text-color="#fff" @click="showMenu = true">
22
- <var-icon name="translate" :size="24" />
23
- <var-icon name="chevron-down" :size="24" />
24
- </var-button>
21
+ <var-site-button text color="transparent" text-color="#fff" @click="showMenu = true">
22
+ <var-site-icon name="translate" :size="24" />
23
+ <var-site-icon name="chevron-down" :size="24" />
24
+ </var-site-button>
25
25
 
26
26
  <template #menu>
27
27
  <div style="background: #fff">
28
- <var-cell
28
+ <var-site-cell
29
29
  v-for="(value, key) in nonEmptyLanguages"
30
30
  :key="key"
31
31
  class="mobile-language-cell"
@@ -34,12 +34,12 @@
34
34
  @click="changeLanguage(key)"
35
35
  >
36
36
  {{ value }}
37
- </var-cell>
37
+ </var-site-cell>
38
38
  </div>
39
39
  </template>
40
- </var-menu>
40
+ </var-site-menu>
41
41
  </template>
42
- </var-app-bar>
42
+ </var-site-app-bar>
43
43
  </header>
44
44
  <div class="router-view__block">
45
45
  <router-view />
@@ -53,7 +53,7 @@ import config from '@config'
53
53
  import { computed, ComputedRef, defineComponent, ref, Ref, watch } from 'vue'
54
54
  import { useRoute } from 'vue-router'
55
55
  import { bigCamelize, removeEmpty, setThemes, watchLang } from '../utils'
56
- import { get } from 'lodash'
56
+ import { get } from 'lodash-es'
57
57
 
58
58
  type Language = Record<string, string>
59
59
 
@@ -107,7 +107,9 @@ export default defineComponent({
107
107
  </script>
108
108
 
109
109
  <style lang="less">
110
- @import '~@varlet/ui/es/styles/var';
110
+ * {
111
+ -webkit-font-smoothing: antialiased;
112
+ }
111
113
 
112
114
  body {
113
115
  margin: 0;
@@ -132,7 +134,7 @@ header {
132
134
  }
133
135
 
134
136
  .app-bar {
135
- background: var(--site-color-app-bar);
137
+ background: var(--site-config-color-app-bar) !important;
136
138
  }
137
139
 
138
140
  .router-view__block {
@@ -148,8 +150,8 @@ header {
148
150
  cursor: pointer;
149
151
 
150
152
  &--active {
151
- color: var(--site-color-mobile-language-active);
152
- background: var(--site-color-mobile-language-active-background);
153
+ color: var(--site-config-color-mobile-language-active);
154
+ background: var(--site-config-color-mobile-language-active-background);
153
155
  }
154
156
  }
155
157
  </style>
@@ -6,19 +6,19 @@
6
6
  </h1>
7
7
  <h2 class="varlet-home__desc">{{ description[lang] }}</h2>
8
8
  </div>
9
- <var-cell
9
+ <var-site-cell
10
10
  v-for="component in components"
11
11
  :key="component.text"
12
12
  @click="toComponent(component)"
13
13
  v-ripple
14
14
  >
15
15
  <template #extra>
16
- <var-icon name="chevron-right" size="14" />
16
+ <var-site-icon name="chevron-right" size="14" />
17
17
  </template>
18
18
  <template #default>
19
19
  {{ component.text[lang] }}
20
20
  </template>
21
- </var-cell>
21
+ </var-site-cell>
22
22
  </template>
23
23
 
24
24
  <script>
@@ -72,8 +72,6 @@ export default {
72
72
  </script>
73
73
 
74
74
  <style scoped lang="less">
75
- @import '~@varlet/ui/es/styles/var';
76
-
77
75
  .logo {
78
76
  height: 100px;
79
77
  padding-top: 30px;
@@ -114,15 +112,15 @@ export default {
114
112
  margin-left: 16px;
115
113
  }
116
114
 
117
- .var-cell {
115
+ .var-site-cell {
118
116
  cursor: pointer;
119
117
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
120
118
  transition: all 0.3s;
121
119
  color: #555;
122
120
 
123
121
  &:hover {
124
- color: var(--site-color-mobile-cell-hover);
125
- background: var(--site-color-mobile-cell-hover-background);
122
+ color: var(--site-config-color-mobile-cell-hover);
123
+ background: var(--site-config-color-mobile-cell-hover-background);
126
124
  }
127
125
  }
128
126
  </style>
@@ -6,8 +6,17 @@ import App from './App.vue'
6
6
  import '@varlet/touch-emulator'
7
7
  import { createApp } from 'vue'
8
8
  import { createRouter, createWebHashHistory } from 'vue-router'
9
- import { Icon, AppBar, Button, Menu, Cell, Ripple } from '@varlet/ui'
10
- import { get } from 'lodash'
9
+
10
+ import Icon from '../components/icon'
11
+ import AppBar from '../components/app-bar'
12
+ import Button from '../components/button'
13
+ import Menu from '../components/menu'
14
+ import Cell from '../components/cell'
15
+ import Ripple from '../components/ripple'
16
+ import '../components/styles/common.less'
17
+ import '../components/styles/elevation.less'
18
+
19
+ import { get } from 'lodash-es'
11
20
  import { inIframe, isPhone } from '../utils'
12
21
 
13
22
  const redirect = get(config, 'mobile.redirect')
@@ -53,12 +62,18 @@ router.beforeEach((to, from) => {
53
62
  }
54
63
  })
55
64
 
65
+ // @ts-ignore
56
66
  createApp(App)
57
67
  .use(router)
68
+ // @ts-ignore
58
69
  .use(Icon)
70
+ // @ts-ignore
59
71
  .use(AppBar)
72
+ // @ts-ignore
60
73
  .use(Cell)
61
74
  .use(Ripple)
75
+ // @ts-ignore
62
76
  .use(Button)
77
+ // @ts-ignore
63
78
  .use(Menu)
64
79
  .mount('#app')
@@ -2,12 +2,11 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <title><%= htmlWebpackPlugin.options.title %></title>
5
+ <title><%= mobileTitle %></title>
6
6
  <meta http-equiv="Cache-Control" content="no-cache">
7
7
  <meta http-equiv="Pragma" content="no-cache">
8
8
  <meta http-equiv="Expires" content="0">
9
- <meta content="<%= htmlWebpackPlugin.options.description %>" name="description" />
10
- <link href="<%= htmlWebpackPlugin.options.logo %>" rel="icon" type="image/png" />
9
+ <link href="<%= logo %>" rel="icon" type="image/png" />
11
10
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
12
11
  name="viewport" />
13
12
  <style>
@@ -20,11 +19,11 @@
20
19
  }
21
20
  </style>
22
21
  <script>
23
- if ('<%= htmlWebpackPlugin.options.baidu %>') {
22
+ if ('<%= baidu %>') {
24
23
  var _hmt = _hmt || [];
25
24
  (function() {
26
25
  var hm = document.createElement('script')
27
- hm.src = '<%= htmlWebpackPlugin.options.baidu %>'
26
+ hm.src = '<%= baidu %>'
28
27
  var s = document.getElementsByTagName('script')[0]
29
28
  s.parentNode.insertBefore(hm, s)
30
29
  })()
@@ -33,5 +32,7 @@
33
32
  </head>
34
33
  <body>
35
34
  <div id="app"></div>
35
+
36
+ <script type="module" src="/mobile/main.ts"></script>
36
37
  </body>
37
38
  </html>
package/site/pc/App.vue CHANGED
@@ -36,7 +36,7 @@ import AppHeader from './components/AppHeader'
36
36
  import AppSidebar from './components/AppSidebar'
37
37
  import { defineComponent, nextTick, onMounted, ref, Ref, watch } from 'vue'
38
38
  import { useRoute } from 'vue-router'
39
- import { get } from 'lodash'
39
+ import { get } from 'lodash-es'
40
40
  import { getPCLocationInfo, isPhone, MenuTypes, setThemes } from '../utils'
41
41
 
42
42
  type Language = Record<string, string>
@@ -82,7 +82,7 @@ export default defineComponent({
82
82
  nextTick(() => {
83
83
  const children = document
84
84
  .querySelector('.varlet-site-sidebar')
85
- .getElementsByClassName('var-cell')
85
+ .getElementsByClassName('var-site-cell')
86
86
  const index = menu.value.findIndex((item) => item.doc === menuName)
87
87
 
88
88
  if (index !== -1) {
@@ -142,13 +142,17 @@ export default defineComponent({
142
142
  </style>
143
143
 
144
144
  <style lang="less">
145
- @import '~@varlet/ui/es/progress/progress';
146
-
147
145
  @doc-active: {
148
146
  display: inline;
149
147
  font-family: inherit;
150
148
  padding: 0 4px;
151
- white-space: nowrap;
149
+ white-space: pre-wrap;
150
+ }
151
+
152
+ ::-webkit-scrollbar {
153
+ display: none;
154
+ width: 0;
155
+ background: transparent;
152
156
  }
153
157
 
154
158
  body {
@@ -172,7 +176,7 @@ iframe {
172
176
  align-items: center;
173
177
  margin: 20px 4px 20px;
174
178
  padding: 40px;
175
- border-top: 7px solid var(--site-color-primary);
179
+ border-top: 7px solid var(--site-config-color-primary);
176
180
  border-radius: 4px;
177
181
  box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12);
178
182
 
@@ -199,9 +203,10 @@ iframe {
199
203
 
200
204
  &-site {
201
205
  &-content {
202
- height: calc(100vh - 60px);
203
206
  display: flex;
204
207
  background: #fff;
208
+ margin-top: 60px;
209
+ margin-left: 220px;
205
210
  }
206
211
 
207
212
  &-doc-container {
@@ -222,7 +227,7 @@ iframe {
222
227
 
223
228
  &-doc {
224
229
  a {
225
- color: var(--site-color-link);
230
+ color: var(--site-config-color-link);
226
231
  -webkit-font-smoothing: antialiased;
227
232
  word-break: keep-all;
228
233
  font-size: 15px;
@@ -295,7 +300,7 @@ iframe {
295
300
  table code {
296
301
  -webkit-font-smoothing: antialiased;
297
302
  word-break: keep-all;
298
- color: var(--site-color-primary);
303
+ color: var(--site-config-color-primary);
299
304
  font-size: 15px;
300
305
  @doc-active();
301
306
  }
@@ -327,14 +332,14 @@ iframe {
327
332
  font-family: Consolas, Monaco, monospace;
328
333
 
329
334
  code {
330
- white-space: nowrap;
335
+ white-space: pre-wrap;
331
336
  padding: 0;
332
337
  font-size: 13px;
333
338
  }
334
339
  }
335
340
 
336
341
  em {
337
- color: var(--site-color-type);
342
+ color: var(--site-config-color-type);
338
343
  font-style: normal;
339
344
  -webkit-font-smoothing: antialiased;
340
345
  font-size: 13px;
@@ -12,15 +12,15 @@
12
12
  @mouseleave="isOpenMenu = false"
13
13
  v-if="languages"
14
14
  >
15
- <var-icon name="translate" size="26px" color="#666" />
16
- <var-icon name="chevron-down" color="#666" />
15
+ <var-site-icon name="translate" size="26px" color="#666" />
16
+ <var-site-icon name="chevron-down" color="#666" />
17
17
  <transition name="fade">
18
18
  <div
19
19
  class="varlet-site-header__language-list var-elevation--5"
20
20
  v-show="isOpenMenu"
21
21
  :style="{ pointerEvents: isOpenMenu ? 'auto' : 'none' }"
22
22
  >
23
- <var-cell
23
+ <var-site-cell
24
24
  v-for="(value, key) in nonEmptyLanguages"
25
25
  v-ripple
26
26
  :key="key"
@@ -28,7 +28,7 @@
28
28
  @click="handleLanguageChange(key)"
29
29
  >
30
30
  {{ value }}
31
- </var-cell>
31
+ </var-site-cell>
32
32
  </div>
33
33
  </transition>
34
34
  </div>
@@ -38,7 +38,7 @@
38
38
  :href="github"
39
39
  v-if="github"
40
40
  >
41
- <var-icon name="github" color="#666" :size="28" />
41
+ <var-site-icon name="github" color="#666" :size="28" />
42
42
  </a>
43
43
  </div>
44
44
  </div>
@@ -48,7 +48,7 @@
48
48
  // @ts-ignore
49
49
  import config from '@config'
50
50
  import { ref, computed } from 'vue'
51
- import { get } from 'lodash'
51
+ import { get } from 'lodash-es'
52
52
  import { getPCLocationInfo, removeEmpty } from '../../utils'
53
53
  import { useRouter } from 'vue-router'
54
54
  import type { Ref, ComputedRef } from 'vue'
@@ -91,8 +91,6 @@ export default {
91
91
  </script>
92
92
 
93
93
  <style scoped lang="less">
94
- @import '~@varlet/ui/es/styles/var';
95
-
96
94
  .fade-enter-active {
97
95
  animation-name: fade-in;
98
96
  animation-duration: 0.3s;
@@ -126,15 +124,19 @@ export default {
126
124
  }
127
125
 
128
126
  .varlet-site-header {
127
+ position: fixed;
128
+ top: 0;
129
+ left: 0;
129
130
  display: flex;
130
131
  align-items: center;
131
132
  color: #555;
133
+ width: 100%;
132
134
  height: 60px;
133
135
  padding: 0 30px;
134
136
  justify-content: space-between;
135
137
  user-select: none;
136
- position: relative;
137
- z-index: 2;
138
+ z-index: 996;
139
+ background: #fff;
138
140
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
139
141
  box-sizing: border-box;
140
142
 
@@ -202,13 +204,13 @@ export default {
202
204
  top: 40px;
203
205
  left: -20px;
204
206
 
205
- .var-cell {
207
+ .var-site-cell {
206
208
  width: 100px;
207
209
  }
208
210
 
209
211
  &--active {
210
- background: var(--site-color-pc-language-active-background);
211
- color: var(--site-color-pc-language-active);
212
+ background: var(--site-config-color-pc-language-active-background);
213
+ color: var(--site-config-color-pc-language-active);
212
214
  }
213
215
  }
214
216
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="varlet-site-mobile var-elevation--3">
2
+ <div class="varlet-site-mobile var-site-elevation--3">
3
3
  <div class="varlet-site-mobile-content">
4
4
  <iframe :src="`./mobile.html#/${componentName}?language=${language}&platform=pc&replace=${replace}`"></iframe>
5
5
  </div>
@@ -25,10 +25,10 @@ export default {
25
25
 
26
26
  <style scoped lang="less">
27
27
  .varlet-site-mobile {
28
+ position: sticky;
28
29
  flex: 0 0 325px;
29
- position: relative;
30
+ top: 80px;
30
31
  height: calc(100vh - 100px);
31
- align-self: center;
32
32
  margin-right: 38px;
33
33
  overflow: hidden;
34
34
  border-radius: 8px;