@alphacifer/slidev-addon-theme 0.0.5 → 0.0.7
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 +163 -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/comparison-table/ComparisonTable.vue +244 -0
- package/components/comparison-table/ComparisonTableCell.vue +88 -0
- package/components/comparison-table/ComparisonTableCol.vue +97 -0
- package/components/comparison-table/ComparisonTableCols.vue +74 -0
- package/components/comparison-table/ComparisonTableRow.vue +92 -0
- package/components/comparison-table/ComparisonTableRows.vue +21 -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 +2 -2
- 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/comparisonTable/constants.ts +72 -0
- package/utils/comparisonTable/context.ts +24 -0
- package/utils/comparisonTable/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,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { CHEVRON_CARD_KEY } from '../../utils/chevronCard';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'ChevronCardBadge',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export interface IChevronCardBadgeProps {
|
|
11
|
+
readonly step?: string | number;
|
|
12
|
+
readonly icon?: string | object;
|
|
13
|
+
readonly color?: string;
|
|
14
|
+
readonly width?: number;
|
|
15
|
+
readonly height?: number | string;
|
|
16
|
+
readonly notchDepth?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<IChevronCardBadgeProps>(), {
|
|
20
|
+
step: undefined,
|
|
21
|
+
icon: undefined,
|
|
22
|
+
color: undefined,
|
|
23
|
+
width: 130,
|
|
24
|
+
height: undefined,
|
|
25
|
+
notchDepth: 26,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const cardContext = inject(CHEVRON_CARD_KEY, undefined);
|
|
29
|
+
|
|
30
|
+
const resolvedColor = computed(() => {
|
|
31
|
+
return props.color ?? cardContext?.color.value ?? '#f59e0b';
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const resolvedStep = computed(() => {
|
|
35
|
+
return props.step ?? cardContext?.step.value ?? '01';
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<div
|
|
41
|
+
class="alpha-chevron-card-badge relative select-none flex-shrink-0 flex items-center justify-center text-white"
|
|
42
|
+
:style="{
|
|
43
|
+
width: `${props.width}px`,
|
|
44
|
+
height: props.height
|
|
45
|
+
? typeof props.height === 'number'
|
|
46
|
+
? `${props.height}px`
|
|
47
|
+
: props.height
|
|
48
|
+
: '100%',
|
|
49
|
+
backgroundColor: resolvedColor,
|
|
50
|
+
clipPath: `polygon(0% 0%, calc(100% - ${props.notchDepth}px) 0%, 100% 50%, calc(100% - ${props.notchDepth}px) 100%, 0% 100%, ${props.notchDepth}px 50%)`,
|
|
51
|
+
}"
|
|
52
|
+
>
|
|
53
|
+
<slot name="icon">
|
|
54
|
+
<slot>
|
|
55
|
+
<component
|
|
56
|
+
:is="props.icon"
|
|
57
|
+
v-if="typeof props.icon === 'object'"
|
|
58
|
+
class="w-8 h-8 text-white"
|
|
59
|
+
/>
|
|
60
|
+
<span
|
|
61
|
+
v-else-if="typeof props.icon === 'string'"
|
|
62
|
+
:class="[props.icon, 'text-3xl text-white inline-block']"
|
|
63
|
+
/>
|
|
64
|
+
<span
|
|
65
|
+
v-else
|
|
66
|
+
class="font-extrabold text-[32px] tracking-tight font-sans select-none"
|
|
67
|
+
style="font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;"
|
|
68
|
+
>
|
|
69
|
+
{{ resolvedStep }}
|
|
70
|
+
</span>
|
|
71
|
+
</slot>
|
|
72
|
+
</slot>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { CHEVRON_CARD_KEY } from '../../utils/chevronCard';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'ChevronCardContent',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export interface IChevronCardContentProps {
|
|
11
|
+
readonly color?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<IChevronCardContentProps>(), {
|
|
15
|
+
color: undefined,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const cardContext = inject(CHEVRON_CARD_KEY, undefined);
|
|
19
|
+
|
|
20
|
+
const contentColor = computed(() => {
|
|
21
|
+
return props.color ?? cardContext?.textColor.value ?? '#6b7280';
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div
|
|
27
|
+
class="alpha-chevron-card-content text-[1rem] leading-[1.45] font-normal tracking-tight select-none font-sans"
|
|
28
|
+
:style="{
|
|
29
|
+
color: contentColor,
|
|
30
|
+
margin: 0,
|
|
31
|
+
padding: 0,
|
|
32
|
+
fontSize: '1rem',
|
|
33
|
+
fontFamily:
|
|
34
|
+
'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif',
|
|
35
|
+
}"
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { CHEVRON_CARD_KEY } from '../../utils/chevronCard';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'ChevronCardHeading',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export interface IChevronCardHeadingProps {
|
|
11
|
+
readonly color?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<IChevronCardHeadingProps>(), {
|
|
15
|
+
color: undefined,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const cardContext = inject(CHEVRON_CARD_KEY, undefined);
|
|
19
|
+
|
|
20
|
+
const headingColor = computed(() => {
|
|
21
|
+
return props.color ?? cardContext?.titleColor.value ?? '#4b5563';
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div
|
|
27
|
+
class="alpha-chevron-card-heading font-bold text-[1.25rem] uppercase tracking-wider leading-tight select-none font-sans"
|
|
28
|
+
:style="{
|
|
29
|
+
color: headingColor,
|
|
30
|
+
padding: 0,
|
|
31
|
+
fontSize: '1.25rem',
|
|
32
|
+
fontFamily:
|
|
33
|
+
'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif',
|
|
34
|
+
marginBottom: '0.25rem',
|
|
35
|
+
}"
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
type ComputedRef,
|
|
4
|
+
computed,
|
|
5
|
+
Fragment,
|
|
6
|
+
inject,
|
|
7
|
+
provide,
|
|
8
|
+
useSlots,
|
|
9
|
+
type VNode,
|
|
10
|
+
} from 'vue';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
COMPARISON_TABLE_KEY,
|
|
14
|
+
DEFAULT_BORDER_RADIUS,
|
|
15
|
+
DEFAULT_CELL_BG,
|
|
16
|
+
DEFAULT_CELL_COLOR,
|
|
17
|
+
DEFAULT_COL_HEADER_TEXT_COLOR,
|
|
18
|
+
DEFAULT_MOCKUP_COLS,
|
|
19
|
+
DEFAULT_MOCKUP_ROWS,
|
|
20
|
+
DEFAULT_ROW_HEADER_COLOR,
|
|
21
|
+
DEFAULT_ROW_HEADER_TEXT_COLOR,
|
|
22
|
+
DEFAULT_ROW_HEADER_WIDTH,
|
|
23
|
+
DEFAULT_SPACING,
|
|
24
|
+
type IComparisonTableContext,
|
|
25
|
+
resolveDimension,
|
|
26
|
+
} from '../../utils/comparisonTable';
|
|
27
|
+
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
28
|
+
import ComparisonTableCell from './ComparisonTableCell.vue';
|
|
29
|
+
import ComparisonTableCol from './ComparisonTableCol.vue';
|
|
30
|
+
import ComparisonTableCols from './ComparisonTableCols.vue';
|
|
31
|
+
import ComparisonTableRow from './ComparisonTableRow.vue';
|
|
32
|
+
import ComparisonTableRows from './ComparisonTableRows.vue';
|
|
33
|
+
|
|
34
|
+
defineOptions({
|
|
35
|
+
inheritAttrs: false,
|
|
36
|
+
name: 'ComparisonTable',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export interface IComparisonTableProps {
|
|
40
|
+
readonly cellBg?: string;
|
|
41
|
+
readonly cellColor?: string;
|
|
42
|
+
readonly rowHeaderColor?: string;
|
|
43
|
+
readonly rowHeaderTextColor?: string;
|
|
44
|
+
readonly colHeaderTextColor?: string;
|
|
45
|
+
readonly borderRadius?: number | string;
|
|
46
|
+
readonly rowHeaderWidth?: number | string;
|
|
47
|
+
readonly spacing?: number | string;
|
|
48
|
+
readonly tableLayout?: 'fixed' | 'auto';
|
|
49
|
+
readonly dense?: boolean;
|
|
50
|
+
readonly animation?: boolean;
|
|
51
|
+
readonly active?: boolean;
|
|
52
|
+
readonly width?: number | string;
|
|
53
|
+
readonly height?: number | string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const props = withDefaults(defineProps<IComparisonTableProps>(), {
|
|
57
|
+
cellBg: DEFAULT_CELL_BG,
|
|
58
|
+
cellColor: DEFAULT_CELL_COLOR,
|
|
59
|
+
rowHeaderColor: DEFAULT_ROW_HEADER_COLOR,
|
|
60
|
+
rowHeaderTextColor: DEFAULT_ROW_HEADER_TEXT_COLOR,
|
|
61
|
+
colHeaderTextColor: DEFAULT_COL_HEADER_TEXT_COLOR,
|
|
62
|
+
borderRadius: DEFAULT_BORDER_RADIUS,
|
|
63
|
+
rowHeaderWidth: DEFAULT_ROW_HEADER_WIDTH,
|
|
64
|
+
spacing: DEFAULT_SPACING,
|
|
65
|
+
tableLayout: 'fixed',
|
|
66
|
+
dense: false,
|
|
67
|
+
animation: true,
|
|
68
|
+
active: undefined,
|
|
69
|
+
width: '100%',
|
|
70
|
+
height: undefined,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const slots = useSlots();
|
|
74
|
+
|
|
75
|
+
const shiftingIntro = inject<
|
|
76
|
+
| {
|
|
77
|
+
active: ComputedRef<boolean>;
|
|
78
|
+
isShifting?: ComputedRef<boolean>;
|
|
79
|
+
}
|
|
80
|
+
| undefined
|
|
81
|
+
>('SLIDEV_LAYOUT_SHIFTING_INTRO', undefined);
|
|
82
|
+
|
|
83
|
+
const isAnimated = computed(() => {
|
|
84
|
+
if (!props.animation) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (props.active !== undefined) {
|
|
89
|
+
return props.active;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (shiftingIntro) {
|
|
93
|
+
return shiftingIntro.active.value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const resolvedBorderRadius = computed(() => {
|
|
100
|
+
return resolveDimension(props.borderRadius) ?? DEFAULT_BORDER_RADIUS;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const resolvedRowHeaderWidth = computed(() => {
|
|
104
|
+
return resolveDimension(props.rowHeaderWidth) ?? DEFAULT_ROW_HEADER_WIDTH;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const resolvedSpacing = computed(() => {
|
|
108
|
+
return resolveDimension(props.spacing) ?? DEFAULT_SPACING;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const resolvedWidth = computed(() => {
|
|
112
|
+
return resolveDimension(props.width) ?? '100%';
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const resolvedHeight = computed(() => {
|
|
116
|
+
return resolveDimension(props.height);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
provide<IComparisonTableContext>(COMPARISON_TABLE_KEY, {
|
|
120
|
+
cellBg: computed(() => props.cellBg),
|
|
121
|
+
cellColor: computed(() => props.cellColor),
|
|
122
|
+
rowHeaderColor: computed(() => props.rowHeaderColor),
|
|
123
|
+
rowHeaderTextColor: computed(() => props.rowHeaderTextColor),
|
|
124
|
+
colHeaderTextColor: computed(() => props.colHeaderTextColor),
|
|
125
|
+
borderRadius: resolvedBorderRadius,
|
|
126
|
+
rowHeaderWidth: resolvedRowHeaderWidth,
|
|
127
|
+
spacing: resolvedSpacing,
|
|
128
|
+
dense: computed(() => props.dense),
|
|
129
|
+
animation: isAnimated,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
function isSignificantNode(node: VNode): boolean {
|
|
133
|
+
if (typeof node.type === 'symbol') {
|
|
134
|
+
if (typeof node.children === 'string' && !node.children.trim()) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (typeof node.children === 'string' && !node.children.trim()) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function flattenVNodes(nodes: VNode[]): VNode[] {
|
|
147
|
+
const result: VNode[] = [];
|
|
148
|
+
|
|
149
|
+
for (const node of nodes) {
|
|
150
|
+
if (node.type === Fragment && Array.isArray(node.children)) {
|
|
151
|
+
result.push(...flattenVNodes(node.children as VNode[]));
|
|
152
|
+
} else if (isSignificantNode(node)) {
|
|
153
|
+
result.push(node);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const defaultNodes = computed(() => {
|
|
161
|
+
if (!slots.default) {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return flattenVNodes(slots.default());
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const hasCustomContent = computed(() => {
|
|
169
|
+
return defaultNodes.value.length > 0;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const tableStyle = computed(() => {
|
|
173
|
+
return {
|
|
174
|
+
width: resolvedWidth.value,
|
|
175
|
+
height: resolvedHeight.value,
|
|
176
|
+
borderCollapse: 'separate' as const,
|
|
177
|
+
borderSpacing: resolvedSpacing.value,
|
|
178
|
+
tableLayout: props.tableLayout,
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
183
|
+
'alpha-comparison-table w-full select-text font-sans relative my-auto',
|
|
184
|
+
);
|
|
185
|
+
</script>
|
|
186
|
+
|
|
187
|
+
<template>
|
|
188
|
+
<div class="alpha-comparison-table-wrapper w-full flex items-center justify-center overflow-x-auto">
|
|
189
|
+
<table
|
|
190
|
+
v-bind="forwardedAttrs()"
|
|
191
|
+
:class="[
|
|
192
|
+
className(),
|
|
193
|
+
{ 'alpha-comparison-table--animated': isAnimated },
|
|
194
|
+
]"
|
|
195
|
+
:style="tableStyle"
|
|
196
|
+
>
|
|
197
|
+
<template v-if="hasCustomContent">
|
|
198
|
+
<slot />
|
|
199
|
+
</template>
|
|
200
|
+
<template v-else>
|
|
201
|
+
<ComparisonTableCols>
|
|
202
|
+
<ComparisonTableCol
|
|
203
|
+
v-for="col in DEFAULT_MOCKUP_COLS"
|
|
204
|
+
:key="col.title"
|
|
205
|
+
:color="col.color"
|
|
206
|
+
>
|
|
207
|
+
{{ col.title }}
|
|
208
|
+
</ComparisonTableCol>
|
|
209
|
+
</ComparisonTableCols>
|
|
210
|
+
<ComparisonTableRows>
|
|
211
|
+
<ComparisonTableRow
|
|
212
|
+
v-for="row in DEFAULT_MOCKUP_ROWS"
|
|
213
|
+
:key="row.title"
|
|
214
|
+
:title="row.title"
|
|
215
|
+
>
|
|
216
|
+
<ComparisonTableCell
|
|
217
|
+
v-for="(cellText, idx) in row.cells"
|
|
218
|
+
:key="idx"
|
|
219
|
+
>
|
|
220
|
+
{{ cellText }}
|
|
221
|
+
</ComparisonTableCell>
|
|
222
|
+
</ComparisonTableRow>
|
|
223
|
+
</ComparisonTableRows>
|
|
224
|
+
</template>
|
|
225
|
+
</table>
|
|
226
|
+
</div>
|
|
227
|
+
</template>
|
|
228
|
+
|
|
229
|
+
<style scoped>
|
|
230
|
+
.alpha-comparison-table--animated {
|
|
231
|
+
animation: alpha-table-appear 0.35s ease-out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@keyframes alpha-table-appear {
|
|
235
|
+
from {
|
|
236
|
+
opacity: 0;
|
|
237
|
+
transform: translateY(4px);
|
|
238
|
+
}
|
|
239
|
+
to {
|
|
240
|
+
opacity: 1;
|
|
241
|
+
transform: translateY(0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
</style>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
COMPARISON_TABLE_KEY,
|
|
6
|
+
DEFAULT_CELL_BG,
|
|
7
|
+
DEFAULT_CELL_COLOR,
|
|
8
|
+
resolveDimension,
|
|
9
|
+
} from '../../utils/comparisonTable';
|
|
10
|
+
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
name: 'ComparisonTableCell',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export interface IComparisonTableCellProps {
|
|
18
|
+
readonly text?: string | number;
|
|
19
|
+
readonly color?: string;
|
|
20
|
+
readonly bg?: string;
|
|
21
|
+
readonly textColor?: string;
|
|
22
|
+
readonly borderRadius?: number | string;
|
|
23
|
+
readonly align?: 'left' | 'center' | 'right';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<IComparisonTableCellProps>(), {
|
|
27
|
+
text: undefined,
|
|
28
|
+
color: undefined,
|
|
29
|
+
bg: undefined,
|
|
30
|
+
textColor: undefined,
|
|
31
|
+
borderRadius: undefined,
|
|
32
|
+
align: 'center',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const tableContext = inject(COMPARISON_TABLE_KEY, undefined);
|
|
36
|
+
|
|
37
|
+
const resolvedBg = computed(() => {
|
|
38
|
+
return (
|
|
39
|
+
props.bg ?? props.color ?? tableContext?.cellBg.value ?? DEFAULT_CELL_BG
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const resolvedTextColor = computed(() => {
|
|
44
|
+
return props.textColor ?? tableContext?.cellColor.value ?? DEFAULT_CELL_COLOR;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const resolvedBorderRadius = computed(() => {
|
|
48
|
+
return (
|
|
49
|
+
resolveDimension(props.borderRadius) ??
|
|
50
|
+
tableContext?.borderRadius.value ??
|
|
51
|
+
'8px'
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const resolvedPadding = computed(() => {
|
|
56
|
+
return tableContext?.dense.value ? 'py-2 px-3' : 'py-3 px-4';
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const cellStyle = computed(() => {
|
|
60
|
+
return {
|
|
61
|
+
backgroundColor: resolvedBg.value,
|
|
62
|
+
color: resolvedTextColor.value,
|
|
63
|
+
borderRadius: resolvedBorderRadius.value,
|
|
64
|
+
fontSize: '1rem',
|
|
65
|
+
textAlign: props.align,
|
|
66
|
+
verticalAlign: 'middle' as const,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const { className, forwardedAttrs } = useMergedUnoAttrs(() => {
|
|
71
|
+
return `alpha-comparison-table-cell font-medium text-[1rem] leading-relaxed align-middle transition-all duration-200 select-text [&_p]:text-[1rem] [&_p]:m-0 ${resolvedPadding.value}`;
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<td
|
|
77
|
+
v-bind="forwardedAttrs()"
|
|
78
|
+
:class="[
|
|
79
|
+
className(),
|
|
80
|
+
align === 'center' ? 'text-center [&_p]:text-center' : '',
|
|
81
|
+
align === 'left' ? 'text-left [&_p]:text-left' : '',
|
|
82
|
+
align === 'right' ? 'text-right [&_p]:text-right' : '',
|
|
83
|
+
]"
|
|
84
|
+
:style="cellStyle"
|
|
85
|
+
>
|
|
86
|
+
<slot>{{ text }}</slot>
|
|
87
|
+
</td>
|
|
88
|
+
</template>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject } from 'vue';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
COMPARISON_TABLE_COLS_KEY,
|
|
6
|
+
COMPARISON_TABLE_KEY,
|
|
7
|
+
DEFAULT_COL_COLORS,
|
|
8
|
+
DEFAULT_COL_HEADER_TEXT_COLOR,
|
|
9
|
+
resolveDimension,
|
|
10
|
+
} from '../../utils/comparisonTable';
|
|
11
|
+
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
12
|
+
|
|
13
|
+
defineOptions({
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
name: 'ComparisonTableCol',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export interface IComparisonTableColProps {
|
|
19
|
+
readonly title?: string;
|
|
20
|
+
readonly color?: string;
|
|
21
|
+
readonly textColor?: string;
|
|
22
|
+
readonly width?: number | string;
|
|
23
|
+
readonly borderRadius?: number | string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<IComparisonTableColProps>(), {
|
|
27
|
+
title: undefined,
|
|
28
|
+
color: undefined,
|
|
29
|
+
textColor: undefined,
|
|
30
|
+
width: undefined,
|
|
31
|
+
borderRadius: undefined,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const tableContext = inject(COMPARISON_TABLE_KEY, undefined);
|
|
35
|
+
const colsContext = inject(COMPARISON_TABLE_COLS_KEY, undefined);
|
|
36
|
+
|
|
37
|
+
const autoIndex = colsContext?.registerCol() ?? 0;
|
|
38
|
+
|
|
39
|
+
const resolvedColor = computed(() => {
|
|
40
|
+
if (props.color) {
|
|
41
|
+
return props.color;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return DEFAULT_COL_COLORS[autoIndex % DEFAULT_COL_COLORS.length];
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const resolvedTextColor = computed(() => {
|
|
48
|
+
return (
|
|
49
|
+
props.textColor ??
|
|
50
|
+
tableContext?.colHeaderTextColor.value ??
|
|
51
|
+
DEFAULT_COL_HEADER_TEXT_COLOR
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const resolvedBorderRadius = computed(() => {
|
|
56
|
+
return (
|
|
57
|
+
resolveDimension(props.borderRadius) ??
|
|
58
|
+
tableContext?.borderRadius.value ??
|
|
59
|
+
'8px'
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const resolvedWidth = computed(() => {
|
|
64
|
+
return resolveDimension(props.width);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const resolvedPadding = computed(() => {
|
|
68
|
+
return tableContext?.dense.value ? 'py-2 px-3' : 'py-3 px-4';
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const colStyle = computed(() => {
|
|
72
|
+
return {
|
|
73
|
+
backgroundColor: resolvedColor.value,
|
|
74
|
+
color: resolvedTextColor.value,
|
|
75
|
+
borderRadius: resolvedBorderRadius.value,
|
|
76
|
+
width: resolvedWidth.value,
|
|
77
|
+
fontSize: '1rem',
|
|
78
|
+
textAlign: 'center' as const,
|
|
79
|
+
verticalAlign: 'middle' as const,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const { className, forwardedAttrs } = useMergedUnoAttrs(() => {
|
|
84
|
+
return `alpha-comparison-table-col font-bold uppercase tracking-wider text-[1rem] leading-snug text-center align-middle select-text transition-all duration-200 [&_p]:text-[1rem] [&_p]:text-center [&_p]:m-0 ${resolvedPadding.value}`;
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<th
|
|
90
|
+
scope="col"
|
|
91
|
+
v-bind="forwardedAttrs()"
|
|
92
|
+
:class="className()"
|
|
93
|
+
:style="colStyle"
|
|
94
|
+
>
|
|
95
|
+
<slot>{{ title }}</slot>
|
|
96
|
+
</th>
|
|
97
|
+
</template>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject, onBeforeUpdate, provide } from 'vue';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
COMPARISON_TABLE_COLS_KEY,
|
|
6
|
+
COMPARISON_TABLE_KEY,
|
|
7
|
+
DEFAULT_ROW_HEADER_WIDTH,
|
|
8
|
+
resolveDimension,
|
|
9
|
+
} from '../../utils/comparisonTable';
|
|
10
|
+
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
name: 'ComparisonTableCols',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export interface IComparisonTableColsProps {
|
|
18
|
+
readonly cornerWidth?: number | string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<IComparisonTableColsProps>(), {
|
|
22
|
+
cornerWidth: undefined,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const tableContext = inject(COMPARISON_TABLE_KEY, undefined);
|
|
26
|
+
|
|
27
|
+
let colCounter = 0;
|
|
28
|
+
onBeforeUpdate(() => {
|
|
29
|
+
colCounter = 0;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
provide(COMPARISON_TABLE_COLS_KEY, {
|
|
33
|
+
registerCol: () => {
|
|
34
|
+
return colCounter++;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const resolvedCornerWidth = computed(() => {
|
|
39
|
+
return (
|
|
40
|
+
resolveDimension(props.cornerWidth) ??
|
|
41
|
+
tableContext?.rowHeaderWidth.value ??
|
|
42
|
+
DEFAULT_ROW_HEADER_WIDTH
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const cornerStyle = computed(() => {
|
|
47
|
+
return {
|
|
48
|
+
width: resolvedCornerWidth.value,
|
|
49
|
+
backgroundColor: 'transparent',
|
|
50
|
+
border: 'none',
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
55
|
+
'alpha-comparison-table-cols',
|
|
56
|
+
);
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<thead
|
|
61
|
+
v-bind="forwardedAttrs()"
|
|
62
|
+
:class="className()"
|
|
63
|
+
>
|
|
64
|
+
<tr>
|
|
65
|
+
<th
|
|
66
|
+
scope="col"
|
|
67
|
+
class="alpha-comparison-table-corner p-0 bg-transparent border-none pointer-events-none select-none"
|
|
68
|
+
:style="cornerStyle"
|
|
69
|
+
aria-hidden="true"
|
|
70
|
+
/>
|
|
71
|
+
<slot />
|
|
72
|
+
</tr>
|
|
73
|
+
</thead>
|
|
74
|
+
</template>
|