@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.
@@ -0,0 +1,56 @@
1
+ <script setup lang="ts">
2
+ import { VPSponsors } from '../internal';
3
+ import { useLabels } from '../composables/options';
4
+
5
+ export interface SponsorItem {
6
+ name: string
7
+ img: string
8
+ url: string
9
+ }
10
+
11
+ export interface SponsorTier {
12
+ tier?: string
13
+ size?: 'xmini' | 'mini' | 'small' | 'medium' | 'big'
14
+ items: SponsorItem[]
15
+ }
16
+
17
+ defineProps<{
18
+ message?: string
19
+ actionText?: string
20
+ actionLink?: string
21
+ data: SponsorTier[] | SponsorItem[]
22
+ }>();
23
+
24
+ const labels = useLabels();
25
+ </script>
26
+
27
+ <template>
28
+ <section class="VPHomeSponsors ff-sponsors">
29
+ <div class="ff-sponsors-container">
30
+ <h2 class="ff-sponsors-title ff-display">
31
+ {{ labels.sponsors }}
32
+ </h2>
33
+ <p
34
+ v-if="message"
35
+ class="ff-sponsors-message"
36
+ >
37
+ {{ message }}
38
+ </p>
39
+
40
+ <VPSponsors
41
+ class="ff-sponsors-grid"
42
+ :data="data"
43
+ />
44
+
45
+ <div
46
+ v-if="actionLink"
47
+ class="ff-sponsors-action"
48
+ >
49
+ <a
50
+ class="ff-btn ff-btn-alt no-icon"
51
+ :href="actionLink"
52
+ >{{ actionText ?? labels.sponsorsAction }}</a>
53
+ </div>
54
+ </div>
55
+ </section>
56
+ </template>
@@ -1,15 +1,17 @@
1
- import { computed } from 'vue'
2
- import { useData } from 'vitepress'
3
- import type { ThemeConfig, ThemeLabels, ThemeOptions } from '../types'
1
+ import { computed } from 'vue';
2
+ import { useData } from 'vitepress';
3
+ import type {
4
+ ThemeConfig, ThemeLabels, ThemeOptions
5
+ } from '../types';
4
6
 
5
7
  /**
6
8
  * Theme options declared under `themeConfig.ff`, with an empty object as a fallback so callers
7
9
  * never have to guard.
8
10
  */
9
11
  export function useThemeOptions() {
10
- const { theme } = useData()
12
+ const { theme } = useData();
11
13
 
12
- return computed<ThemeOptions>(() => (theme.value as ThemeConfig).ff ?? {})
14
+ return computed<ThemeOptions>(() => (theme.value as ThemeConfig).ff ?? {});
13
15
  }
14
16
 
15
17
  /** English fallbacks for every string this theme adds. */
@@ -22,28 +24,37 @@ export const defaultLabels: Required<ThemeLabels> = {
22
24
  heroCopied: 'Copied',
23
25
  heroCopyLabel: 'Copy {0}',
24
26
  backToTop: 'Top',
25
- footerSocial: 'Follow'
26
- }
27
+ footerSocial: 'Follow',
28
+ sponsors: 'Sponsors',
29
+ sponsorsAction: 'Become a sponsor'
30
+ };
27
31
 
28
32
  /**
29
33
  * Labels for the current locale. VitePress merges `themeConfig` per locale before it reaches the
30
34
  * client, so a site translates the theme by declaring `ff.labels` under each locale.
31
35
  */
32
36
  export function useLabels() {
33
- const options = useThemeOptions()
37
+ const options = useThemeOptions();
34
38
 
35
39
  return computed<Required<ThemeLabels>>(() => {
36
- const labels = { ...defaultLabels }
37
-
38
- for (const [key, value] of Object.entries(options.value.labels ?? {})) {
39
- if (value) labels[key as keyof ThemeLabels] = value
40
+ const labels = {
41
+ ...defaultLabels
42
+ };
43
+
44
+ for (const [
45
+ key,
46
+ value
47
+ ] of Object.entries(options.value.labels ?? {})) {
48
+ if (value) {
49
+ labels[key as keyof ThemeLabels] = value;
50
+ }
40
51
  }
41
52
 
42
- return labels
43
- })
53
+ return labels;
54
+ });
44
55
  }
