@frontfactory/vitepress-theme 1.4.2 → 1.5.1
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/README.md +12 -1
- package/config.d.ts +4 -4
- package/config.js +41 -18
- package/dist/style.css +1 -1919
- package/package.json +16 -7
- package/src/components/FfBackToTop.vue +37 -30
- package/src/components/FfBanner.vue +64 -50
- package/src/components/FfDocMeta.vue +107 -55
- package/src/components/FfFeature.vue +58 -26
- package/src/components/FfFooter.vue +97 -51
- package/src/components/FfHero.vue +168 -109
- package/src/components/FfHeroCommand.vue +66 -47
- package/src/components/FfHomeSponsors.vue +56 -0
- package/src/composables/options.ts +26 -15
- package/src/content/Api.vue +30 -13
- package/src/content/Card.vue +22 -16
- package/src/content/CardGrid.vue +9 -4
- package/src/content/Kbd.vue +1 -1
- package/src/content/Steps.vue +3 -3
- package/src/index.ts +25 -23
- package/src/internal.ts +5 -4
- package/src/layout/FfLayout.vue +45 -34
- package/src/styles/_blocks.scss +1 -0
- package/src/styles/_code.scss +1 -0
- package/src/styles/_content.scss +8 -2
- package/src/styles/_doc.scss +7 -6
- package/src/styles/_home.scss +166 -10
- package/src/styles/_motion.scss +1 -0
- package/src/styles/_nav.scss +5 -3
- package/src/styles/_sidebar.scss +1 -0
- package/src/styles/_tokens.scss +15 -26
- package/src/types.ts +6 -2
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import { useData } from 'vitepress'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { useData } from 'vitepress';
|
|
4
|
+
import {
|
|
5
|
+
useLayout, VPIcon, VPLink
|
|
6
|
+
} from '../internal';
|
|
7
|
+
import { useLabels, useThemeOptions } from '../composables/options';
|
|
8
|
+
import type { DefaultTheme } from '../types';
|
|
7
9
|
|
|
8
|
-
const { theme, frontmatter } = useData()
|
|
9
|
-
const { hasSidebar } = useLayout()
|
|
10
|
-
const options = useThemeOptions()
|
|
11
|
-
const labels = useLabels()
|
|
10
|
+
const { theme, frontmatter } = useData();
|
|
11
|
+
const { hasSidebar } = useLayout();
|
|
12
|
+
const options = useThemeOptions();
|
|
13
|
+
const labels = useLabels();
|
|
12
14
|
|
|
13
|
-
const columns = computed(() => options.value.footerColumns ?? [])
|
|
15
|
+
const columns = computed(() => options.value.footerColumns ?? []);
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* `themeConfig.socialLinks`, printed as a normal footer column: one row per network, its logo
|
|
17
19
|
* beside a readable name. The name is the entry's `ariaLabel`, or the icon slug it defaults to.
|
|
18
20
|
*/
|
|
19
21
|
const social = computed(() => {
|
|
20
|
-
if (options.value.footerSocial === false)
|
|
22
|
+
if (options.value.footerSocial === false) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
21
25
|
|
|
22
26
|
return ((theme.value.socialLinks ?? []) as DefaultTheme.SocialLink[]).map((link) => ({
|
|
23
27
|
...link,
|
|
@@ -26,56 +30,98 @@ const social = computed(() => {
|
|
|
26
30
|
? `simple-icons:${link.icon}`
|
|
27
31
|
: link.icon,
|
|
28
32
|
text: link.ariaLabel ?? (typeof link.icon === 'string' ? link.icon : '')
|
|
29
|
-
}))
|
|
30
|
-
})
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
31
35
|
|
|
32
36
|
const visible = computed(
|
|
33
37
|
() =>
|
|
34
38
|
(theme.value.footer || columns.value.length || social.value.length) &&
|
|
35
39
|
frontmatter.value.footer !== false
|
|
36
|
-
)
|
|
40
|
+
);
|
|
37
41
|
</script>
|
|
38
42
|
|
|
39
43
|
<template>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
<footer
|
|
45
|
+
v-if="visible"
|
|
46
|
+
class="VPFooter ff-footer"
|
|
47
|
+
:class="{ 'has-sidebar': hasSidebar }"
|
|
48
|
+
>
|
|
49
|
+
<div class="ff-footer-container">
|
|
50
|
+
<div
|
|
51
|
+
v-if="columns.length || social.length"
|
|
52
|
+
class="ff-footer-top"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
v-if="columns.length"
|
|
56
|
+
class="ff-footer-columns"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
v-for="column in columns"
|
|
60
|
+
:key="column.title"
|
|
61
|
+
class="ff-footer-column"
|
|
62
|
+
>
|
|
63
|
+
<p class="ff-label">
|
|
64
|
+
{{ column.title }}
|
|
65
|
+
</p>
|
|
46
66
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
<ul>
|
|
68
|
+
<li
|
|
69
|
+
v-for="item in column.items"
|
|
70
|
+
:key="item.link"
|
|
71
|
+
>
|
|
72
|
+
<VPLink
|
|
73
|
+
:href="item.link"
|
|
74
|
+
:rel="item.rel"
|
|
75
|
+
:target="item.target"
|
|
76
|
+
>
|
|
77
|
+
{{ item.text }}
|
|
78
|
+
</VPLink>
|
|
79
|
+
</li>
|
|
80
|
+
</ul>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<VPIcon :icon="item.icon" />
|
|
68
|
-
<span>{{ item.text }}</span>
|
|
69
|
-
</a>
|
|
70
|
-
</li>
|
|
71
|
-
</ul>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
84
|
+
<div
|
|
85
|
+
v-if="social.length"
|
|
86
|
+
class="ff-footer-column ff-footer-social"
|
|
87
|
+
>
|
|
88
|
+
<p class="ff-label">
|
|
89
|
+
{{ labels.footerSocial }}
|
|
90
|
+
</p>
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
<ul>
|
|
93
|
+
<li
|
|
94
|
+
v-for="item in social"
|
|
95
|
+
:key="item.link"
|
|
96
|
+
>
|
|
97
|
+
<a
|
|
98
|
+
:href="item.link"
|
|
99
|
+
:target="item.target ?? '_blank'"
|
|
100
|
+
rel="me noopener"
|
|
101
|
+
>
|
|
102
|
+
<VPIcon :icon="item.icon" />
|
|
103
|
+
<span>{{ item.text }}</span>
|
|
104
|
+
</a>
|
|
105
|
+
</li>
|
|
106
|
+
</ul>
|
|
79
107
|
</div>
|
|
80
|
-
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div
|
|
111
|
+
v-if="theme.footer"
|
|
112
|
+
class="ff-footer-legal"
|
|
113
|
+
>
|
|
114
|
+
<p
|
|
115
|
+
v-if="theme.footer.message"
|
|
116
|
+
class="message"
|
|
117
|
+
v-html="theme.footer.message"
|
|
118
|
+
/>
|
|
119
|
+
<p
|
|
120
|
+
v-if="theme.footer.copyright"
|
|
121
|
+
class="copyright"
|
|
122
|
+
v-html="theme.footer.copyright"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</footer>
|
|
81
127
|
</template>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
Comment, computed, Fragment, Text, useSlots, type VNode
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import { useData } from 'vitepress';
|
|
6
|
+
import { VPImage } from '../internal';
|
|
7
|
+
import FfHeroCommand from './FfHeroCommand.vue';
|
|
8
|
+
import type { HeroExtras, HeroMetaItem } from '../types';
|
|
9
|
+
import type { DefaultTheme } from 'vitepress/theme';
|
|
8
10
|
|
|
9
11
|
export interface HeroAction {
|
|
10
12
|
theme?: 'brand' | 'alt'
|
|
@@ -20,10 +22,10 @@ const props = defineProps<{
|
|
|
20
22
|
tagline?: string
|
|
21
23
|
image?: DefaultTheme.ThemeableImage
|
|
22
24
|
actions?: HeroAction[]
|
|
23
|
-
}>()
|
|
25
|
+
}>();
|
|
24
26
|
|
|
25
|
-
const { frontmatter } = useData()
|
|
26
|
-
const slots = useSlots()
|
|
27
|
+
const { frontmatter } = useData();
|
|
28
|
+
const slots = useSlots();
|
|
27
29
|
|
|
28
30
|
// Three additions to the standard home frontmatter, all optional:
|
|
29
31
|
//
|
|
@@ -31,12 +33,12 @@ const slots = useSlots()
|
|
|
31
33
|
// hero.quote a short line ruled like a markdown blockquote — under the tagline normally, or
|
|
32
34
|
// under the install line instead once one sits inline beneath it (see hasInlineCommand)
|
|
33
35
|
// hero.meta a colophon strip under the hero: [{ label, value }, …]
|
|
34
|
-
const hero = computed<HeroExtras>(() => frontmatter.value.hero ?? {})
|
|
35
|
-
const command = computed<HeroExtras['command']>(() => hero.value.command)
|
|
36
|
-
const hasCommand = computed(() => (Array.isArray(command.value) ? command.value.length > 0 : !!command.value))
|
|
37
|
-
const hasActions = computed(() => !!props.actions?.length)
|
|
38
|
-
const quote = computed<string | undefined>(() => hero.value.quote)
|
|
39
|
-
const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? [])
|
|
36
|
+
const hero = computed<HeroExtras>(() => frontmatter.value.hero ?? {});
|
|
37
|
+
const command = computed<HeroExtras['command']>(() => hero.value.command);
|
|
38
|
+
const hasCommand = computed(() => (Array.isArray(command.value) ? command.value.length > 0 : !!command.value));
|
|
39
|
+
const hasActions = computed(() => !!props.actions?.length);
|
|
40
|
+
const quote = computed<string | undefined>(() => hero.value.quote);
|
|
41
|
+
const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? []);
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* The home layout always declares the `home-hero-image` slot, so its presence says nothing about
|
|
@@ -45,123 +47,180 @@ const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? [])
|
|
|
45
47
|
*/
|
|
46
48
|
function filled(nodes?: VNode[]): boolean {
|
|
47
49
|
return !!nodes?.some((node) => {
|
|
48
|
-
if (node.type === Comment)
|
|
49
|
-
|
|
50
|
+
if (node.type === Comment) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (node.type === Text) {
|
|
55
|
+
return String(node.children).trim() !== '';
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
if (node.type === Fragment) {
|
|
51
|
-
return Array.isArray(node.children) && filled(node.children as VNode[])
|
|
59
|
+
return Array.isArray(node.children) && filled(node.children as VNode[]);
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
return true
|
|
55
|
-
})
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
// Called from the template rather than cached in a computed: the slot has to be rendered where its
|
|
59
67
|
// dependencies are tracked, and it changes with the page.
|
|
60
68
|
function hasImage() {
|
|
61
|
-
return !!props.image || filled(slots['home-hero-image']?.())
|
|
69
|
+
return !!props.image || filled(slots['home-hero-image']?.());
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
// The second column carries the image when there is one, and the starting point otherwise. The
|
|
65
73
|
// actions only move over there when they have a panel to sit in.
|
|
66
74
|
function hasPanel() {
|
|
67
|
-
return !hasImage() && hasCommand.value
|
|
75
|
+
return !hasImage() && hasCommand.value;
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
// An image claims the second column, so the install panel has nowhere to sit beside the text —
|
|
71
79
|
// it drops under it instead rather than disappearing.
|
|
72
80
|
function hasInlineCommand() {
|
|
73
|
-
return hasImage() && hasCommand.value
|
|
81
|
+
return hasImage() && hasCommand.value;
|
|
74
82
|
}
|
|
75
83
|
</script>
|
|
76
84
|
|
|
77
85
|
<template>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<FfHeroCommand :command="command!" :bare="!hasActions" />
|
|
141
|
-
|
|
142
|
-
<div v-if="hasActions" class="ff-hero-actions">
|
|
143
|
-
<slot name="home-hero-actions-before-actions" />
|
|
144
|
-
|
|
145
|
-
<a
|
|
146
|
-
v-for="action in actions"
|
|
147
|
-
:key="action.link"
|
|
148
|
-
class="ff-btn"
|
|
149
|
-
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
150
|
-
:href="action.link"
|
|
151
|
-
:target="action.target"
|
|
152
|
-
:rel="action.rel"
|
|
153
|
-
>
|
|
154
|
-
{{ action.text }}
|
|
155
|
-
</a>
|
|
156
|
-
</div>
|
|
157
|
-
</aside>
|
|
86
|
+
<div
|
|
87
|
+
class="VPHero ff-hero"
|
|
88
|
+
:class="{ 'has-image': hasImage(), 'has-panel': hasPanel() }"
|
|
89
|
+
>
|
|
90
|
+
<span
|
|
91
|
+
class="ff-hero-glow"
|
|
92
|
+
aria-hidden="true"
|
|
93
|
+
/>
|
|
94
|
+
<span
|
|
95
|
+
class="ff-hero-glow ff-hero-glow-far"
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
/>
|
|
98
|
+
|
|
99
|
+
<div class="ff-hero-container">
|
|
100
|
+
<div class="ff-hero-main">
|
|
101
|
+
<slot name="home-hero-info-before" />
|
|
102
|
+
|
|
103
|
+
<slot name="home-hero-info">
|
|
104
|
+
<p
|
|
105
|
+
v-if="name"
|
|
106
|
+
class="ff-hero-kicker ff-label"
|
|
107
|
+
v-html="name"
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<h1
|
|
111
|
+
v-if="text"
|
|
112
|
+
class="ff-hero-title ff-display"
|
|
113
|
+
v-html="text"
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
<p
|
|
117
|
+
v-if="tagline"
|
|
118
|
+
class="ff-hero-tagline"
|
|
119
|
+
v-html="tagline"
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
<blockquote
|
|
123
|
+
v-if="quote && !hasInlineCommand()"
|
|
124
|
+
class="ff-hero-quote"
|
|
125
|
+
v-html="quote"
|
|
126
|
+
/>
|
|
127
|
+
</slot>
|
|
128
|
+
|
|
129
|
+
<slot name="home-hero-info-after" />
|
|
130
|
+
|
|
131
|
+
<div
|
|
132
|
+
v-if="hasActions && !hasPanel()"
|
|
133
|
+
class="ff-hero-actions"
|
|
134
|
+
>
|
|
135
|
+
<slot name="home-hero-actions-before-actions" />
|
|
136
|
+
|
|
137
|
+
<a
|
|
138
|
+
v-for="action in actions"
|
|
139
|
+
:key="action.link"
|
|
140
|
+
class="ff-btn"
|
|
141
|
+
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
142
|
+
:href="action.link"
|
|
143
|
+
:target="action.target"
|
|
144
|
+
:rel="action.rel"
|
|
145
|
+
>
|
|
146
|
+
{{ action.text }}
|
|
147
|
+
</a>
|
|
158
148
|
</div>
|
|
159
149
|
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
150
|
+
<slot name="home-hero-actions-after" />
|
|
151
|
+
|
|
152
|
+
<FfHeroCommand
|
|
153
|
+
v-if="hasInlineCommand()"
|
|
154
|
+
:command="command!"
|
|
155
|
+
bare
|
|
156
|
+
class="ff-hero-panel ff-hero-panel-inline ff-hero-panel-bare"
|
|
157
|
+
/>
|
|
158
|
+
|
|
159
|
+
<blockquote
|
|
160
|
+
v-if="quote && hasInlineCommand()"
|
|
161
|
+
class="ff-hero-quote"
|
|
162
|
+
v-html="quote"
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div
|
|
167
|
+
v-if="hasImage()"
|
|
168
|
+
class="ff-hero-image"
|
|
169
|
+
>
|
|
170
|
+
<slot name="home-hero-image">
|
|
171
|
+
<VPImage
|
|
172
|
+
v-if="image"
|
|
173
|
+
class="ff-hero-image-src"
|
|
174
|
+
:image="image"
|
|
175
|
+
/>
|
|
176
|
+
</slot>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<aside
|
|
180
|
+
v-else-if="hasPanel()"
|
|
181
|
+
class="ff-hero-panel"
|
|
182
|
+
:class="{ 'ff-hero-panel-bare': !hasActions }"
|
|
183
|
+
>
|
|
184
|
+
<FfHeroCommand
|
|
185
|
+
:command="command!"
|
|
186
|
+
:bare="!hasActions"
|
|
187
|
+
/>
|
|
188
|
+
|
|
189
|
+
<div
|
|
190
|
+
v-if="hasActions"
|
|
191
|
+
class="ff-hero-actions"
|
|
192
|
+
>
|
|
193
|
+
<slot name="home-hero-actions-before-actions" />
|
|
194
|
+
|
|
195
|
+
<a
|
|
196
|
+
v-for="action in actions"
|
|
197
|
+
:key="action.link"
|
|
198
|
+
class="ff-btn"
|
|
199
|
+
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
200
|
+
:href="action.link"
|
|
201
|
+
:target="action.target"
|
|
202
|
+
:rel="action.rel"
|
|
203
|
+
>
|
|
204
|
+
{{ action.text }}
|
|
205
|
+
</a>
|
|
206
|
+
</div>
|
|
207
|
+
</aside>
|
|
166
208
|
</div>
|
|
209
|
+
|
|
210
|
+
<dl
|
|
211
|
+
v-if="meta.length"
|
|
212
|
+
class="ff-hero-meta"
|
|
213
|
+
>
|
|
214
|
+
<div
|
|
215
|
+
v-for="item in meta"
|
|
216
|
+
:key="item.label"
|
|
217
|
+
class="ff-hero-meta-item"
|
|
218
|
+
>
|
|
219
|
+
<dt class="ff-label">
|
|
220
|
+
{{ item.label }}
|
|
221
|
+
</dt>
|
|
222
|
+
<dd>{{ item.value }}</dd>
|
|
223
|
+
</div>
|
|
224
|
+
</dl>
|
|
225
|
+
</div>
|
|
167
226
|
</template>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, ref, watch
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import { format, useLabels } from '../composables/options';
|
|
6
|
+
import type { HeroCommandTab } from '../types';
|
|
5
7
|
|
|
6
8
|
// Used from both hero panel positions (inline and beside the headline, see FfHero), which are
|
|
7
9
|
// mutually exclusive — so the active tab lives here rather than being lifted to the parent.
|
|
@@ -9,73 +11,90 @@ const props = defineProps<{
|
|
|
9
11
|
command: string | HeroCommandTab[]
|
|
10
12
|
/** No actions sit under this command — print the bare line, without the "Install" heading. */
|
|
11
13
|
bare?: boolean
|
|
12
|
-
}>()
|
|
14
|
+
}>();
|
|
13
15
|
|
|
14
|
-
const labels = useLabels()
|
|
16
|
+
const labels = useLabels();
|
|
15
17
|
|
|
16
18
|
const tabs = computed<HeroCommandTab[] | undefined>(() =>
|
|
17
19
|
Array.isArray(props.command) ? props.command : undefined
|
|
18
|
-
)
|
|
20
|
+
);
|
|
19
21
|
|
|
20
|
-
const activeTab = ref(0)
|
|
22
|
+
const activeTab = ref(0);
|
|
21
23
|
|
|
22
24
|
// Client-side navigation can swap the tabs a shorter or longer array without remounting this
|
|
23
25
|
// component (two home pages in the same site), so the index is reset rather than left pointing
|
|
24
26
|
// past the end.
|
|
25
|
-
watch(tabs, () => (activeTab.value = 0))
|
|
27
|
+
watch(tabs, () => (activeTab.value = 0));
|
|
26
28
|
|
|
27
29
|
const activeCommand = computed<string>(() =>
|
|
28
30
|
tabs.value ? (tabs.value[activeTab.value]?.value ?? '') : (props.command as string)
|
|
29
|
-
)
|
|
31
|
+
);
|
|
30
32
|
|
|
31
|
-
const copied = ref(false)
|
|
33
|
+
const copied = ref(false);
|
|
32
34
|
|
|
33
35
|
async function copy() {
|
|
34
|
-
if (!activeCommand.value)
|
|
36
|
+
if (!activeCommand.value) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
|
-
await navigator.clipboard.writeText(activeCommand.value)
|
|
37
|
-
copied.value = true
|
|
38
|
-
setTimeout(() => (copied.value = false), 2000)
|
|
40
|
+
await navigator.clipboard.writeText(activeCommand.value);
|
|
41
|
+
copied.value = true;
|
|
42
|
+
setTimeout(() => (copied.value = false), 2000);
|
|
39
43
|
}
|
|
40
44
|
</script>
|
|
41
45
|
|
|
42
46
|
<template>
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
<div class="ff-hero-command-panel">
|
|
48
|
+
<p
|
|
49
|
+
v-if="!bare"
|
|
50
|
+
class="ff-hero-panel-label ff-label"
|
|
51
|
+
>
|
|
52
|
+
{{ labels.heroInstall }}
|
|
53
|
+
</p>
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
<div
|
|
56
|
+
v-if="tabs"
|
|
57
|
+
class="ff-hero-command-tabs"
|
|
58
|
+
role="tablist"
|
|
59
|
+
>
|
|
60
|
+
<button
|
|
61
|
+
v-for="(tab, index) in tabs"
|
|
62
|
+
:key="tab.label"
|
|
63
|
+
type="button"
|
|
64
|
+
role="tab"
|
|
65
|
+
class="ff-hero-command-tab"
|
|
66
|
+
:class="{ active: index === activeTab }"
|
|
67
|
+
:aria-selected="index === activeTab"
|
|
68
|
+
@click="activeTab = index"
|
|
69
|
+
>
|
|
70
|
+
{{ tab.label }}
|
|
71
|
+
</button>
|
|
72
|
+
</div>
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
<div class="ff-hero-command">
|
|
75
|
+
<code>
|
|
76
|
+
<span
|
|
77
|
+
class="ff-hero-prompt"
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
>$</span>
|
|
80
|
+
{{ activeCommand }}
|
|
81
|
+
</code>
|
|
66
82
|
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
<span class="ff-hero-copy-group">
|
|
84
|
+
<span
|
|
85
|
+
v-if="copied"
|
|
86
|
+
class="ff-hero-copied ff-label"
|
|
87
|
+
>{{ labels.heroCopied }}</span>
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</div>
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
class="ff-hero-copy"
|
|
92
|
+
:class="{ copied }"
|
|
93
|
+
:title="format(labels.heroCopyLabel, activeCommand)"
|
|
94
|
+
:aria-label="format(labels.heroCopyLabel, activeCommand)"
|
|
95
|
+
@click="copy"
|
|
96
|
+
/>
|
|
97
|
+
</span>
|
|
80
98
|
</div>
|
|
99
|
+
</div>
|
|
81
100
|
</template>
|