@papernote/ui 1.11.5 → 1.11.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/dist/components/FunnelChart.d.ts +3 -1
- package/dist/components/FunnelChart.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +55 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +55 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FunnelChart.tsx +27 -15
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ export interface FunnelChartProps {
|
|
|
20
20
|
height?: number;
|
|
21
21
|
/** Whether to show conversion rates between stages */
|
|
22
22
|
showConversion?: boolean;
|
|
23
|
+
/** Label size preset — controls stage name, value, count, and conversion text */
|
|
24
|
+
labelSize?: 'sm' | 'md' | 'lg';
|
|
23
25
|
/** Click handler for a stage */
|
|
24
26
|
onStageClick?: (stageName: string) => void;
|
|
25
27
|
/** Additional className */
|
|
@@ -40,6 +42,16 @@ const defaultColors = [
|
|
|
40
42
|
'#f3e8ff', // purple ultra light
|
|
41
43
|
];
|
|
42
44
|
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// Label Size Presets
|
|
47
|
+
// =============================================================================
|
|
48
|
+
|
|
49
|
+
const labelSizes = {
|
|
50
|
+
sm: { name: '9px', value: '8px', count: '10px', conversion: '8px' },
|
|
51
|
+
md: { name: '11px', value: '10px', count: '12px', conversion: '10px' },
|
|
52
|
+
lg: { name: '13px', value: '12px', count: '14px', conversion: '12px' },
|
|
53
|
+
} as const;
|
|
54
|
+
|
|
43
55
|
// =============================================================================
|
|
44
56
|
// Component
|
|
45
57
|
// =============================================================================
|
|
@@ -55,11 +67,13 @@ export default function FunnelChart({
|
|
|
55
67
|
stages,
|
|
56
68
|
height = 300,
|
|
57
69
|
showConversion = true,
|
|
70
|
+
labelSize = 'md',
|
|
58
71
|
onStageClick,
|
|
59
72
|
className = '',
|
|
60
73
|
}: FunnelChartProps) {
|
|
61
74
|
if (stages.length === 0) return null;
|
|
62
75
|
|
|
76
|
+
const sizes = labelSizes[labelSize];
|
|
63
77
|
const maxCount = Math.max(...stages.map(s => s.count), 1);
|
|
64
78
|
const stageHeight = height / stages.length;
|
|
65
79
|
const svgWidth = 450;
|
|
@@ -115,8 +129,8 @@ export default function FunnelChart({
|
|
|
115
129
|
y={y + stageHeight / 2 + 1}
|
|
116
130
|
textAnchor="middle"
|
|
117
131
|
dominantBaseline="middle"
|
|
118
|
-
className="fill-white
|
|
119
|
-
style={{ fontSize:
|
|
132
|
+
className="fill-white font-bold"
|
|
133
|
+
style={{ fontSize: sizes.count }}
|
|
120
134
|
>
|
|
121
135
|
{stage.count.toLocaleString()}
|
|
122
136
|
</text>
|
|
@@ -126,7 +140,7 @@ export default function FunnelChart({
|
|
|
126
140
|
x={centerX + funnelWidth / 2 + 12}
|
|
127
141
|
y={y + stageHeight / 2 - 4}
|
|
128
142
|
className="fill-ink-700 dark:fill-ink-300"
|
|
129
|
-
style={{ fontSize:
|
|
143
|
+
style={{ fontSize: sizes.name, fontWeight: 500 }}
|
|
130
144
|
>
|
|
131
145
|
{stage.name}
|
|
132
146
|
</text>
|
|
@@ -135,7 +149,7 @@ export default function FunnelChart({
|
|
|
135
149
|
x={centerX + funnelWidth / 2 + 12}
|
|
136
150
|
y={y + stageHeight / 2 + 7}
|
|
137
151
|
className="fill-ink-400"
|
|
138
|
-
style={{ fontSize:
|
|
152
|
+
style={{ fontSize: sizes.value }}
|
|
139
153
|
>
|
|
140
154
|
{stage.value}
|
|
141
155
|
</text>
|
|
@@ -143,17 +157,15 @@ export default function FunnelChart({
|
|
|
143
157
|
|
|
144
158
|
{/* Conversion rate on left — shows stage-to-stage conversion */}
|
|
145
159
|
{showConversion && conversionRate !== null && (
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</text>
|
|
156
|
-
</g>
|
|
160
|
+
<text
|
|
161
|
+
x={centerX - funnelWidth / 2 - 16}
|
|
162
|
+
y={y + 4}
|
|
163
|
+
textAnchor="end"
|
|
164
|
+
className="fill-ink-500"
|
|
165
|
+
style={{ fontSize: sizes.conversion, fontWeight: 500 }}
|
|
166
|
+
>
|
|
167
|
+
↓ {conversionRate}%
|
|
168
|
+
</text>
|
|
157
169
|
)}
|
|
158
170
|
</g>
|
|
159
171
|
);
|