45
56
 
46
57
  /** Fills the `{0}` placeholder of a label. */
47
58
  export function format(label: string, value: string | number) {
48
- return label.replace('{0}', String(value))
59
+ return label.replace('{0}', String(value));
49
60
  }
@@ -10,23 +10,40 @@ defineProps<{
10
10
  since?: string
11
11
  /** Marks the symbol as deprecated. */
12
12
  deprecated?: boolean
13
- }>()
13
+ }>();
14
14
  </script>
15
15
 
16
16
  <template>
17
- <section class="ff-api" :class="{ 'is-deprecated': deprecated }">
18
- <header class="ff-api-head">
19
- <code class="ff-api-name">{{ name }}</code>
17
+ <section
18
+ class="ff-api"
19
+ :class="{ 'is-deprecated': deprecated }"
20
+ >
21
+ <header class="ff-api-head">
22
+ <code class="ff-api-name">{{ name }}</code>
20
23
 
21
- <span v-if="kind" class="ff-api-kind ff-label">{{ kind }}</span>
22
- <span v-if="since" class="ff-api-tag ff-label">since {{ since }}</span>
23
- <span v-if="deprecated" class="ff-api-tag ff-api-deprecated ff-label">deprecated</span>
24
- </header>
24
+ <span
25
+ v-if="kind"
26
+ class="ff-api-kind ff-label"
27
+ >{{ kind }}</span>
28
+ <span
29
+ v-if="since"
30
+ class="ff-api-tag ff-label"
31
+ >since {{ since }}</span>
32
+ <span
33
+ v-if="deprecated"
34
+ class="ff-api-tag ff-api-deprecated ff-label"
35
+ >deprecated</span>
36
+ </header>
25
37
 
26
- <p v-if="signature" class="ff-api-signature"><code>{{ signature }}</code></p>
38
+ <p
39
+ v-if="signature"
40
+ class="ff-api-signature"
41
+ >
42
+ <code>{{ signature }}</code>
43
+ </p>
27
44
 
28
- <div class="ff-api-body">
29
- <slot />
30
- </div>
31
- </section>
45
+ <div class="ff-api-body">
46
+ <slot />
47
+ </div>
48
+ </section>
32
49
  </template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { VPLink } from '../internal'
2
+ import { VPLink } from '../internal';
3
3
 
4
4
  defineProps<{
5
5
  title: string
@@ -8,24 +8,30 @@ defineProps<{
8
8
  link?: string
9
9
  rel?: string
10
10
  target?: string
11
- }>()
11
+ }>();
12
12
  </script>
13
13
 
14
14
  <template>
15
- <VPLink
16
- class="ff-card"
17
- :href="link"
18
- :rel="rel"
19
- :target="target"
20
- :no-icon="true"
21
- :tag="link ? 'a' : 'div'"
22
- >
23
- <span v-if="icon" class="ff-card-icon" v-html="icon" />
15
+ <VPLink
16
+ class="ff-card"
17
+ :href="link"
18
+ :rel="rel"
19
+ :target="target"
20
+ :no-icon="true"
21
+ :tag="link ? 'a' : 'div'"
22
+ >
23
+ <span
24
+ v-if="icon"
25
+ class="ff-card-icon"
26
+ v-html="icon"
27
+ />
24
28
 
25
- <p class="ff-card-title">{{ title }}</p>
29
+ <p class="ff-card-title">
30
+ {{ title }}
31
+ </p>
26
32
 
27
- <div class="ff-card-body">
28
- <slot />
29
- </div>
30
- </VPLink>
33
+ <div class="ff-card-body">
34
+ <slot />
35
+ </div>
36
+ </VPLink>
31
37
  </template>
@@ -1,9 +1,14 @@
1
1
  <script setup lang="ts">
2
- withDefaults(defineProps<{ columns?: number | string }>(), { columns: 2 })
2
+ withDefaults(defineProps<{ columns?: number | string }>(), {
3
+ columns: 2
4
+ });
3
5
  </script>
4
6
 
5
7
  <template>
6
- <div class="ff-card-grid" :style="{ '--ff-card-columns': columns }">
7
- <slot />
8
- </div>
8
+ <div
9
+ class="ff-card-grid"
10
+ :style="{ '--ff-card-columns': columns }"
11
+ >
12
+ <slot />
13
+ </div>
9
14
  </template>
