@frontfactory/vitepress-theme 1.0.0

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,31 @@
1
+ <script setup lang="ts">
2
+ import { VPLink } from '../internal'
3
+
4
+ defineProps<{
5
+ title: string
6
+ /** Inline SVG or emoji shown above the title. */
7
+ icon?: string
8
+ link?: string
9
+ rel?: string
10
+ target?: string
11
+ }>()
12
+ </script>
13
+
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" />
24
+
25
+ <p class="ff-card-title">{{ title }}</p>
26
+
27
+ <div class="ff-card-body">
28
+ <slot />
29
+ </div>
30
+ </VPLink>
31
+ </template>
@@ -0,0 +1,9 @@
1
+ <script setup lang="ts">
2
+ withDefaults(defineProps<{ columns?: number | string }>(), { columns: 2 })
3
+ </script>
4
+
5
+ <template>
6
+ <div class="ff-card-grid" :style="{ '--ff-card-columns': columns }">
7
+ <slot />
8
+ </div>
9
+ </template>
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <kbd class="ff-kbd"><slot /></kbd>
3
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="ff-steps">
3
+ <slot />
4
+ </div>
5
+ </template>
package/src/index.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { Theme } from 'vitepress'
2
+ import DefaultTheme from 'vitepress/theme'
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'
10
+
11
+ import '../dist/style.css'
12
+
13
+ /**
14
+ * Editorial VitePress theme.
15
+ *
16
+ * It keeps the default theme underneath — search, i18n, mobile navigation and every markdown
17
+ * feature stay untouched — and replaces the whole surface: type, rules, numbering, hero, feature
18
+ * grid and footer.
19
+ */
20
+ const theme: Theme = {
21
+ extends: DefaultTheme,
22
+ Layout: FfLayout,
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)
29
+ }
30
+ }
31
+
32
+ export default theme
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'
39
+
40
+ export { defaultLabels, useLabels, useThemeOptions } from './composables/options'
41
+
42
+ export type {
43
+ BannerConfig,
44
+ FooterColumn,
45
+ FooterLink,
46
+ HeroExtras,
47
+ HeroMetaItem,
48
+ MetaConfig,
49
+ ThemeConfig,
50
+ ThemeLabels,
51
+ ThemeOptions
52
+ } from './types'
@@ -0,0 +1,10 @@
1
+ // Pieces borrowed from the VitePress default theme.
2
+ //
3
+ // `VPImage`, `VPLink` and `useLayout` are part of its public surface (`vitepress/theme`), but they
4
+ // are imported from their own files instead: components that this theme swaps in through a Vite
5
+ // alias would otherwise import the theme index that imports them back. Nothing here reaches for an
6
+ // API the default theme does not export.
7
+
8
+ export { default as VPImage } from 'vitepress/dist/client/theme-default/components/VPImage.vue'
9
+ export { default as VPLink } from 'vitepress/dist/client/theme-default/components/VPLink.vue'
10
+ export { useLayout } from 'vitepress/dist/client/theme-default/composables/layout.js'
@@ -0,0 +1,41 @@
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
+
8
+ const { Layout } = DefaultTheme
9
+
10
+ // Three slots carry the additions of this theme; every other slot the site passes in is forwarded
11
+ // untouched, so the whole default slot surface keeps working.
12
+ const owned = ['layout-top', 'doc-before', 'layout-bottom']
13
+
14
+ const slots = useSlots()
15
+ const forwarded = computed(() => Object.keys(slots).filter((name) => !owned.includes(name)))
16
+ </script>
17
+
18
+ <template>
19
+ <div class="ff-theme">
20
+ <Layout>
21
+ <template #layout-top>
22
+ <FfBanner />
23
+ <slot name="layout-top" />
24
+ </template>
25
+
26
+ <template #doc-before>
27
+ <FfDocMeta />
28
+ <slot name="doc-before" />
29
+ </template>
30
+
31
+ <template #layout-bottom>
32
+ <slot name="layout-bottom" />
33
+ <FfBackToTop />
34
+ </template>
35
+
36
+ <template v-for="name in forwarded" :key="name" #[name]="data">
37
+ <slot :name="name" v-bind="data ?? {}" />
38
+ </template>
39
+ </Layout>
40
+ </div>
41
+ </template>
@@ -0,0 +1,121 @@
1
+ // ============================================================================================= //
2
+ // BASE //
3
+ // ============================================================================================= //
4
+
5
+ @use "theme" as mg;
6
+
7
+ // Everything the theme restyles is scoped under .ff-theme, the class the layout puts on its root
8
+ // element. It buys one point of specificity over the scoped styles of the default theme, which is
9
+ // what makes the overrides land without a single !important.
10
+
11
+ .ff-theme {
12
+ font-family: #{mg.ref("font-body")};
13
+ font-size: #{mg.ref("size-body")};
14
+ line-height: #{mg.ref("leading-body")};
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale;
17
+ }
18
+
19
+ // --------------------------------------------------------------------------------------------- //
20
+ // Shared primitives
21
+ // --------------------------------------------------------------------------------------------- //
22
+
23
+ .ff-label {
24
+ display: inline-flex;
25
+ align-items: center;
26
+ gap: 0.5em;
27
+ font-family: #{mg.ref("font-mono")};
28
+ font-size: #{mg.ref("size-label")};
29
+ font-weight: 500;
30
+ line-height: 1;
31
+ text-transform: uppercase;
32
+ letter-spacing: #{mg.ref("tracking-label")};
33
+ color: #{mg.ref("color-ink-faint")};
34
+ }
35
+
36
+ .ff-display {
37
+ font-family: #{mg.ref("font-display")};
38
+ font-weight: 620;
39
+ letter-spacing: #{mg.ref("tracking-display")};
40
+ line-height: #{mg.ref("leading-tight")};
41
+ font-variation-settings: "opsz" 32;
42
+ }
43
+
44
+ // --------------------------------------------------------------------------------------------- //
45
+ // Selection, focus and scrollbars
46
+ // --------------------------------------------------------------------------------------------- //
47
+
48
+ ::selection {
49
+ background: #{mg.ref("color-accent-soft")};
50
+ }
51
+
52
+ .ff-theme :focus-visible,
53
+ .VPLocalSearchBox :focus-visible {
54
+ outline: 2px solid #{mg.ref("color-accent")};
55
+ outline-offset: 2px;
56
+ border-radius: #{mg.ref("radius-sm")};
57
+ }
58
+
59
+ .ff-theme * {
60
+ scrollbar-width: thin;
61
+ scrollbar-color: #{mg.ref("color-rule-strong")} transparent;
62
+ }
63
+
64
+ // --------------------------------------------------------------------------------------------- //
65
+ // Buttons
66
+ //
67
+ // Square-ish, hairline, no lift on hover: the accent does the talking.
68
+ // --------------------------------------------------------------------------------------------- //
69
+
70
+ .ff-theme {
71
+ .VPButton {
72
+ border-radius: #{mg.ref("radius-sm")};
73
+ border-width: #{mg.ref("rule-width")};
74
+ font-weight: 550;
75
+ letter-spacing: 0.01em;
76
+ transition:
77
+ background-color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")},
78
+ border-color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")},
79
+ color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")};
80
+ }
81
+
82
+ .VPButton.medium {
83
+ padding: 0 1.25rem;
84
+ line-height: 2.75rem;
85
+ font-size: 0.875rem;
86
+ }
87
+
88
+ .VPButton.big {
89
+ padding: 0 1.75rem;
90
+ line-height: 3.25rem;
91
+ font-size: 0.9375rem;
92
+ }
93
+
94
+ .VPBadge {
95
+ border-radius: #{mg.ref("radius-sm")};
96
+ border: #{mg.ref("rule-width")} solid #{mg.ref("color-rule-strong")};
97
+ background: transparent;
98
+ font-family: #{mg.ref("font-mono")};
99
+ font-size: #{mg.ref("size-label")};
100
+ font-weight: 500;
101
+ text-transform: uppercase;
102
+ letter-spacing: 0.06em;
103
+ color: #{mg.ref("color-ink-muted")};
104
+ }
105
+
106
+ .VPBadge.tip,
107
+ .VPBadge.info {
108
+ border-color: #{mg.ref("color-accent")};
109
+ color: #{mg.ref("color-accent")};
110
+ }
111
+
112
+ .VPBadge.warning {
113
+ border-color: #{mg.ref("color-warning")};
114
+ color: #{mg.ref("color-warning")};
115
+ }
116
+
117
+ .VPBadge.danger {
118
+ border-color: #{mg.ref("color-danger")};
119
+ color: #{mg.ref("color-danger")};
120
+ }
121
+ }
@@ -0,0 +1,103 @@
1
+ // ============================================================================================= //
2
+ // CUSTOM BLOCKS //
3
+ // ============================================================================================= //
4
+
5
+ @use "theme" as mg;
6
+
7
+ .ff-theme {
8
+ // Margin notes rather than coloured panels: a rule on the left, a monospaced label, and the
9
+ // text sitting on the same paper as the rest of the page.
10
+
11
+ .vp-doc .custom-block {
12
+ margin: 1.75rem 0;
13
+ padding: 0 0 0 1.25rem;
14
+ border: 0;
15
+ border-left: #{mg.ref("rule-accent-width")} solid #{mg.ref("color-rule-strong")};
16
+ border-radius: 0;
17
+ background: transparent;
18
+ font-size: 0.9375rem;
19
+ }
20
+
21
+ .vp-doc .custom-block p,
22
+ .vp-doc .custom-block li {
23
+ line-height: 1.7;
24
+ color: #{mg.ref("color-ink-muted")};
25
+ }
26
+
27
+ .vp-doc .custom-block p:first-of-type {
28
+ margin-top: 0;
29
+ }
30
+
31
+ .vp-doc .custom-block p:last-child {
32
+ margin-bottom: 0;
33
+ }
34
+
35
+ .vp-doc .custom-block .custom-block-title {
36
+ margin-bottom: 0.5rem;
37
+ font-family: #{mg.ref("font-mono")};
38
+ font-size: #{mg.ref("size-label")};
39
+ font-weight: 500;
40
+ line-height: 1;
41
+ text-transform: uppercase;
42
+ letter-spacing: #{mg.ref("tracking-label")};
43
+ color: #{mg.ref("color-ink-faint")};
44
+ }
45
+
46
+ .vp-doc .custom-block.tip,
47
+ .vp-doc .custom-block.note,
48
+ .vp-doc .custom-block.info,
49
+ .vp-doc .custom-block.important {
50
+ border-left-color: #{mg.ref("color-accent")};
51
+ }
52
+
53
+ .vp-doc .custom-block.tip .custom-block-title,
54
+ .vp-doc .custom-block.note .custom-block-title,
55
+ .vp-doc .custom-block.important .custom-block-title {
56
+ color: #{mg.ref("color-accent")};
57
+ }
58
+
59
+ .vp-doc .custom-block.warning {
60
+ border-left-color: #{mg.ref("color-warning")};
61
+ }
62
+
63
+ .vp-doc .custom-block.warning .custom-block-title {
64
+ color: #{mg.ref("color-warning")};
65
+ }
66
+
67
+ .vp-doc .custom-block.danger,
68
+ .vp-doc .custom-block.caution {
69
+ border-left-color: #{mg.ref("color-danger")};
70
+ }
71
+
72
+ .vp-doc .custom-block.danger .custom-block-title,
73
+ .vp-doc .custom-block.caution .custom-block-title {
74
+ color: #{mg.ref("color-danger")};
75
+ }
76
+
77
+ .vp-doc .custom-block a {
78
+ font-weight: inherit;
79
+ }
80
+
81
+ // Collapsibles keep a frame — they are objects on the page, not asides.
82
+
83
+ .vp-doc .custom-block.details {
84
+ padding: 1rem 1.25rem;
85
+ border: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
86
+ border-radius: #{mg.ref("radius-md")};
87
+ }
88
+
89
+ .vp-doc .custom-block.details summary {
90
+ margin-bottom: 0;
91
+ font-family: #{mg.ref("font-mono")};
92
+ font-size: #{mg.ref("size-meta")};
93
+ font-weight: 500;
94
+ text-transform: uppercase;
95
+ letter-spacing: 0.06em;
96
+ color: #{mg.ref("color-ink")};
97
+ cursor: pointer;
98
+ }
99
+
100
+ .vp-doc .custom-block.details[open] summary {
101
+ margin-bottom: 0.75rem;
102
+ }
103
+ }
@@ -0,0 +1,163 @@
1
+ // ============================================================================================= //
2
+ // CODE //
3
+ // ============================================================================================= //
4
+
5
+ @use "theme" as mg;
6
+
7
+ .ff-theme {
8
+ // Each block gets a hairline frame and a header strip carrying the language and the copy
9
+ // button. The strip is drawn from the language label the compiler already emits.
10
+
11
+ .vp-doc div[class*="language-"],
12
+ .vp-doc .vp-block {
13
+ margin: 1.75rem 0;
14
+ padding-top: 2.5rem;
15
+ border: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
16
+ border-radius: #{mg.ref("radius-md")};
17
+ background: #{mg.ref("color-surface")};
18
+ }
19
+
20
+ .vp-doc [class*="language-"] > pre {
21
+ margin: 0;
22
+ border-top: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
23
+ }
24
+
25
+ .vp-doc [class*="language-"] > span.lang {
26
+ display: flex;
27
+ align-items: center;
28
+ top: 0;
29
+ right: auto;
30
+ left: 0;
31
+ height: 2.5rem;
32
+ padding: 0 1rem;
33
+ font-family: #{mg.ref("font-mono")};
34
+ font-size: #{mg.ref("size-label")};
35
+ font-weight: 500;
36
+ text-transform: uppercase;
37
+ letter-spacing: #{mg.ref("tracking-label")};
38
+ color: #{mg.ref("color-ink-faint")};
39
+ opacity: 1;
40
+ }
41
+
42
+ .vp-doc [class*="language-"]:hover > button.copy + span.lang,
43
+ .vp-doc [class*="language-"] > button.copy:focus + span.lang {
44
+ opacity: 1;
45
+ }
46
+
47
+ .vp-doc [class*="language-"] > button.copy {
48
+ top: 0.4375rem;
49
+ right: 0.625rem;
50
+ width: 1.75rem;
51
+ height: 1.75rem;
52
+ border-radius: #{mg.ref("radius-sm")};
53
+ background-color: transparent;
54
+ background-size: 0.875rem;
55
+ opacity: 0.55;
56
+ }
57
+
58
+ .vp-doc [class*="language-"]:hover > button.copy,
59
+ .vp-doc [class*="language-"] > button.copy:focus {
60
+ opacity: 1;
61
+ }
62
+
63
+ .vp-doc [class*="language-"] > button.copy.copied,
64
+ .vp-doc [class*="language-"] > button.copy:hover.copied {
65
+ border-radius: 0 #{mg.ref("radius-sm")} #{mg.ref("radius-sm")} 0;
66
+ }
67
+
68
+ .vp-doc [class*="language-"] > button.copy.copied::before,
69
+ .vp-doc [class*="language-"] > button.copy:hover.copied::before {
70
+ top: 0;
71
+ height: 1.75rem;
72
+ border-radius: #{mg.ref("radius-sm")} 0 0 #{mg.ref("radius-sm")};
73
+ background: #{mg.ref("color-surface")};
74
+ font-family: #{mg.ref("font-mono")};
75
+ font-size: #{mg.ref("size-label")};
76
+ text-transform: uppercase;
77
+ letter-spacing: 0.06em;
78
+ }
79
+
80
+ .vp-doc div[class*="language-"].line-numbers-mode {
81
+ padding-left: 0;
82
+ }
83
+
84
+ .vp-doc [class*="language-"] .line-numbers-wrapper {
85
+ top: 2.5rem;
86
+ border-right: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
87
+ font-family: #{mg.ref("font-mono")};
88
+ color: #{mg.ref("color-ink-faint")};
89
+ }
90
+
91
+ // ----------------------------------------------------------------------------------------- //
92
+ // Code groups: the tabs replace the header strip
93
+ // ----------------------------------------------------------------------------------------- //
94
+
95
+ .vp-doc .vp-code-group {
96
+ margin: 1.75rem 0;
97
+ border: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
98
+ border-radius: #{mg.ref("radius-md")};
99
+ background: #{mg.ref("color-surface")};
100
+ overflow: hidden;
101
+ }
102
+
103
+ .vp-doc .vp-code-group .tabs {
104
+ margin: 0;
105
+ padding: 0 0.5rem;
106
+ border-bottom: #{mg.ref("rule-width")} solid #{mg.ref("color-rule")};
107
+ border-radius: 0;
108
+ background: transparent;
109
+ box-shadow: none;
110
+ }
111
+
112
+ .vp-doc .vp-code-group .tabs label {
113
+ padding: 0 0.75rem;
114
+ line-height: 2.5rem;
115
+ font-family: #{mg.ref("font-mono")};
116
+ font-size: #{mg.ref("size-label")};
117
+ font-weight: 500;
118
+ text-transform: uppercase;
119
+ letter-spacing: #{mg.ref("tracking-label")};
120
+ color: #{mg.ref("color-ink-faint")};
121
+ }
122
+
123
+ .vp-doc .vp-code-group input:checked + label {
124
+ color: #{mg.ref("color-ink")};
125
+ }
126
+
127
+ .vp-doc .vp-code-group .tabs label::after {
128
+ right: 0;
129
+ left: 0;
130
+ border-radius: 0;
131
+ }
132
+
133
+ .vp-doc .vp-code-group div[class*="language-"] {
134
+ margin: 0;
135
+ padding-top: 0;
136
+ border: 0;
137
+ border-radius: 0;
138
+ }
139
+
140
+ .vp-doc .vp-code-group div[class*="language-"] > pre {
141
+ border-top: 0;
142
+ }
143
+
144
+ .vp-doc .vp-code-group div[class*="language-"] > span.lang,
145
+ .vp-doc .custom-block div[class*="language-"] > span.lang {
146
+ display: none;
147
+ }
148
+
149
+ .vp-doc .vp-code-group [class*="language-"] .line-numbers-wrapper {
150
+ top: 0;
151
+ }
152
+
153
+ // Blocks nested in a custom block stay flush with the note.
154
+
155
+ .vp-doc .custom-block div[class*="language-"] {
156
+ padding-top: 0;
157
+ background: #{mg.ref("color-surface")};
158
+ }
159
+
160
+ .vp-doc .custom-block div[class*="language-"] > pre {
161
+ border-top: 0;
162
+ }
163
+ }