@alphacifer/slidev-addon-theme 0.0.4 → 0.0.6
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 +127 -2
- package/components/arc-arrow-process/ArcArrowProcess.vue +361 -0
- package/components/arc-arrow-process/ArcArrowProcessArrow.vue +143 -0
- package/components/arc-arrow-process/ArcArrowProcessCallout.vue +361 -0
- package/components/arc-arrow-process/ArcArrowProcessContent.vue +38 -0
- package/components/arc-arrow-process/ArcArrowProcessHeading.vue +43 -0
- package/components/arc-arrow-process/ArcArrowProcessIcon.vue +154 -0
- package/components/arc-compare/ArcCompare.vue +443 -0
- package/components/arc-compare/ArcCompareBadge.vue +63 -0
- package/components/arc-compare/ArcCompareCallout.vue +386 -0
- package/components/arc-compare/ArcCompareContent.vue +52 -0
- package/components/arc-compare/ArcCompareContents.vue +18 -0
- package/components/arc-compare/ArcCompareHeading.vue +52 -0
- package/components/arc-compare/ArcCompareLeft.vue +183 -0
- package/components/arc-compare/ArcCompareRight.vue +183 -0
- package/components/arc-compare/ArcCompareTitle.vue +47 -0
- package/components/arrow-triad/ArrowTriad.vue +368 -0
- package/components/arrow-triad/ArrowTriadCallout.vue +300 -0
- package/components/arrow-triad/ArrowTriadContent.vue +38 -0
- package/components/arrow-triad/ArrowTriadHeading.vue +38 -0
- package/components/arrow-triad/ArrowTriadIcon.vue +96 -0
- package/components/chevron-card/ChevronCard.vue +237 -0
- package/components/chevron-card/ChevronCardBadge.vue +74 -0
- package/components/chevron-card/ChevronCardContent.vue +39 -0
- package/components/chevron-card/ChevronCardHeading.vue +39 -0
- package/components/hex-triad/HexTriad.vue +438 -0
- package/components/hex-triad/HexTriadBadge.vue +110 -0
- package/components/hex-triad/HexTriadCallout.vue +200 -0
- package/components/hex-triad/HexTriadCenterBadge.vue +51 -0
- package/components/hex-triad/HexTriadContent.vue +20 -0
- package/components/hex-triad/HexTriadHeading.vue +28 -0
- package/components/hex-triad/HexTriadLayer.vue +28 -0
- package/components/horiz-card/HorizCard.vue +318 -0
- package/components/horiz-card/HorizCardBadge.vue +75 -0
- package/components/horiz-card/HorizCardContent.vue +46 -0
- package/components/horiz-card/HorizCardHeading.vue +47 -0
- package/components/horiz-card/HorizCardIcon.vue +118 -0
- package/components/quad-hub/QuadHub.vue +642 -0
- package/components/quad-hub/QuadHubCallout.vue +267 -0
- package/components/quad-hub/QuadHubCenter.vue +53 -0
- package/components/quad-hub/QuadHubContent.vue +39 -0
- package/components/quad-hub/QuadHubHeading.vue +44 -0
- package/components/quad-hub/QuadHubIcon.vue +112 -0
- package/components/shifting-heading/TransitionHeading.vue +3 -3
- package/components/vert-card/VertCard.vue +389 -0
- package/components/vert-card/VertCardBadge.vue +72 -0
- package/components/vert-card/VertCardContent.vue +45 -0
- package/components/vert-card/VertCardHeading.vue +68 -0
- package/components/vert-card/VertCardIcon.vue +126 -0
- package/components/vert-card/VertCardTitle.vue +76 -0
- package/layouts/core/arc-toc.vue +76 -113
- package/layouts/core/bg-center.vue +32 -4
- package/layouts/shifting-heading/shifting-intro.vue +35 -7
- package/package.json +3 -2
- package/utils/arcArrowProcess/context.ts +28 -0
- package/utils/arcArrowProcess/createArcArrowProcessGeometry.ts +137 -0
- package/utils/arcArrowProcess/index.ts +3 -0
- package/utils/arcArrowProcess/resolveArcArrowProcessItems.ts +189 -0
- package/utils/arcCompare/context.ts +36 -0
- package/utils/arcCompare/createArcCompareGeometry.ts +254 -0
- package/utils/arcCompare/index.ts +3 -0
- package/utils/arcCompare/resolveArcCompareItems.ts +123 -0
- package/utils/arrowTriad/context.ts +38 -0
- package/utils/arrowTriad/createArrowTriadGeometry.ts +63 -0
- package/utils/arrowTriad/index.ts +3 -0
- package/utils/arrowTriad/resolveArrowTriadItems.ts +121 -0
- package/utils/chevronCard/context.ts +12 -0
- package/utils/chevronCard/createChevronCardGeometry.ts +48 -0
- package/utils/chevronCard/index.ts +2 -0
- package/utils/hexTriad/context.ts +25 -0
- package/utils/hexTriad/createHexTriadGeometry.ts +182 -0
- package/utils/hexTriad/index.ts +3 -0
- package/utils/hexTriad/resolveHexTriadItems.ts +63 -0
- package/utils/horizCard/context.ts +13 -0
- package/utils/horizCard/createHorizCardGeometry.ts +243 -0
- package/utils/horizCard/index.ts +2 -0
- package/utils/quadHub/context.ts +26 -0
- package/utils/quadHub/createQuadHubGeometry.ts +331 -0
- package/utils/quadHub/index.ts +3 -0
- package/utils/quadHub/resolveQuadHubItems.ts +214 -0
- package/utils/useDiagramAutoScale.ts +300 -0
- package/utils/vertCard/context.ts +18 -0
- package/utils/vertCard/createVertCardGeometry.ts +242 -0
- package/utils/vertCard/index.ts +2 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { lightenColor } from './createQuadHubGeometry';
|
|
2
|
+
|
|
3
|
+
export type TQuadHubIcon = string | object | boolean;
|
|
4
|
+
|
|
5
|
+
export interface IQuadHubItem {
|
|
6
|
+
readonly id?: string | number;
|
|
7
|
+
/**
|
|
8
|
+
* Optional icon: icon class (e.g. 'i-lucide-user'), component object,
|
|
9
|
+
* built-in name ('user' | 'academic' | 'briefcase' | 'target'), or false to hide.
|
|
10
|
+
*/
|
|
11
|
+
readonly icon?: TQuadHubIcon;
|
|
12
|
+
readonly color?: string;
|
|
13
|
+
readonly cardBg?: string;
|
|
14
|
+
readonly arcColor?: string;
|
|
15
|
+
readonly arcRatio?: number;
|
|
16
|
+
readonly textColor?: string;
|
|
17
|
+
readonly titleColor?: string;
|
|
18
|
+
readonly arcBorderColor?: string;
|
|
19
|
+
readonly arcBorderRatio?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IResolvedQuadHubItem extends IQuadHubItem {
|
|
23
|
+
readonly id: string | number;
|
|
24
|
+
readonly color: string;
|
|
25
|
+
readonly cardBg: string;
|
|
26
|
+
readonly arcColor: string;
|
|
27
|
+
readonly textColor: string;
|
|
28
|
+
readonly titleColor: string;
|
|
29
|
+
readonly arcBorderColor: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const DEFAULT_QUAD_HUB_ITEMS: readonly [
|
|
33
|
+
IResolvedQuadHubItem,
|
|
34
|
+
IResolvedQuadHubItem,
|
|
35
|
+
IResolvedQuadHubItem,
|
|
36
|
+
IResolvedQuadHubItem,
|
|
37
|
+
] = [
|
|
38
|
+
// 0: Top-Left (01) - Golden Orange
|
|
39
|
+
{
|
|
40
|
+
id: '01',
|
|
41
|
+
icon: 'user',
|
|
42
|
+
color: '#f29e4b',
|
|
43
|
+
cardBg: lightenColor({
|
|
44
|
+
hex: '#f29e4b',
|
|
45
|
+
ratio: 0.9,
|
|
46
|
+
}),
|
|
47
|
+
arcColor: lightenColor({
|
|
48
|
+
hex: '#f29e4b',
|
|
49
|
+
ratio: 0.55,
|
|
50
|
+
}),
|
|
51
|
+
textColor: '#555555',
|
|
52
|
+
titleColor: '#e6882c',
|
|
53
|
+
arcBorderColor: lightenColor({
|
|
54
|
+
hex: '#f29e4b',
|
|
55
|
+
ratio: 0.8,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
// 1: Top-Right (02) - Fresh Sage Green
|
|
59
|
+
{
|
|
60
|
+
id: '02',
|
|
61
|
+
icon: 'academic',
|
|
62
|
+
color: '#a4cb81',
|
|
63
|
+
cardBg: lightenColor({
|
|
64
|
+
hex: '#a4cb81',
|
|
65
|
+
ratio: 0.9,
|
|
66
|
+
}),
|
|
67
|
+
arcColor: lightenColor({
|
|
68
|
+
hex: '#a4cb81',
|
|
69
|
+
ratio: 0.55,
|
|
70
|
+
}),
|
|
71
|
+
textColor: '#555555',
|
|
72
|
+
titleColor: '#8bb863',
|
|
73
|
+
arcBorderColor: lightenColor({
|
|
74
|
+
hex: '#a4cb81',
|
|
75
|
+
ratio: 0.8,
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
// 2: Bottom-Right (03) - Seafoam Teal
|
|
79
|
+
{
|
|
80
|
+
id: '03',
|
|
81
|
+
icon: 'briefcase',
|
|
82
|
+
color: '#62b6a8',
|
|
83
|
+
cardBg: lightenColor({
|
|
84
|
+
hex: '#62b6a8',
|
|
85
|
+
ratio: 0.9,
|
|
86
|
+
}),
|
|
87
|
+
arcColor: lightenColor({
|
|
88
|
+
hex: '#62b6a8',
|
|
89
|
+
ratio: 0.55,
|
|
90
|
+
}),
|
|
91
|
+
textColor: '#555555',
|
|
92
|
+
titleColor: '#4ea798',
|
|
93
|
+
arcBorderColor: lightenColor({
|
|
94
|
+
hex: '#62b6a8',
|
|
95
|
+
ratio: 0.8,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
// 3: Bottom-Left (04) - Coral Rose Pink
|
|
99
|
+
{
|
|
100
|
+
id: '04',
|
|
101
|
+
icon: 'target',
|
|
102
|
+
color: '#e9717a',
|
|
103
|
+
cardBg: lightenColor({
|
|
104
|
+
hex: '#e9717a',
|
|
105
|
+
ratio: 0.9,
|
|
106
|
+
}),
|
|
107
|
+
arcColor: lightenColor({
|
|
108
|
+
hex: '#e9717a',
|
|
109
|
+
ratio: 0.55,
|
|
110
|
+
}),
|
|
111
|
+
textColor: '#555555',
|
|
112
|
+
titleColor: '#e45b65',
|
|
113
|
+
arcBorderColor: lightenColor({
|
|
114
|
+
hex: '#e9717a',
|
|
115
|
+
ratio: 0.8,
|
|
116
|
+
}),
|
|
117
|
+
},
|
|
118
|
+
] as const;
|
|
119
|
+
|
|
120
|
+
export function resolveSingleItem(
|
|
121
|
+
defaultItem: IResolvedQuadHubItem,
|
|
122
|
+
userItem?: IQuadHubItem,
|
|
123
|
+
defaultArcRatio = 0.55,
|
|
124
|
+
defaultArcBorderRatio = 0.8,
|
|
125
|
+
): IResolvedQuadHubItem {
|
|
126
|
+
const merged = {
|
|
127
|
+
...defaultItem,
|
|
128
|
+
...(userItem ?? {}),
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const baseColor = merged.color ?? defaultItem.color;
|
|
132
|
+
const resolvedArcRatio = merged.arcRatio ?? defaultArcRatio;
|
|
133
|
+
const resolvedArcBorderRatio = merged.arcBorderRatio ?? defaultArcBorderRatio;
|
|
134
|
+
|
|
135
|
+
const isColorChanged = userItem?.color !== undefined;
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
...merged,
|
|
139
|
+
id: merged.id ?? defaultItem.id,
|
|
140
|
+
color: baseColor,
|
|
141
|
+
cardBg:
|
|
142
|
+
userItem?.cardBg ??
|
|
143
|
+
(isColorChanged
|
|
144
|
+
? lightenColor({
|
|
145
|
+
hex: baseColor,
|
|
146
|
+
ratio: 0.9,
|
|
147
|
+
})
|
|
148
|
+
: defaultItem.cardBg),
|
|
149
|
+
arcColor:
|
|
150
|
+
userItem?.arcColor ??
|
|
151
|
+
(isColorChanged || userItem?.arcRatio !== undefined
|
|
152
|
+
? lightenColor({
|
|
153
|
+
hex: baseColor,
|
|
154
|
+
ratio: resolvedArcRatio,
|
|
155
|
+
})
|
|
156
|
+
: defaultItem.arcColor),
|
|
157
|
+
textColor: merged.textColor ?? defaultItem.textColor,
|
|
158
|
+
titleColor:
|
|
159
|
+
merged.titleColor ??
|
|
160
|
+
(isColorChanged ? baseColor : defaultItem.titleColor),
|
|
161
|
+
arcBorderColor:
|
|
162
|
+
userItem?.arcBorderColor ??
|
|
163
|
+
(isColorChanged || userItem?.arcBorderRatio !== undefined
|
|
164
|
+
? lightenColor({
|
|
165
|
+
hex: baseColor,
|
|
166
|
+
ratio: resolvedArcBorderRatio,
|
|
167
|
+
})
|
|
168
|
+
: defaultItem.arcBorderColor),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface IResolveQuadHubItemsParams {
|
|
173
|
+
readonly items?: readonly IQuadHubItem[];
|
|
174
|
+
readonly arcRatio?: number;
|
|
175
|
+
readonly arcBorderRatio?: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function resolveQuadHubItems({
|
|
179
|
+
items = [],
|
|
180
|
+
arcRatio = 0.55,
|
|
181
|
+
arcBorderRatio = 0.8,
|
|
182
|
+
}: IResolveQuadHubItemsParams = {}): readonly [
|
|
183
|
+
IResolvedQuadHubItem,
|
|
184
|
+
IResolvedQuadHubItem,
|
|
185
|
+
IResolvedQuadHubItem,
|
|
186
|
+
IResolvedQuadHubItem,
|
|
187
|
+
] {
|
|
188
|
+
return [
|
|
189
|
+
resolveSingleItem(
|
|
190
|
+
DEFAULT_QUAD_HUB_ITEMS[0],
|
|
191
|
+
items[0],
|
|
192
|
+
arcRatio,
|
|
193
|
+
arcBorderRatio,
|
|
194
|
+
),
|
|
195
|
+
resolveSingleItem(
|
|
196
|
+
DEFAULT_QUAD_HUB_ITEMS[1],
|
|
197
|
+
items[1],
|
|
198
|
+
arcRatio,
|
|
199
|
+
arcBorderRatio,
|
|
200
|
+
),
|
|
201
|
+
resolveSingleItem(
|
|
202
|
+
DEFAULT_QUAD_HUB_ITEMS[2],
|
|
203
|
+
items[2],
|
|
204
|
+
arcRatio,
|
|
205
|
+
arcBorderRatio,
|
|
206
|
+
),
|
|
207
|
+
resolveSingleItem(
|
|
208
|
+
DEFAULT_QUAD_HUB_ITEMS[3],
|
|
209
|
+
items[3],
|
|
210
|
+
arcRatio,
|
|
211
|
+
arcBorderRatio,
|
|
212
|
+
),
|
|
213
|
+
] as const;
|
|
214
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComputedRef,
|
|
3
|
+
computed,
|
|
4
|
+
onMounted,
|
|
5
|
+
onUnmounted,
|
|
6
|
+
type Ref,
|
|
7
|
+
ref,
|
|
8
|
+
} from 'vue';
|
|
9
|
+
|
|
10
|
+
export interface IUseDiagramAutoScaleOptions {
|
|
11
|
+
readonly rootRef: Ref<HTMLElement | null>;
|
|
12
|
+
readonly baseWidth: number;
|
|
13
|
+
readonly baseHeight: number;
|
|
14
|
+
readonly scale?: Ref<number | undefined> | (() => number | undefined);
|
|
15
|
+
readonly autoScale?: Ref<boolean | undefined> | (() => boolean | undefined);
|
|
16
|
+
readonly maxScale?: Ref<number | undefined> | (() => number | undefined);
|
|
17
|
+
readonly height?:
|
|
18
|
+
| Ref<number | string | undefined>
|
|
19
|
+
| (() => number | string | undefined);
|
|
20
|
+
readonly pagyClearance?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IUseDiagramAutoScaleResult {
|
|
24
|
+
readonly resolvedScale: ComputedRef<number>;
|
|
25
|
+
readonly autoScaleValue: Ref<number>;
|
|
26
|
+
readonly containerHeight: Ref<number>;
|
|
27
|
+
readonly updateScale: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolveValue<T>(val: Ref<T> | (() => T) | undefined, fallback: T): T {
|
|
31
|
+
if (typeof val === 'function') {
|
|
32
|
+
const res = (val as () => T)();
|
|
33
|
+
|
|
34
|
+
return res !== undefined ? res : fallback;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (val !== undefined && val.value !== undefined) {
|
|
38
|
+
return val.value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return fallback;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Automatically computes a scale factor (via CSS transform: scale)
|
|
46
|
+
* so that diagram components (ArrowTriad, QuadHub, ArcArrowProcess, etc.)
|
|
47
|
+
* fit comfortably inside the available slide canvas without clipping or overlaying pagination.
|
|
48
|
+
*/
|
|
49
|
+
export function useDiagramAutoScale(
|
|
50
|
+
options: IUseDiagramAutoScaleOptions,
|
|
51
|
+
): IUseDiagramAutoScaleResult {
|
|
52
|
+
const { rootRef, baseWidth, baseHeight, pagyClearance = 32 } = options;
|
|
53
|
+
|
|
54
|
+
const autoScaleValue = ref<number>(1);
|
|
55
|
+
const containerHeight = ref<number>(0);
|
|
56
|
+
|
|
57
|
+
const updateScale = () => {
|
|
58
|
+
if (typeof window === 'undefined' || !rootRef.value) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const el = rootRef.value;
|
|
63
|
+
const parent = el.parentElement;
|
|
64
|
+
|
|
65
|
+
if (!parent) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 1. Locate slide container if inside Slidev
|
|
70
|
+
const pageEl = el.closest<HTMLElement>(
|
|
71
|
+
'.slidev-page, [data-slidev-page], .slidev-slide-content',
|
|
72
|
+
);
|
|
73
|
+
const layoutEl = el.closest<HTMLElement>('.slidev-layout');
|
|
74
|
+
const slideEl = pageEl || layoutEl;
|
|
75
|
+
|
|
76
|
+
// Immediate parent padding
|
|
77
|
+
const parentStyle = window.getComputedStyle(parent);
|
|
78
|
+
const padLeft = Number.parseFloat(parentStyle.paddingLeft) || 0;
|
|
79
|
+
const padRight = Number.parseFloat(parentStyle.paddingRight) || 0;
|
|
80
|
+
const padTop = Number.parseFloat(parentStyle.paddingTop) || 0;
|
|
81
|
+
const padBottom = Number.parseFloat(parentStyle.paddingBottom) || 0;
|
|
82
|
+
|
|
83
|
+
// Available width inside parent or slide layout
|
|
84
|
+
let availW = 0;
|
|
85
|
+
|
|
86
|
+
if (parent.clientWidth > 0) {
|
|
87
|
+
availW = parent.clientWidth - padLeft - padRight;
|
|
88
|
+
} else if (slideEl && slideEl.clientWidth > 0) {
|
|
89
|
+
const slideStyle = window.getComputedStyle(slideEl);
|
|
90
|
+
const sPadLeft = Number.parseFloat(slideStyle.paddingLeft) || 0;
|
|
91
|
+
const sPadRight = Number.parseFloat(slideStyle.paddingRight) || 0;
|
|
92
|
+
availW = slideEl.clientWidth - sPadLeft - sPadRight;
|
|
93
|
+
} else if (el.clientWidth > 0) {
|
|
94
|
+
availW = el.clientWidth;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Available height inside parent or slide layout
|
|
98
|
+
let availH = 0;
|
|
99
|
+
const explicitHeight = resolveValue(options.height, undefined);
|
|
100
|
+
|
|
101
|
+
if (typeof explicitHeight === 'number') {
|
|
102
|
+
availH = explicitHeight;
|
|
103
|
+
} else if (
|
|
104
|
+
typeof explicitHeight === 'string' &&
|
|
105
|
+
explicitHeight.endsWith('px')
|
|
106
|
+
) {
|
|
107
|
+
availH = Number.parseFloat(explicitHeight);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!availH) {
|
|
111
|
+
// Calculate sibling heights inside parent (e.g. title, headers)
|
|
112
|
+
let siblingsH = 0;
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < parent.children.length; i++) {
|
|
115
|
+
const child = parent.children[i];
|
|
116
|
+
|
|
117
|
+
if (child && child !== el && child instanceof HTMLElement) {
|
|
118
|
+
siblingsH += child.offsetHeight;
|
|
119
|
+
const cs = window.getComputedStyle(child);
|
|
120
|
+
siblingsH +=
|
|
121
|
+
(Number.parseFloat(cs.marginTop) || 0) +
|
|
122
|
+
(Number.parseFloat(cs.marginBottom) || 0);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check if pagination element is present and visible
|
|
127
|
+
const pagyEl =
|
|
128
|
+
pageEl?.querySelector<HTMLElement>(
|
|
129
|
+
'.alpha-academic-pagy, .slidev-page-nav, [aria-label="Slide pagination"]',
|
|
130
|
+
) ||
|
|
131
|
+
slideEl?.querySelector<HTMLElement>(
|
|
132
|
+
'.alpha-academic-pagy, .slidev-page-nav, [aria-label="Slide pagination"]',
|
|
133
|
+
) ||
|
|
134
|
+
(typeof document !== 'undefined'
|
|
135
|
+
? document.querySelector<HTMLElement>(
|
|
136
|
+
'.alpha-academic-pagy, .slidev-page-nav',
|
|
137
|
+
)
|
|
138
|
+
: null);
|
|
139
|
+
const isPagyVisible =
|
|
140
|
+
pagyEl && window.getComputedStyle(pagyEl).display !== 'none';
|
|
141
|
+
const clearance = isPagyVisible ? pagyClearance : 16;
|
|
142
|
+
|
|
143
|
+
if (parent.clientHeight > 0 && parent !== slideEl) {
|
|
144
|
+
availH = Math.max(
|
|
145
|
+
0,
|
|
146
|
+
parent.clientHeight - padTop - padBottom - siblingsH - clearance,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (availH <= 0 && slideEl && slideEl.clientHeight > 0) {
|
|
151
|
+
const slideStyle = window.getComputedStyle(slideEl);
|
|
152
|
+
const sPadTop = Number.parseFloat(slideStyle.paddingTop) || 0;
|
|
153
|
+
const sPadBottom = Number.parseFloat(slideStyle.paddingBottom) || 0;
|
|
154
|
+
|
|
155
|
+
let slideSiblingsH = siblingsH;
|
|
156
|
+
|
|
157
|
+
if (parent !== slideEl) {
|
|
158
|
+
for (let i = 0; i < slideEl.children.length; i++) {
|
|
159
|
+
const child = slideEl.children[i];
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
child &&
|
|
163
|
+
child !== parent &&
|
|
164
|
+
!child.contains(parent) &&
|
|
165
|
+
child instanceof HTMLElement
|
|
166
|
+
) {
|
|
167
|
+
slideSiblingsH += child.offsetHeight;
|
|
168
|
+
const cs = window.getComputedStyle(child);
|
|
169
|
+
slideSiblingsH +=
|
|
170
|
+
(Number.parseFloat(cs.marginTop) || 0) +
|
|
171
|
+
(Number.parseFloat(cs.marginBottom) || 0);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
availH = Math.max(
|
|
177
|
+
0,
|
|
178
|
+
slideEl.clientHeight -
|
|
179
|
+
sPadTop -
|
|
180
|
+
sPadBottom -
|
|
181
|
+
slideSiblingsH -
|
|
182
|
+
clearance,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (availH > 0 && Math.abs(availH - containerHeight.value) > 1) {
|
|
188
|
+
containerHeight.value = Math.round(availH);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (availW <= 0) {
|
|
192
|
+
availW = baseWidth;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let targetScale = 1;
|
|
196
|
+
|
|
197
|
+
if (availW > 0 && availH > 0) {
|
|
198
|
+
const scaleX = availW / baseWidth;
|
|
199
|
+
const scaleY = availH / baseHeight;
|
|
200
|
+
targetScale = Math.min(scaleX, scaleY);
|
|
201
|
+
} else if (availW > 0) {
|
|
202
|
+
targetScale = availW / baseWidth;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const maxScaleProp = resolveValue(options.maxScale, undefined);
|
|
206
|
+
|
|
207
|
+
if (maxScaleProp !== undefined) {
|
|
208
|
+
targetScale = Math.min(targetScale, maxScaleProp);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
targetScale = Math.round(targetScale * 1000) / 1000;
|
|
212
|
+
|
|
213
|
+
if (Math.abs(targetScale - autoScaleValue.value) > 0.005) {
|
|
214
|
+
autoScaleValue.value = targetScale;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
let observer: ResizeObserver | null = null;
|
|
219
|
+
|
|
220
|
+
onMounted(() => {
|
|
221
|
+
if (typeof window === 'undefined' || !rootRef.value) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
updateScale();
|
|
226
|
+
requestAnimationFrame(() => {
|
|
227
|
+
updateScale();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
231
|
+
observer = new ResizeObserver(() => {
|
|
232
|
+
updateScale();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
observer.observe(rootRef.value);
|
|
236
|
+
|
|
237
|
+
if (rootRef.value.parentElement) {
|
|
238
|
+
observer.observe(rootRef.value.parentElement);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const pageEl = rootRef.value.closest<HTMLElement>(
|
|
242
|
+
'.slidev-page, [data-slidev-page], .slidev-slide-content',
|
|
243
|
+
);
|
|
244
|
+
const layoutEl = rootRef.value.closest<HTMLElement>('.slidev-layout');
|
|
245
|
+
const slideEl = pageEl || layoutEl;
|
|
246
|
+
|
|
247
|
+
if (slideEl && slideEl !== rootRef.value.parentElement) {
|
|
248
|
+
observer.observe(slideEl);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (
|
|
252
|
+
pageEl &&
|
|
253
|
+
pageEl !== slideEl &&
|
|
254
|
+
pageEl !== rootRef.value.parentElement
|
|
255
|
+
) {
|
|
256
|
+
observer.observe(pageEl);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
window.addEventListener('resize', updateScale);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
onUnmounted(() => {
|
|
264
|
+
if (observer) {
|
|
265
|
+
observer.disconnect();
|
|
266
|
+
observer = null;
|
|
267
|
+
} else if (typeof window !== 'undefined') {
|
|
268
|
+
window.removeEventListener('resize', updateScale);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const resolvedScale = computed((): number => {
|
|
273
|
+
const scaleProp = resolveValue(options.scale, undefined);
|
|
274
|
+
|
|
275
|
+
if (scaleProp !== undefined) {
|
|
276
|
+
return scaleProp;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const autoScaleProp = resolveValue(options.autoScale, true);
|
|
280
|
+
|
|
281
|
+
if (autoScaleProp === false) {
|
|
282
|
+
return 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const maxScaleProp = resolveValue(options.maxScale, undefined);
|
|
286
|
+
|
|
287
|
+
if (maxScaleProp !== undefined) {
|
|
288
|
+
return Math.min(autoScaleValue.value, maxScaleProp);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return autoScaleValue.value;
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
resolvedScale,
|
|
296
|
+
autoScaleValue,
|
|
297
|
+
containerHeight,
|
|
298
|
+
updateScale,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type TVertCardBadgeVariant = 'outside' | 'inside' | 'none' | 'hidden';
|
|
4
|
+
|
|
5
|
+
export interface IVertCardContext {
|
|
6
|
+
readonly color: ComputedRef<string>;
|
|
7
|
+
readonly cardBg: ComputedRef<string>;
|
|
8
|
+
readonly lightColor: ComputedRef<string>;
|
|
9
|
+
readonly titleColor: ComputedRef<string>;
|
|
10
|
+
readonly stripeColor: ComputedRef<string>;
|
|
11
|
+
readonly hasDivider?: ComputedRef<boolean>;
|
|
12
|
+
readonly step: ComputedRef<string | number>;
|
|
13
|
+
readonly textColor: ComputedRef<string | undefined>;
|
|
14
|
+
readonly badgeVariant: ComputedRef<TVertCardBadgeVariant>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const VERT_CARD_KEY: InjectionKey<IVertCardContext> =
|
|
18
|
+
Symbol('VERT_CARD');
|