@@ -1,3 +1,3 @@
1
1
  <template>
2
- <kbd class="ff-kbd"><slot /></kbd>
2
+ <kbd class="ff-kbd"><slot /></kbd>
3
3
  </template>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="ff-steps">
3
- <slot />
4
- </div>
2
+ <div class="ff-steps">
3
+ <slot />
4
+ </div>
5
5
  </template>
package/src/index.ts CHANGED
@@ -1,14 +1,14 @@
1
- import type { Theme } from 'vitepress'
2
- import DefaultTheme from 'vitepress/theme'
1
+ import type { Theme } from 'vitepress';
2
+ import DefaultTheme from 'vitepress/theme';
3
3
 
4
- import FfLayout from './layout/FfLayout.vue'
5
- import Api from './content/Api.vue'
6
- import Card from './content/Card.vue'
7
- import CardGrid from './content/CardGrid.vue'
8
- import Kbd from './content/Kbd.vue'
9
- import Steps from './content/Steps.vue'
4
+ import FfLayout from './layout/FfLayout.vue';
5
+ import Api from './content/Api.vue';
6
+ import Card from './content/Card.vue';
7
+ import CardGrid from './content/CardGrid.vue';
8
+ import Kbd from './content/Kbd.vue';
9
+ import Steps from './content/Steps.vue';
10
10
 
11
- import '../dist/style.css'
11
+ import '../dist/style.css';
12
12
 
