diff options
author | Li Jin <dragon-fly@qq.com> | 2021-04-19 23:41:33 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-04-19 23:41:33 +0800 |
commit | 5d3b07801456d16dcc2c75dcccd48d508a6b60cc (patch) | |
tree | 2df1a154bf58d93f2475df02afbd15f1a8ba2963 /doc/docs/.vuepress/theme/global-components | |
parent | ea82666506b57d6e905b7f2e5fe78498fe5a7abd (diff) | |
download | yuescript-5d3b07801456d16dcc2c75dcccd48d508a6b60cc.tar.gz yuescript-5d3b07801456d16dcc2c75dcccd48d508a6b60cc.tar.bz2 yuescript-5d3b07801456d16dcc2c75dcccd48d508a6b60cc.zip |
first commit for Yuescript document site.
Diffstat (limited to 'doc/docs/.vuepress/theme/global-components')
3 files changed, 205 insertions, 0 deletions
diff --git a/doc/docs/.vuepress/theme/global-components/Badge.vue b/doc/docs/.vuepress/theme/global-components/Badge.vue new file mode 100644 index 0000000..53951f9 --- /dev/null +++ b/doc/docs/.vuepress/theme/global-components/Badge.vue | |||
@@ -0,0 +1,44 @@ | |||
1 | <script> | ||
2 | export default { | ||
3 | functional: true, | ||
4 | props: { | ||
5 | type: { | ||
6 | type: String, | ||
7 | default: 'tip' | ||
8 | }, | ||
9 | text: String, | ||
10 | vertical: { | ||
11 | type: String, | ||
12 | default: 'top' | ||
13 | } | ||
14 | }, | ||
15 | render (h, { props, slots }) { | ||
16 | return h('span', { | ||
17 | class: ['badge', props.type], | ||
18 | style: { | ||
19 | verticalAlign: props.vertical | ||
20 | } | ||
21 | }, props.text || slots().default) | ||
22 | } | ||
23 | } | ||
24 | </script> | ||
25 | |||
26 | <style lang="stylus" scoped> | ||
27 | .badge | ||
28 | display inline-block | ||
29 | font-size 14px | ||
30 | height 18px | ||
31 | line-height 18px | ||
32 | border-radius 3px | ||
33 | padding 0 6px | ||
34 | color white | ||
35 | background-color #42b983 | ||
36 | &.tip, &.green | ||
37 | background-color $badgeTipColor | ||
38 | &.error | ||
39 | background-color $badgeErrorColor | ||
40 | &.warning, &.warn, &.yellow | ||
41 | background-color $badgeWarningColor | ||
42 | & + & | ||
43 | margin-left 5px | ||
44 | </style> | ||
diff --git a/doc/docs/.vuepress/theme/global-components/CodeBlock.vue b/doc/docs/.vuepress/theme/global-components/CodeBlock.vue new file mode 100644 index 0000000..d59d85b --- /dev/null +++ b/doc/docs/.vuepress/theme/global-components/CodeBlock.vue | |||
@@ -0,0 +1,41 @@ | |||
1 | <template> | ||
2 | <div | ||
3 | class="theme-code-block" | ||
4 | :class="{ 'theme-code-block__active': active }" | ||
5 | > | ||
6 | <slot /> | ||
7 | </div> | ||
8 | </template> | ||
9 | |||
10 | <script> | ||
11 | export default { | ||
12 | name: 'CodeBlock', | ||
13 | props: { | ||
14 | title: { | ||
15 | type: String, | ||
16 | required: true | ||
17 | }, | ||
18 | active: { | ||
19 | type: Boolean, | ||
20 | default: false | ||
21 | } | ||
22 | }, | ||
23 | mounted () { | ||
24 | if (this.$parent && this.$parent.loadTabs) { | ||
25 | this.$parent.loadTabs() | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | </script> | ||
30 | |||
31 | <style scoped> | ||
32 | .theme-code-block { | ||
33 | display: none; | ||
34 | } | ||
35 | .theme-code-block__active { | ||
36 | display: block; | ||
37 | } | ||
38 | .theme-code-block > pre { | ||
39 | background-color: orange; | ||
40 | } | ||
41 | </style> | ||
diff --git a/doc/docs/.vuepress/theme/global-components/CodeGroup.vue b/doc/docs/.vuepress/theme/global-components/CodeGroup.vue new file mode 100644 index 0000000..ac6ec55 --- /dev/null +++ b/doc/docs/.vuepress/theme/global-components/CodeGroup.vue | |||
@@ -0,0 +1,120 @@ | |||
1 | <template> | ||
2 | <ClientOnly> | ||
3 | <div class="theme-code-group"> | ||
4 | <div class="theme-code-group__nav"> | ||
5 | <ul class="theme-code-group__ul"> | ||
6 | <li | ||
7 | v-for="(tab, i) in codeTabs" | ||
8 | :key="tab.title" | ||
9 | class="theme-code-group__li" | ||
10 | > | ||
11 | <button | ||
12 | class="theme-code-group__nav-tab" | ||
13 | :class="{ | ||
14 | 'theme-code-group__nav-tab-active': i === activeCodeTabIndex, | ||
15 | }" | ||
16 | @click="changeCodeTab(i)" | ||
17 | > | ||
18 | {{ tab.title }} | ||
19 | </button> | ||
20 | </li> | ||
21 | </ul> | ||
22 | </div> | ||
23 | <slot /> | ||
24 | <pre | ||
25 | v-if="codeTabs.length < 1" | ||
26 | class="pre-blank" | ||
27 | >// Make sure to add code blocks to your code group</pre> | ||
28 | </div> | ||
29 | </ClientOnly> | ||
30 | </template> | ||
31 | |||
32 | <script> | ||
33 | export default { | ||
34 | name: 'CodeGroup', | ||
35 | data () { | ||
36 | return { | ||
37 | codeTabs: [], | ||
38 | activeCodeTabIndex: -1 | ||
39 | } | ||
40 | }, | ||
41 | watch: { | ||
42 | activeCodeTabIndex (index) { | ||
43 | this.activateCodeTab(index) | ||
44 | } | ||
45 | }, | ||
46 | mounted () { | ||
47 | this.loadTabs() | ||
48 | }, | ||
49 | methods: { | ||
50 | changeCodeTab (index) { | ||
51 | this.activeCodeTabIndex = index | ||
52 | }, | ||
53 | loadTabs () { | ||
54 | this.codeTabs = (this.$slots.default || []).filter(slot => Boolean(slot.componentOptions)).map((slot, index) => { | ||
55 | if (slot.componentOptions.propsData.active === '') { | ||
56 | this.activeCodeTabIndex = index | ||
57 | } | ||
58 | |||
59 | return { | ||
60 | title: slot.componentOptions.propsData.title, | ||
61 | elm: slot.elm | ||
62 | } | ||
63 | }) | ||
64 | |||
65 | if (this.activeCodeTabIndex === -1 && this.codeTabs.length > 0) { | ||
66 | this.activeCodeTabIndex = 0 | ||
67 | } | ||
68 | |||
69 | this.activateCodeTab(0) | ||
70 | }, | ||
71 | activateCodeTab (index) { | ||
72 | this.codeTabs.forEach(tab => { | ||
73 | if (tab.elm) { | ||
74 | tab.elm.classList.remove('theme-code-block__active') | ||
75 | } | ||
76 | }) | ||
77 | |||
78 | if (this.codeTabs[index].elm) { | ||
79 | this.codeTabs[index].elm.classList.add('theme-code-block__active') | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | </script> | ||
85 | |||
86 | <style lang="stylus" scoped> | ||
87 | .theme-code-group {} | ||
88 | .theme-code-group__nav { | ||
89 | margin-bottom: -35px; | ||
90 | background-color: $codeBgColor; | ||
91 | padding-bottom: 22px; | ||
92 | border-top-left-radius: 6px; | ||
93 | border-top-right-radius: 6px; | ||
94 | padding-left: 10px; | ||
95 | padding-top: 10px; | ||
96 | } | ||
97 | .theme-code-group__ul { | ||
98 | margin: auto 0; | ||
99 | padding-left: 0; | ||
100 | display: inline-flex; | ||
101 | list-style: none; | ||
102 | } | ||
103 | .theme-code-group__li {} | ||
104 | .theme-code-group__nav-tab { | ||
105 | border: 0; | ||
106 | padding: 5px; | ||
107 | cursor: pointer; | ||
108 | background-color: transparent; | ||
109 | font-size: 0.85em; | ||
110 | line-height: 1.4; | ||
111 | color: rgba(255, 255, 255, 0.9); | ||
112 | font-weight: 600; | ||
113 | } | ||
114 | .theme-code-group__nav-tab-active { | ||
115 | border-bottom: #42b983 1px solid; | ||
116 | } | ||
117 | .pre-blank { | ||
118 | color: #42b983; | ||
119 | } | ||
120 | </style> | ||