@alphacifer/slidev-addon-theme 0.0.8 → 0.0.10
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 +80 -0
- package/components/defense-in-depth/arc-did/ArcDiD.vue +732 -0
- package/components/defense-in-depth/arc-did/ArcDiDLayer.vue +321 -0
- package/components/defense-in-depth/arc-did/ArcDiDLayerPart.vue +449 -0
- package/components/defense-in-depth/arc-did/ArcDiDLayerParts.vue +11 -0
- package/components/defense-in-depth/arc-did/ArcDiDLayerSector.vue +148 -0
- package/components/defense-in-depth/arc-did/ArcDiDLayerTitle.vue +98 -0
- package/components/pyramid/circular-pyramid/CircularPyramid.vue +858 -0
- package/components/pyramid/circular-pyramid/CircularPyramidStack.vue +342 -0
- package/components/pyramid/circular-pyramid/CircularPyramidStackContent.vue +305 -0
- package/components/pyramid/circular-pyramid/CircularPyramidStackTitle.vue +208 -0
- package/components/pyramid/square-pyramid/SquarePyramid.vue +863 -0
- package/components/pyramid/square-pyramid/SquarePyramidStack.vue +333 -0
- package/components/pyramid/square-pyramid/SquarePyramidStackContent.vue +301 -0
- package/components/pyramid/square-pyramid/SquarePyramidStackTitle.vue +204 -0
- package/package.json +2 -1
- package/utils/defenseInDepth/arcDid/context.ts +110 -0
- package/utils/defenseInDepth/arcDid/createArcDiDGeometry.ts +570 -0
- package/utils/defenseInDepth/arcDid/index.ts +3 -0
- package/utils/defenseInDepth/arcDid/types.ts +140 -0
- package/utils/defenseInDepth/index.ts +2 -0
- package/utils/defenseInDepth/shared/colors.ts +121 -0
- package/utils/defenseInDepth/shared/constants.ts +14 -0
- package/utils/defenseInDepth/shared/index.ts +3 -0
- package/utils/defenseInDepth/shared/types.ts +12 -0
- package/utils/pyramid/circular-pyramid/context.ts +46 -0
- package/utils/pyramid/circular-pyramid/createCircularPyramidGeometry.ts +143 -0
- package/utils/pyramid/circular-pyramid/index.ts +3 -0
- package/utils/pyramid/circular-pyramid/types.ts +34 -0
- package/utils/pyramid/index.ts +3 -0
- package/utils/pyramid/shared/colors.ts +92 -0
- package/utils/pyramid/shared/connector.ts +111 -0
- package/utils/pyramid/shared/constants.ts +9 -0
- package/utils/pyramid/shared/index.ts +5 -0
- package/utils/pyramid/shared/stacking.ts +76 -0
- package/utils/pyramid/shared/types.ts +36 -0
- package/utils/pyramid/square-pyramid/context.ts +46 -0
- package/utils/pyramid/square-pyramid/createSquarePyramidGeometry.ts +265 -0
- package/utils/pyramid/square-pyramid/index.ts +3 -0
- package/utils/pyramid/square-pyramid/types.ts +39 -0
- package/utils/useDiagramAutoScale.ts +64 -20
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface IColorModifierParams {
|
|
2
|
+
readonly hex: string;
|
|
3
|
+
readonly ratio?: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface IPyramidPalette {
|
|
7
|
+
readonly activeTopStart: string;
|
|
8
|
+
readonly activeTopEnd: string;
|
|
9
|
+
readonly activeSideStart: string;
|
|
10
|
+
readonly activeSideEnd: string;
|
|
11
|
+
readonly activeStroke: string;
|
|
12
|
+
readonly defaultTopStart: string;
|
|
13
|
+
readonly defaultTopEnd: string;
|
|
14
|
+
readonly defaultSideStart: string;
|
|
15
|
+
readonly defaultSideEnd: string;
|
|
16
|
+
readonly defaultStroke: string;
|
|
17
|
+
readonly glow: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IPyramidRegistration {
|
|
21
|
+
readonly index: number;
|
|
22
|
+
readonly unregister: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IComputePyramidStackingParams {
|
|
26
|
+
readonly count: number;
|
|
27
|
+
readonly viewBoxHeight: number;
|
|
28
|
+
readonly slabHeight: number;
|
|
29
|
+
readonly radii: readonly { readonly rx: number; readonly ry: number }[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IPyramidStackingResult {
|
|
33
|
+
readonly startCy: number;
|
|
34
|
+
readonly stepYList: readonly number[];
|
|
35
|
+
readonly actualTotalHeight: number;
|
|
36
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey, Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type { IPyramidPalette, IPyramidRegistration } from '../shared';
|
|
4
|
+
import type { ISquareLayerGeometry, ISquarePyramidGeometry } from './types';
|
|
5
|
+
|
|
6
|
+
export interface ISquarePyramidRegistration extends IPyramidRegistration {}
|
|
7
|
+
|
|
8
|
+
export interface ISquarePyramidRootContext {
|
|
9
|
+
readonly count: ComputedRef<number>;
|
|
10
|
+
readonly activeIndex: Ref<number> | ComputedRef<number>;
|
|
11
|
+
readonly color: ComputedRef<string>;
|
|
12
|
+
readonly geo: ComputedRef<ISquarePyramidGeometry>;
|
|
13
|
+
readonly palette: ComputedRef<IPyramidPalette>;
|
|
14
|
+
readonly animation: ComputedRef<boolean>;
|
|
15
|
+
readonly interactive: ComputedRef<boolean>;
|
|
16
|
+
readonly titleWidthPx: ComputedRef<number>;
|
|
17
|
+
readonly contentWidthPx: ComputedRef<number>;
|
|
18
|
+
readonly contentRightOffsetPx: ComputedRef<number>;
|
|
19
|
+
readonly registerStack: (
|
|
20
|
+
id?: symbol,
|
|
21
|
+
color?: ComputedRef<string | undefined>,
|
|
22
|
+
) => {
|
|
23
|
+
index: ComputedRef<number>;
|
|
24
|
+
unregister: () => void;
|
|
25
|
+
};
|
|
26
|
+
readonly getLayerColor: (index: number) => string;
|
|
27
|
+
readonly setActiveIndex: (index: number) => void;
|
|
28
|
+
readonly getCardDeltaY?: (index: number) => number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ISquarePyramidStackContext {
|
|
32
|
+
readonly index: ComputedRef<number>;
|
|
33
|
+
readonly isActive: ComputedRef<boolean>;
|
|
34
|
+
readonly step: ComputedRef<string | number>;
|
|
35
|
+
readonly color?: ComputedRef<string>;
|
|
36
|
+
readonly layerGeo?: ComputedRef<ISquareLayerGeometry | undefined>;
|
|
37
|
+
readonly deltaY?: ComputedRef<number>;
|
|
38
|
+
readonly connectorWidth?: ComputedRef<number>;
|
|
39
|
+
readonly setActive?: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const SQUARE_PYRAMID_ROOT_KEY: InjectionKey<ISquarePyramidRootContext> =
|
|
43
|
+
Symbol('SQUARE_PYRAMID_ROOT_KEY');
|
|
44
|
+
|
|
45
|
+
export const SQUARE_PYRAMID_STACK_KEY: InjectionKey<ISquarePyramidStackContext> =
|
|
46
|
+
Symbol('SQUARE_PYRAMID_STACK_KEY');
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clampPyramidCount,
|
|
3
|
+
computePyramidStacking,
|
|
4
|
+
DEFAULT_PYRAMID_COLOR,
|
|
5
|
+
darkenColor,
|
|
6
|
+
lightenColor,
|
|
7
|
+
MAX_PYRAMID_COUNT,
|
|
8
|
+
MIN_PYRAMID_COUNT,
|
|
9
|
+
resolvePyramidPalette,
|
|
10
|
+
} from '../shared';
|
|
11
|
+
import type {
|
|
12
|
+
ICreateSquarePyramidOptions,
|
|
13
|
+
ISquareLayerGeometry,
|
|
14
|
+
ISquarePyramidGeometry,
|
|
15
|
+
ISquarePyramidPalette,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
export const DEFAULT_SQUARE_PYRAMID_COLOR = DEFAULT_PYRAMID_COLOR;
|
|
19
|
+
export const DEFAULT_SQUARE_PYRAMID_STACK_COLORS: readonly string[] = [
|
|
20
|
+
'#ec4899', // 0: Pink (matches top slab)
|
|
21
|
+
'#8b5cf6', // 1: Purple (matches 2nd slab)
|
|
22
|
+
'#3b82f6', // 2: Blue (matches 3rd slab)
|
|
23
|
+
'#06b6d4', // 3: Cyan (matches 4th slab)
|
|
24
|
+
'#14b8a6', // 4: Teal (matches 5th slab)
|
|
25
|
+
'#f59e0b', // 5: Amber (warm accent)
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
export const MIN_SQUARE_COUNT = MIN_PYRAMID_COUNT;
|
|
29
|
+
export const MAX_SQUARE_COUNT = MAX_PYRAMID_COUNT;
|
|
30
|
+
|
|
31
|
+
export { darkenColor, lightenColor };
|
|
32
|
+
|
|
33
|
+
export function clampSquareCount(count?: number): number {
|
|
34
|
+
return clampPyramidCount(count);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolveSquarePyramidPalette(
|
|
38
|
+
baseColor: string = DEFAULT_SQUARE_PYRAMID_COLOR,
|
|
39
|
+
): ISquarePyramidPalette {
|
|
40
|
+
return resolvePyramidPalette(baseColor);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function buildSquarePaths({
|
|
44
|
+
cx,
|
|
45
|
+
cy,
|
|
46
|
+
rx,
|
|
47
|
+
ry,
|
|
48
|
+
dx,
|
|
49
|
+
dy,
|
|
50
|
+
slabHeight,
|
|
51
|
+
}: {
|
|
52
|
+
cx: number;
|
|
53
|
+
cy: number;
|
|
54
|
+
rx: number;
|
|
55
|
+
ry: number;
|
|
56
|
+
dx: number;
|
|
57
|
+
dy: number;
|
|
58
|
+
slabHeight: number;
|
|
59
|
+
}) {
|
|
60
|
+
const topFacePath = [
|
|
61
|
+
`M ${cx - dx} ${cy - ry + dy}`,
|
|
62
|
+
`Q ${cx} ${cy - ry} ${cx + dx} ${cy - ry + dy}`,
|
|
63
|
+
`L ${cx + rx - dx} ${cy - dy}`,
|
|
64
|
+
`Q ${cx + rx} ${cy} ${cx + rx - dx} ${cy + dy}`,
|
|
65
|
+
`L ${cx + dx} ${cy + ry - dy}`,
|
|
66
|
+
`Q ${cx} ${cy + ry} ${cx - dx} ${cy + ry - dy}`,
|
|
67
|
+
`L ${cx - rx + dx} ${cy + dy}`,
|
|
68
|
+
`Q ${cx - rx} ${cy} ${cx - rx + dx} ${cy - dy}`,
|
|
69
|
+
'Z',
|
|
70
|
+
].join(' ');
|
|
71
|
+
|
|
72
|
+
const innerRatio = 0.65;
|
|
73
|
+
const rxInner = Number((rx * innerRatio).toFixed(2));
|
|
74
|
+
const ryInner = Number((ry * innerRatio).toFixed(2));
|
|
75
|
+
const dxInner = Number((dx * innerRatio).toFixed(2));
|
|
76
|
+
const dyInner = Number((dy * innerRatio).toFixed(2));
|
|
77
|
+
|
|
78
|
+
const innerFacePath = [
|
|
79
|
+
`M ${cx - dxInner} ${cy - ryInner + dyInner}`,
|
|
80
|
+
`Q ${cx} ${cy - ryInner} ${cx + dxInner} ${cy - ryInner + dyInner}`,
|
|
81
|
+
`L ${cx + rxInner - dxInner} ${cy - dyInner}`,
|
|
82
|
+
`Q ${cx + rxInner} ${cy} ${cx + rxInner - dxInner} ${cy + dyInner}`,
|
|
83
|
+
`L ${cx + dxInner} ${cy + ryInner - dyInner}`,
|
|
84
|
+
`Q ${cx} ${cy + ryInner} ${cx - dxInner} ${cy + ryInner - dyInner}`,
|
|
85
|
+
`L ${cx - rxInner + dxInner} ${cy + dyInner}`,
|
|
86
|
+
`Q ${cx - rxInner} ${cy} ${cx - rxInner + dxInner} ${cy - dyInner}`,
|
|
87
|
+
'Z',
|
|
88
|
+
].join(' ');
|
|
89
|
+
|
|
90
|
+
const sidePath = [
|
|
91
|
+
`M ${cx - rx + 0.5 * dx} ${cy}`,
|
|
92
|
+
`Q ${cx - rx + 0.5 * dx} ${cy + 0.5 * dy} ${cx - rx + dx} ${cy + dy}`,
|
|
93
|
+
`L ${cx - dx} ${cy + ry - dy}`,
|
|
94
|
+
`Q ${cx} ${cy + ry} ${cx + dx} ${cy + ry - dy}`,
|
|
95
|
+
`L ${cx + rx - dx} ${cy + dy}`,
|
|
96
|
+
`Q ${cx + rx - 0.5 * dx} ${cy + 0.5 * dy} ${cx + rx - 0.5 * dx} ${cy}`,
|
|
97
|
+
`L ${cx + rx - 0.5 * dx} ${cy + slabHeight}`,
|
|
98
|
+
`Q ${cx + rx - 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx + rx - dx} ${cy + slabHeight + dy}`,
|
|
99
|
+
`L ${cx + dx} ${cy + ry + slabHeight - dy}`,
|
|
100
|
+
`Q ${cx} ${cy + ry + slabHeight} ${cx - dx} ${cy + ry + slabHeight - dy}`,
|
|
101
|
+
`L ${cx - rx + dx} ${cy + slabHeight + dy}`,
|
|
102
|
+
`Q ${cx - rx + 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx - rx + 0.5 * dx} ${cy + slabHeight}`,
|
|
103
|
+
'Z',
|
|
104
|
+
].join(' ');
|
|
105
|
+
|
|
106
|
+
const leftSidePath = [
|
|
107
|
+
`M ${cx - rx + 0.5 * dx} ${cy}`,
|
|
108
|
+
`Q ${cx - rx + 0.5 * dx} ${cy + 0.5 * dy} ${cx - rx + dx} ${cy + dy}`,
|
|
109
|
+
`L ${cx - dx} ${cy + ry - dy}`,
|
|
110
|
+
`Q ${cx} ${cy + ry} ${cx} ${cy + ry - 0.5 * dy}`,
|
|
111
|
+
`L ${cx} ${cy + ry + slabHeight - 0.5 * dy}`,
|
|
112
|
+
`Q ${cx} ${cy + ry + slabHeight} ${cx - dx} ${cy + ry + slabHeight - dy}`,
|
|
113
|
+
`L ${cx - rx + dx} ${cy + slabHeight + dy}`,
|
|
114
|
+
`Q ${cx - rx + 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx - rx + 0.5 * dx} ${cy + slabHeight}`,
|
|
115
|
+
'Z',
|
|
116
|
+
].join(' ');
|
|
117
|
+
|
|
118
|
+
const rightSidePath = [
|
|
119
|
+
`M ${cx} ${cy + ry - 0.5 * dy}`,
|
|
120
|
+
`Q ${cx} ${cy + ry} ${cx + dx} ${cy + ry - dy}`,
|
|
121
|
+
`L ${cx + rx - dx} ${cy + dy}`,
|
|
122
|
+
`Q ${cx + rx - 0.5 * dx} ${cy + 0.5 * dy} ${cx + rx - 0.5 * dx} ${cy}`,
|
|
123
|
+
`L ${cx + rx - 0.5 * dx} ${cy + slabHeight}`,
|
|
124
|
+
`Q ${cx + rx - 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx + rx - dx} ${cy + slabHeight + dy}`,
|
|
125
|
+
`L ${cx + dx} ${cy + ry + slabHeight - dy}`,
|
|
126
|
+
`Q ${cx} ${cy + ry + slabHeight} ${cx} ${cy + ry + slabHeight - 0.5 * dy}`,
|
|
127
|
+
'Z',
|
|
128
|
+
].join(' ');
|
|
129
|
+
|
|
130
|
+
const bottomEdgePath = [
|
|
131
|
+
`M ${cx - rx + 0.5 * dx} ${cy + slabHeight}`,
|
|
132
|
+
`Q ${cx - rx + 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx - rx + dx} ${cy + slabHeight + dy}`,
|
|
133
|
+
`L ${cx - dx} ${cy + ry + slabHeight - dy}`,
|
|
134
|
+
`Q ${cx} ${cy + ry + slabHeight} ${cx + dx} ${cy + ry + slabHeight - dy}`,
|
|
135
|
+
`L ${cx + rx - dx} ${cy + slabHeight + dy}`,
|
|
136
|
+
`Q ${cx + rx - 0.5 * dx} ${cy + slabHeight + 0.5 * dy} ${cx + rx - 0.5 * dx} ${cy + slabHeight}`,
|
|
137
|
+
].join(' ');
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
topFacePath,
|
|
141
|
+
innerFacePath,
|
|
142
|
+
sidePath,
|
|
143
|
+
leftSidePath,
|
|
144
|
+
rightSidePath,
|
|
145
|
+
bottomEdgePath,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function createSquarePyramidGeometry(
|
|
150
|
+
options: ICreateSquarePyramidOptions = {},
|
|
151
|
+
): ISquarePyramidGeometry {
|
|
152
|
+
const viewBoxWidth = options.viewBoxWidth ?? 960;
|
|
153
|
+
const viewBoxHeight = options.viewBoxHeight ?? 440;
|
|
154
|
+
const count = clampSquareCount(options.count);
|
|
155
|
+
const ratio = options.ratio ?? 0.46;
|
|
156
|
+
const cx = options.cx ?? viewBoxWidth / 2;
|
|
157
|
+
const slabHeight = options.slabHeight ?? (count >= 5 ? 8 : 10);
|
|
158
|
+
const cornerRadiusRatio = options.cornerRadiusRatio ?? 0.16;
|
|
159
|
+
|
|
160
|
+
if (count === 1) {
|
|
161
|
+
const rx = options.topSize ?? 110;
|
|
162
|
+
const ry = Number((rx * ratio).toFixed(2));
|
|
163
|
+
const cy = Number((viewBoxHeight / 2 - slabHeight / 2).toFixed(2));
|
|
164
|
+
const cornerRadius = Number((rx * cornerRadiusRatio).toFixed(2));
|
|
165
|
+
const dx = cornerRadius;
|
|
166
|
+
const dy = Number((cornerRadius * ratio).toFixed(2));
|
|
167
|
+
|
|
168
|
+
const paths = buildSquarePaths({
|
|
169
|
+
cx,
|
|
170
|
+
cy,
|
|
171
|
+
rx,
|
|
172
|
+
ry,
|
|
173
|
+
dx,
|
|
174
|
+
dy,
|
|
175
|
+
slabHeight,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const slabCenterY = Number((cy + slabHeight / 2).toFixed(2));
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
viewBoxWidth,
|
|
182
|
+
viewBoxHeight,
|
|
183
|
+
count: 1,
|
|
184
|
+
layers: [
|
|
185
|
+
{
|
|
186
|
+
index: 0,
|
|
187
|
+
cx,
|
|
188
|
+
cy,
|
|
189
|
+
rx,
|
|
190
|
+
ry,
|
|
191
|
+
slabHeight,
|
|
192
|
+
cornerRadius,
|
|
193
|
+
slabCenterY,
|
|
194
|
+
...paths,
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const topSize =
|
|
201
|
+
options.topSize ?? (count <= 2 ? 110 : Math.max(75, 100 - (count - 3) * 7));
|
|
202
|
+
const bottomSize = options.bottomSize ?? 185;
|
|
203
|
+
|
|
204
|
+
const radii: { rx: number; ry: number }[] = [];
|
|
205
|
+
for (let i = 0; i < count; i++) {
|
|
206
|
+
const t = i / (count - 1);
|
|
207
|
+
const rx = Number((topSize + t * (bottomSize - topSize)).toFixed(2));
|
|
208
|
+
const ry = Number((rx * ratio).toFixed(2));
|
|
209
|
+
radii.push({ rx, ry });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const { startCy, stepYList } = computePyramidStacking({
|
|
213
|
+
count,
|
|
214
|
+
viewBoxHeight,
|
|
215
|
+
slabHeight,
|
|
216
|
+
radii,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const layers: ISquareLayerGeometry[] = [];
|
|
220
|
+
let currentCy = startCy;
|
|
221
|
+
|
|
222
|
+
for (let i = 0; i < count; i++) {
|
|
223
|
+
const rx = radii[i]?.rx ?? topSize;
|
|
224
|
+
const ry = radii[i]?.ry ?? topSize * ratio;
|
|
225
|
+
const cy = Number(currentCy.toFixed(2));
|
|
226
|
+
const cornerRadius = Number((rx * cornerRadiusRatio).toFixed(2));
|
|
227
|
+
const dx = cornerRadius;
|
|
228
|
+
const dy = Number((cornerRadius * ratio).toFixed(2));
|
|
229
|
+
|
|
230
|
+
const paths = buildSquarePaths({
|
|
231
|
+
cx,
|
|
232
|
+
cy,
|
|
233
|
+
rx,
|
|
234
|
+
ry,
|
|
235
|
+
dx,
|
|
236
|
+
dy,
|
|
237
|
+
slabHeight,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const slabCenterY = Number((cy + slabHeight / 2).toFixed(2));
|
|
241
|
+
|
|
242
|
+
layers.push({
|
|
243
|
+
index: i,
|
|
244
|
+
cx,
|
|
245
|
+
cy,
|
|
246
|
+
rx,
|
|
247
|
+
ry,
|
|
248
|
+
slabHeight,
|
|
249
|
+
cornerRadius,
|
|
250
|
+
slabCenterY,
|
|
251
|
+
...paths,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
if (i < count - 1) {
|
|
255
|
+
currentCy += stepYList[i] ?? 0;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
viewBoxWidth,
|
|
261
|
+
viewBoxHeight,
|
|
262
|
+
count,
|
|
263
|
+
layers,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IPyramidPalette } from '../shared';
|
|
2
|
+
|
|
3
|
+
export interface ISquareLayerGeometry {
|
|
4
|
+
readonly index: number;
|
|
5
|
+
readonly cx: number;
|
|
6
|
+
readonly cy: number;
|
|
7
|
+
readonly rx: number;
|
|
8
|
+
readonly ry: number;
|
|
9
|
+
readonly slabHeight: number;
|
|
10
|
+
readonly cornerRadius: number;
|
|
11
|
+
readonly topFacePath: string;
|
|
12
|
+
readonly innerFacePath: string;
|
|
13
|
+
readonly sidePath: string;
|
|
14
|
+
readonly leftSidePath: string;
|
|
15
|
+
readonly rightSidePath: string;
|
|
16
|
+
readonly bottomEdgePath: string;
|
|
17
|
+
readonly slabCenterY?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ISquarePyramidGeometry {
|
|
21
|
+
readonly viewBoxWidth: number;
|
|
22
|
+
readonly viewBoxHeight: number;
|
|
23
|
+
readonly count: number;
|
|
24
|
+
readonly layers: readonly ISquareLayerGeometry[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ICreateSquarePyramidOptions {
|
|
28
|
+
readonly count?: number;
|
|
29
|
+
readonly viewBoxWidth?: number;
|
|
30
|
+
readonly viewBoxHeight?: number;
|
|
31
|
+
readonly topSize?: number;
|
|
32
|
+
readonly bottomSize?: number;
|
|
33
|
+
readonly slabHeight?: number;
|
|
34
|
+
readonly ratio?: number;
|
|
35
|
+
readonly cx?: number;
|
|
36
|
+
readonly cornerRadiusRatio?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ISquarePyramidPalette extends IPyramidPalette {}
|
|
@@ -14,6 +14,9 @@ export interface IUseDiagramAutoScaleOptions {
|
|
|
14
14
|
readonly scale?: Ref<number | undefined> | (() => number | undefined);
|
|
15
15
|
readonly autoScale?: Ref<boolean | undefined> | (() => boolean | undefined);
|
|
16
16
|
readonly maxScale?: Ref<number | undefined> | (() => number | undefined);
|
|
17
|
+
readonly width?:
|
|
18
|
+
| Ref<number | string | undefined>
|
|
19
|
+
| (() => number | string | undefined);
|
|
17
20
|
readonly height?:
|
|
18
21
|
| Ref<number | string | undefined>
|
|
19
22
|
| (() => number | string | undefined);
|
|
@@ -94,6 +97,19 @@ export function useDiagramAutoScale(
|
|
|
94
97
|
availW = el.clientWidth;
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
const explicitWidth = resolveValue(options.width, undefined);
|
|
101
|
+
if (typeof explicitWidth === 'number' && explicitWidth > 0) {
|
|
102
|
+
availW = availW > 0 ? Math.min(availW, explicitWidth) : explicitWidth;
|
|
103
|
+
} else if (
|
|
104
|
+
typeof explicitWidth === 'string' &&
|
|
105
|
+
explicitWidth.endsWith('px')
|
|
106
|
+
) {
|
|
107
|
+
const parsedW = Number.parseFloat(explicitWidth);
|
|
108
|
+
if (parsedW > 0) {
|
|
109
|
+
availW = availW > 0 ? Math.min(availW, parsedW) : parsedW;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
97
113
|
// Available height inside parent or slide layout
|
|
98
114
|
let availH = 0;
|
|
99
115
|
const explicitHeight = resolveValue(options.height, undefined);
|
|
@@ -140,14 +156,26 @@ export function useDiagramAutoScale(
|
|
|
140
156
|
pagyEl && window.getComputedStyle(pagyEl).display !== 'none';
|
|
141
157
|
const clearance = isPagyVisible ? pagyClearance : 16;
|
|
142
158
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
159
|
+
// Check for internal component header inside el (e.g. ArcDiD, GearTriad, HexTriad)
|
|
160
|
+
let internalHeaderH = 0;
|
|
161
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
162
|
+
const child = el.children[i];
|
|
163
|
+
if (
|
|
164
|
+
child instanceof HTMLElement &&
|
|
165
|
+
(child.tagName === 'HEADER' ||
|
|
166
|
+
child.classList.contains('alpha-arc-did__header') ||
|
|
167
|
+
child.classList.contains('alpha-gear-triad__header') ||
|
|
168
|
+
child.classList.contains('alpha-hex-triad__header'))
|
|
169
|
+
) {
|
|
170
|
+
internalHeaderH += child.offsetHeight;
|
|
171
|
+
const cs = window.getComputedStyle(child);
|
|
172
|
+
internalHeaderH +=
|
|
173
|
+
(Number.parseFloat(cs.marginTop) || 0) +
|
|
174
|
+
(Number.parseFloat(cs.marginBottom) || 0);
|
|
175
|
+
}
|
|
148
176
|
}
|
|
149
177
|
|
|
150
|
-
if (
|
|
178
|
+
if (slideEl && slideEl.clientHeight > 0) {
|
|
151
179
|
const slideStyle = window.getComputedStyle(slideEl);
|
|
152
180
|
const sPadTop = Number.parseFloat(slideStyle.paddingTop) || 0;
|
|
153
181
|
const sPadBottom = Number.parseFloat(slideStyle.paddingBottom) || 0;
|
|
@@ -155,21 +183,26 @@ export function useDiagramAutoScale(
|
|
|
155
183
|
let slideSiblingsH = siblingsH;
|
|
156
184
|
|
|
157
185
|
if (parent !== slideEl) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
child
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
186
|
+
let curr: HTMLElement | null = parent;
|
|
187
|
+
while (curr && curr !== slideEl && curr.parentElement) {
|
|
188
|
+
const p: HTMLElement = curr.parentElement;
|
|
189
|
+
for (let i = 0; i < p.children.length; i++) {
|
|
190
|
+
const child = p.children[i];
|
|
191
|
+
if (
|
|
192
|
+
child &&
|
|
193
|
+
child !== curr &&
|
|
194
|
+
!child.contains(curr) &&
|
|
195
|
+
child instanceof HTMLElement
|
|
196
|
+
) {
|
|
197
|
+
slideSiblingsH += child.offsetHeight;
|
|
198
|
+
const cs = window.getComputedStyle(child);
|
|
199
|
+
slideSiblingsH +=
|
|
200
|
+
(Number.parseFloat(cs.marginTop) || 0) +
|
|
201
|
+
(Number.parseFloat(cs.marginBottom) || 0);
|
|
202
|
+
}
|
|
172
203
|
}
|
|
204
|
+
if (p === slideEl) break;
|
|
205
|
+
curr = p;
|
|
173
206
|
}
|
|
174
207
|
}
|
|
175
208
|
|
|
@@ -179,6 +212,17 @@ export function useDiagramAutoScale(
|
|
|
179
212
|
sPadTop -
|
|
180
213
|
sPadBottom -
|
|
181
214
|
slideSiblingsH -
|
|
215
|
+
internalHeaderH -
|
|
216
|
+
clearance,
|
|
217
|
+
);
|
|
218
|
+
} else if (parent.clientHeight > 0) {
|
|
219
|
+
availH = Math.max(
|
|
220
|
+
0,
|
|
221
|
+
parent.clientHeight -
|
|
222
|
+
padTop -
|
|
223
|
+
padBottom -
|
|
224
|
+
siblingsH -
|
|
225
|
+
internalHeaderH -
|
|
182
226
|
clearance,
|
|
183
227
|
);
|
|
184
228
|
}
|