13
13
  /**
14
14
  * Editorial VitePress theme.
@@ -21,23 +21,25 @@ const theme: Theme = {
21
21
  extends: DefaultTheme,
22
22
  Layout: FfLayout,
23
23
  enhanceApp({ app }) {
24
- app.component('Api', Api)
25
- app.component('Card', Card)
26
- app.component('CardGrid', CardGrid)
27
- app.component('Kbd', Kbd)
28
- app.component('Steps', Steps)
24
+ app.component('Api', Api);
25
+ app.component('Card', Card);
26
+ app.component('CardGrid', CardGrid);
27
+ app.component('Kbd', Kbd);
28
+ app.component('Steps', Steps);
29
29
  }
30
- }
30
+ };
31
31
 
32
- export default theme
32
+ export default theme;
33
33
 
34
- export { default as Api } from './content/Api.vue'
35
- export { default as Card } from './content/Card.vue'
36
- export { default as CardGrid } from './content/CardGrid.vue'
37
- export { default as Kbd } from './content/Kbd.vue'
38
- export { default as Steps } from './content/Steps.vue'
34
+ export { default as Api } from './content/Api.vue';
35
+ export { default as Card } from './content/Card.vue';
36
+ export { default as CardGrid } from './content/CardGrid.vue';
37
+ export { default as Kbd } from './content/Kbd.vue';
38
+ export { default as Steps } from './content/Steps.vue';
39
39
 
40
- export { defaultLabels, useLabels, useThemeOptions } from './composables/options'
40
+ export {
41
+ defaultLabels, useLabels, useThemeOptions
42
+ } from './composables/options';
41
43
 
42
44
  export type {
43
45
  BannerConfig,
@@ -50,4 +52,4 @@ export type {
50
52
  ThemeConfig,
51
53
  ThemeLabels,
52
54
  ThemeOptions
53
- } from './types'
55
+ } from './types';
package/src/internal.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  // alias would otherwise import the theme index that imports them back. Nothing here reaches for an
6
6
  // API the default theme does not export.
7
7
 
8
- export { default as VPIcon } from 'vitepress/dist/client/theme-default/components/VPIcon.vue'
9
- export { default as VPImage } from 'vitepress/dist/client/theme-default/components/VPImage.vue'
10
- export { default as VPLink } from 'vitepress/dist/client/theme-default/components/VPLink.vue'
11
- export { useLayout } from 'vitepress/dist/client/theme-default/composables/layout.js'
8
+ export { default as VPIcon } from 'vitepress/dist/client/theme-default/components/VPIcon.vue';
9
+ export { default as VPImage } from 'vitepress/dist/client/theme-default/components/VPImage.vue';
10
+ export { default as VPLink } from 'vitepress/dist/client/theme-default/components/VPLink.vue';
11
+ export { default as VPSponsors } from 'vitepress/dist/client/theme-default/components/VPSponsors.vue';
12
+ export { useLayout } from 'vitepress/dist/client/theme-default/composables/layout.js';
@@ -1,47 +1,58 @@
1
1
  <script setup lang="ts">
2
- import { computed, useSlots } from 'vue'
3
- import DefaultTheme from 'vitepress/theme'
4
- import FfBackToTop from '../components/FfBackToTop.vue'
5
- import FfBanner from '../components/FfBanner.vue'
6
- import FfDocMeta from '../components/FfDocMeta.vue'
7
- import { useThemeOptions } from '../composables/options'
2
+ import { computed, useSlots } from 'vue';
3
+ import DefaultTheme from 'vitepress/theme';
4
+ import FfBackToTop from '../components/FfBackToTop.vue';
5
+ import FfBanner from '../components/FfBanner.vue';
6
+ import FfDocMeta from '../components/FfDocMeta.vue';
7
+ import { useThemeOptions } from '../composables/options';
8
8
 
9
- const { Layout } = DefaultTheme
10
- const options = useThemeOptions()
9
+ const { Layout } = DefaultTheme;
10
+ const options = useThemeOptions();
11
11
 
12
12
  // Three slots carry the additions of this theme; every other slot the site passes in is forwarded
13
13
  // untouched, so the whole default slot surface keeps working.
14
- const owned = ['layout-top', 'doc-before', 'layout-bottom']
14
+ const owned = [
15
+ 'layout-top',
16
+ 'doc-before',
17
+ 'layout-bottom'
18
+ ];
15
19
 
16
- const slots = useSlots()
17
- const forwarded = computed(() => Object.keys(slots).filter((name) => !owned.includes(name)))
20
+ const slots = useSlots();
21
+ const forwarded = computed(() => Object.keys(slots).filter((name) => !owned.includes(name)));
18
22
  </script>
19
23
 
20
24
  <template>
21
- <div
22
- class="ff-theme"
23
- :data-nav-order="options.navOrder ?? 'search-first'"
24
- :data-nav-sticky="options.navSticky === false ? 'false' : 'true'"
25
- >
26
- <Layout>
27
- <template #layout-top>
28
- <FfBanner />
29
- <slot name="layout-top" />
30
- </template>
25
+ <div
26
+ class="ff-theme"
27
+ :data-nav-order="options.navOrder ?? 'search-first'"
28
+ :data-nav-sticky="options.navSticky === false ? 'false' : 'true'"
29
+ >
30
+ <Layout>
31
+ <template #layout-top>
32
+ <FfBanner />
33
+ <slot name="layout-top" />
34
+ </template>
31
35
 
32
- <template #doc-before>
33
- <FfDocMeta />
34
- <slot name="doc-before" />
35
- </template>
36
+ <template #doc-before>
37
+ <FfDocMeta />
38
+ <slot name="doc-before" />
39
+ </template>
36
40
 
37
- <template #layout-bottom>
38
- <slot name="layout-bottom" />
39
- <FfBackToTop />
40
- </template>
41
+ <template #layout-bottom>
42
+ <slot name="layout-bottom" />
43
+ <FfBackToTop />
44
+ </template>
41
45
 
42
- <template v-for="name in forwarded" :key="name" #[name]="data">
43
- <slot :name="name" v-bind="data ?? {}" />
44
- </template>
45
- </Layout>
46
- </div>
46
+ <template
47
+ v-for="name in forwarded"
48
+ :key="name"
49
+ #[name]="data"
50
+ >
51
+ <slot
52
+ :name="name"
53
+ v-bind="data ?? {}"
54
+ />
55
+ </template>
56
+ </Layout>
57
+ </div>
47
58
  </template>
@@ -5,6 +5,7 @@
5
5
  @use "theme" as mg;
6
6
 
7
7
  .ff-theme {
8
+
8
9
  // Margin notes rather than coloured panels: a rule on the left, a monospaced label, and the
9
10
  // text sitting on the same paper as the rest of the page.
10
11
 
@@ -5,6 +5,7 @@
5
5
  @use "theme" as mg;
6
6
 
7
7
  .ff-theme {
8
+
8
9
  // Each block gets a hairline frame and a header strip carrying the language and the copy
9
10
  // button. The strip is drawn from the language label the compiler already emits.
10
11
 
@@ -20,6 +20,7 @@
20
20
  }
21
21
 
22
22
  .ff-theme {
23
+
23
24
  // ----------------------------------------------------------------------------------------- //
24
25
  // Announcement bar
25
26
  // ----------------------------------------------------------------------------------------- //
@@ -56,30 +57,35 @@
56
57
  .ff-banner[data-variant="ink"] {
57
58
  --ff-banner-from: #{mg.ref("color-ink")};
58
59
  --ff-banner-to: #{mg.ref("color-ink-muted")};
60
+
59
61
  color: #{mg.ref("color-paper")};
60
62
  }
61
63
 
62
64
  .ff-banner[data-variant="accent"] {
63
65
  --ff-banner-from: #{mg.ref("color-accent")};
64
66
  --ff-banner-to: #{mg.ref("color-accent-hover")};
67
+
65
68
  color: #{mg.ref("color-accent-contrast")};
66
69
  }
67
70
 
68
71
  .ff-banner[data-variant="success"] {
69
72
  --ff-banner-from: #{mg.ref("color-success")};
70
73
  --ff-banner-to: #{mg.ref("color-ink")};
74
+
71
75
  color: #{mg.ref("color-paper")};
72
76
  }
73
77
 
74
78
  .ff-banner[data-variant="warning"] {
75
79
  --ff-banner-from: #{mg.ref("color-warning")};
76
80
  --ff-banner-to: #{mg.ref("color-ink")};
81
+
77
82
  color: #{mg.ref("color-paper")};
78
83
  }
79
84
 
80
85
  .ff-banner[data-variant="danger"] {
81
86
  --ff-banner-from: #{mg.ref("color-danger")};
82
87
  --ff-banner-to: #{mg.ref("color-ink")};
88
+
83
89
  color: #{mg.ref("color-paper")};
84
90
  }
85
91
 
@@ -283,7 +289,7 @@
283
289
  margin: 0;
284
290
  }
285
291
 
286
- @media (min-width: 768px) {
292
+ @media (width >= 768px) {
287
293
  .ff-footer {
288
294
  padding: 4rem 3rem 2.5rem;
289
295
  }
@@ -348,7 +354,7 @@
348
354
  color: #{mg.ref("color-ink-muted")};
349
355
  }
350
356
 
351
- @media (max-width: 640px) {
357
+ @media (width <= 640px) {
352
358
  .vp-doc .ff-card-grid {
353
359
  grid-template-columns: minmax(0, 1fr);
354
360
  }
@@ -13,7 +13,7 @@
13
13
 
14
14
 
15
15
  .ff-theme {
16
- @media (min-width: 960px) {
16
+ @media (width >= 960px) {
17
17
  .VPSidebar {
18
18
  padding-left: var(--ff-frame);
19
19
  width: calc(var(--ff-frame) + var(--vp-sidebar-width));
@@ -39,7 +39,7 @@
39
39
  // The outline lives in a container of a fixed width, so the column that holds it must never be
40
40
  // squeezed by the text: it would spill out of the band, past the bar above it.
41
41
 
42
- @media (min-width: 1280px) {
42
+ @media (width >= 1280px) {
43
43
  .VPDoc .aside {
44
44
  flex: 0 0 auto;
45
45
  width: 16rem;
@@ -89,6 +89,7 @@
89
89
  }
90
90
 
91
91
  .vp-doc h2 {
92
+
92
93
  // The gap between the section rule and the heading. The anchor hangs off the same value —
93
94
  // the default theme sets its own `top` to match its own padding, and this theme changes
94
95
  // that padding, so the two have to be declared once and read twice.
@@ -100,10 +101,10 @@
100
101
 
101
102
  // The section rule fades out to the right rather than cutting the page in two.
102
103
  border-image: linear-gradient(
103
- 90deg,
104
- #{mg.ref("color-rule-strong")},
105
- transparent 85%
106
- )
104
+ 90deg,
105
+ #{mg.ref("color-rule-strong")},
106
+ transparent 85%
107
+ )
107
108
  1;
108
109
  font-size: #{mg.ref("size-h2")};
109
110
  font-weight: 600;