astro-component-kit 0.1.0 → 0.2.2
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/package.json +19 -7
- package/src/components/index.ts +3 -0
- package/src/components/lib/Galaxy3D.astro +1 -1
- package/src/components/lib/charts/AreaChart.astro +210 -0
- package/src/components/lib/charts/BarChart.astro +190 -0
- package/src/components/lib/charts/DonutChart.astro +177 -0
- package/src/components/lib/charts/index.ts +3 -0
- package/src/components/lib/sections/index.ts +6 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-component-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A premium, open-source accessible UI component library for Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/components/index.ts",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"./overlays": "./src/components/lib/overlays/index.ts",
|
|
19
19
|
"./typography": "./src/components/lib/typography/index.ts",
|
|
20
20
|
"./utilities": "./src/components/lib/utilities/index.ts",
|
|
21
|
+
"./sections": "./src/components/lib/sections/index.ts",
|
|
22
|
+
"./charts": "./src/components/lib/charts/index.ts",
|
|
21
23
|
"./global.css": "./src/styles/global.css"
|
|
22
24
|
},
|
|
23
25
|
"files": [
|
|
@@ -61,7 +63,17 @@
|
|
|
61
63
|
},
|
|
62
64
|
"homepage": "https://astrocomponents.dev",
|
|
63
65
|
"peerDependencies": {
|
|
64
|
-
"
|
|
66
|
+
"apexcharts": ">=3.0.0",
|
|
67
|
+
"astro": ">=5.0.0",
|
|
68
|
+
"three": ">=0.160.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"apexcharts": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"three": {
|
|
75
|
+
"optional": true
|
|
76
|
+
}
|
|
65
77
|
},
|
|
66
78
|
"publishConfig": {
|
|
67
79
|
"access": "public"
|
|
@@ -69,13 +81,13 @@
|
|
|
69
81
|
"engines": {
|
|
70
82
|
"node": ">=22.12.0"
|
|
71
83
|
},
|
|
72
|
-
"dependencies": {
|
|
73
|
-
"astro": ">=5.0.0",
|
|
74
|
-
"three": "^0.184.0"
|
|
75
|
-
},
|
|
84
|
+
"dependencies": {},
|
|
76
85
|
"devDependencies": {
|
|
77
86
|
"@types/three": "^0.184.0",
|
|
87
|
+
"apexcharts": "^3.45.1",
|
|
88
|
+
"astro": ">=5.0.0",
|
|
78
89
|
"basic-ftp": "^5.3.0",
|
|
79
|
-
"fs-extra": "^11.3.4"
|
|
90
|
+
"fs-extra": "^11.3.4",
|
|
91
|
+
"three": "^0.184.0"
|
|
80
92
|
}
|
|
81
93
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ const { className = '' } = Astro.props;
|
|
|
30
30
|
|
|
31
31
|
<script is:inline>
|
|
32
32
|
(async function() {
|
|
33
|
-
const THREE = await import('
|
|
33
|
+
const THREE = await import('three');
|
|
34
34
|
|
|
35
35
|
const canvas = document.getElementById('galaxy-3d-canvas');
|
|
36
36
|
if (!canvas) return;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* AreaChart — A premium, smooth area chart component.
|
|
4
|
+
*/
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
categories?: any[];
|
|
9
|
+
series?: any[];
|
|
10
|
+
height?: number | string;
|
|
11
|
+
colors?: string[];
|
|
12
|
+
showGrid?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
title,
|
|
18
|
+
subtitle,
|
|
19
|
+
categories = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
20
|
+
series = [{ name: 'Data', data: [31, 40, 28, 51, 42, 109, 100] }],
|
|
21
|
+
height = 350,
|
|
22
|
+
colors = ['var(--c-accent, #b8860b)', 'var(--c-primary, #1e40af)', '#3b82f6'],
|
|
23
|
+
showGrid = true,
|
|
24
|
+
className = '',
|
|
25
|
+
} = Astro.props;
|
|
26
|
+
|
|
27
|
+
const chartConfig = {
|
|
28
|
+
categories,
|
|
29
|
+
series,
|
|
30
|
+
height,
|
|
31
|
+
colors,
|
|
32
|
+
showGrid,
|
|
33
|
+
};
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
<div class={`premium-chart-card ${className}`} data-chart-type="area" data-config={JSON.stringify(chartConfig)}>
|
|
37
|
+
{(title || subtitle) && (
|
|
38
|
+
<div class="premium-chart-card__header">
|
|
39
|
+
{title && <h3 class="premium-chart-card__title">{title}</h3>}
|
|
40
|
+
{subtitle && <p class="premium-chart-card__subtitle">{subtitle}</p>}
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
<div class="premium-chart-card__body">
|
|
44
|
+
<div class="chart-container"></div>
|
|
45
|
+
<div class="chart-fallback">Loading Chart...</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.premium-chart-card {
|
|
51
|
+
background: rgba(255, 255, 255, 0.03);
|
|
52
|
+
backdrop-filter: blur(12px);
|
|
53
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
54
|
+
border-radius: var(--r-xl, 24px);
|
|
55
|
+
padding: var(--sp-6, 24px);
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
width: 100%;
|
|
58
|
+
min-width: 300px;
|
|
59
|
+
color: white;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.premium-chart-card__header {
|
|
63
|
+
margin-bottom: var(--sp-6, 24px);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.premium-chart-card__title {
|
|
67
|
+
font-size: 1.125rem;
|
|
68
|
+
font-weight: 700;
|
|
69
|
+
color: var(--c-text-1, #ffffff);
|
|
70
|
+
margin: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.premium-chart-card__subtitle {
|
|
74
|
+
font-size: 0.875rem;
|
|
75
|
+
color: var(--c-text-2, #94a3b8);
|
|
76
|
+
margin: var(--sp-1, 4px) 0 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.premium-chart-card__body {
|
|
80
|
+
width: 100%;
|
|
81
|
+
position: relative;
|
|
82
|
+
min-height: 200px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.chart-container {
|
|
86
|
+
width: 100%;
|
|
87
|
+
position: relative;
|
|
88
|
+
z-index: 2;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.chart-fallback {
|
|
92
|
+
position: absolute;
|
|
93
|
+
inset: 0;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
font-size: 0.8rem;
|
|
98
|
+
color: var(--c-text-3, #64748b);
|
|
99
|
+
z-index: 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:global(.apexcharts-tooltip) {
|
|
103
|
+
background: rgba(15, 23, 42, 0.9) !important;
|
|
104
|
+
backdrop-filter: blur(8px) !important;
|
|
105
|
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
106
|
+
border-radius: 12px !important;
|
|
107
|
+
color: #fff !important;
|
|
108
|
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3) !important;
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
111
|
+
|
|
112
|
+
<script>
|
|
113
|
+
async function initCharts() {
|
|
114
|
+
const charts = document.querySelectorAll('.premium-chart-card[data-chart-type="area"]');
|
|
115
|
+
if (charts.length === 0) return;
|
|
116
|
+
|
|
117
|
+
// Dynamic import to handle SSR and bundling better in production
|
|
118
|
+
let ApexChartsModule;
|
|
119
|
+
try {
|
|
120
|
+
ApexChartsModule = await import('apexcharts');
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.error('ApexCharts failed to load:', e);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const ApexCharts = ApexChartsModule.default || ApexChartsModule;
|
|
127
|
+
|
|
128
|
+
charts.forEach(container => {
|
|
129
|
+
if (container.getAttribute('data-initialized')) return;
|
|
130
|
+
|
|
131
|
+
const configStr = container.getAttribute('data-config');
|
|
132
|
+
if (!configStr) return;
|
|
133
|
+
|
|
134
|
+
const config = JSON.parse(configStr);
|
|
135
|
+
const target = container.querySelector('.chart-container');
|
|
136
|
+
const fallback = container.querySelector('.chart-fallback');
|
|
137
|
+
|
|
138
|
+
if (!target) return;
|
|
139
|
+
|
|
140
|
+
const options = {
|
|
141
|
+
series: config.series,
|
|
142
|
+
chart: {
|
|
143
|
+
type: 'area',
|
|
144
|
+
height: config.height,
|
|
145
|
+
toolbar: { show: false },
|
|
146
|
+
zoom: { enabled: false },
|
|
147
|
+
background: 'transparent',
|
|
148
|
+
fontFamily: 'Inter, sans-serif',
|
|
149
|
+
animations: {
|
|
150
|
+
enabled: true,
|
|
151
|
+
easing: 'easeinout',
|
|
152
|
+
speed: 800,
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
colors: config.colors,
|
|
156
|
+
dataLabels: { enabled: false },
|
|
157
|
+
stroke: { curve: 'smooth', width: 3 },
|
|
158
|
+
fill: {
|
|
159
|
+
type: 'gradient',
|
|
160
|
+
gradient: {
|
|
161
|
+
shadeIntensity: 1,
|
|
162
|
+
opacityFrom: 0.45,
|
|
163
|
+
opacityTo: 0.05,
|
|
164
|
+
stops: [20, 100],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
xaxis: {
|
|
168
|
+
categories: config.categories,
|
|
169
|
+
axisBorder: { show: false },
|
|
170
|
+
axisTicks: { show: false },
|
|
171
|
+
labels: { style: { colors: '#64748b', fontSize: '12px' } },
|
|
172
|
+
},
|
|
173
|
+
yaxis: {
|
|
174
|
+
labels: { style: { colors: '#64748b', fontSize: '12px' } },
|
|
175
|
+
},
|
|
176
|
+
grid: {
|
|
177
|
+
show: config.showGrid,
|
|
178
|
+
borderColor: 'rgba(255, 255, 255, 0.05)',
|
|
179
|
+
strokeDashArray: 4,
|
|
180
|
+
},
|
|
181
|
+
legend: {
|
|
182
|
+
show: true,
|
|
183
|
+
position: 'top',
|
|
184
|
+
horizontalAlign: 'right',
|
|
185
|
+
labels: { colors: '#94a3b8' },
|
|
186
|
+
},
|
|
187
|
+
tooltip: { theme: 'dark' },
|
|
188
|
+
theme: { mode: 'dark' }
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const chart = new ApexCharts(target, options);
|
|
193
|
+
chart.render().then(() => {
|
|
194
|
+
if (fallback) (fallback as HTMLElement).style.display = 'none';
|
|
195
|
+
});
|
|
196
|
+
container.setAttribute('data-initialized', 'true');
|
|
197
|
+
} catch (err) {
|
|
198
|
+
console.error('Failed to render chart:', err);
|
|
199
|
+
if (fallback) fallback.textContent = 'Failed to load chart';
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Initial load
|
|
205
|
+
initCharts();
|
|
206
|
+
|
|
207
|
+
// Handle navigations
|
|
208
|
+
document.addEventListener('astro:page-load', initCharts);
|
|
209
|
+
document.addEventListener('astro:after-swap', initCharts);
|
|
210
|
+
</script>
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* BarChart — A premium bar chart component.
|
|
4
|
+
*/
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
categories?: any[];
|
|
9
|
+
series?: any[];
|
|
10
|
+
height?: number | string;
|
|
11
|
+
colors?: string[];
|
|
12
|
+
horizontal?: boolean;
|
|
13
|
+
stacked?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
title,
|
|
19
|
+
subtitle,
|
|
20
|
+
categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
|
21
|
+
series = [{ name: 'Sessions', data: [44, 55, 41, 67, 22] }],
|
|
22
|
+
height = 350,
|
|
23
|
+
colors = ['var(--c-accent, #b8860b)', '#3b82f6', '#10b981'],
|
|
24
|
+
horizontal = false,
|
|
25
|
+
stacked = false,
|
|
26
|
+
className = '',
|
|
27
|
+
} = Astro.props;
|
|
28
|
+
|
|
29
|
+
const chartConfig = {
|
|
30
|
+
categories,
|
|
31
|
+
series,
|
|
32
|
+
height,
|
|
33
|
+
colors,
|
|
34
|
+
horizontal,
|
|
35
|
+
stacked,
|
|
36
|
+
};
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<div class={`premium-chart-card ${className}`} data-chart-type="bar" data-config={JSON.stringify(chartConfig)}>
|
|
40
|
+
{(title || subtitle) && (
|
|
41
|
+
<div class="premium-chart-card__header">
|
|
42
|
+
{title && <h3 class="premium-chart-card__title">{title}</h3>}
|
|
43
|
+
{subtitle && <p class="premium-chart-card__subtitle">{subtitle}</p>}
|
|
44
|
+
</div>
|
|
45
|
+
)}
|
|
46
|
+
<div class="premium-chart-card__body">
|
|
47
|
+
<div class="chart-container"></div>
|
|
48
|
+
<div class="chart-fallback">Loading Chart...</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.premium-chart-card {
|
|
54
|
+
background: rgba(255, 255, 255, 0.03);
|
|
55
|
+
backdrop-filter: blur(12px);
|
|
56
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
57
|
+
border-radius: var(--r-xl, 24px);
|
|
58
|
+
padding: var(--sp-6, 24px);
|
|
59
|
+
width: 100%;
|
|
60
|
+
min-width: 300px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.premium-chart-card__header {
|
|
64
|
+
margin-bottom: var(--sp-6, 24px);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.premium-chart-card__title {
|
|
68
|
+
font-size: 1.125rem;
|
|
69
|
+
font-weight: 700;
|
|
70
|
+
color: var(--c-text-1, #ffffff);
|
|
71
|
+
margin: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.premium-chart-card__subtitle {
|
|
75
|
+
font-size: 0.875rem;
|
|
76
|
+
color: var(--c-text-2, #94a3b8);
|
|
77
|
+
margin: var(--sp-1, 4px) 0 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.premium-chart-card__body {
|
|
81
|
+
width: 100%;
|
|
82
|
+
position: relative;
|
|
83
|
+
min-height: 200px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.chart-container {
|
|
87
|
+
width: 100%;
|
|
88
|
+
position: relative;
|
|
89
|
+
z-index: 2;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.chart-fallback {
|
|
93
|
+
position: absolute;
|
|
94
|
+
inset: 0;
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
justify-content: center;
|
|
98
|
+
font-size: 0.8rem;
|
|
99
|
+
color: var(--c-text-3, #64748b);
|
|
100
|
+
z-index: 1;
|
|
101
|
+
}
|
|
102
|
+
</style>
|
|
103
|
+
|
|
104
|
+
<script>
|
|
105
|
+
async function initCharts() {
|
|
106
|
+
const charts = document.querySelectorAll('.premium-chart-card[data-chart-type="bar"]');
|
|
107
|
+
if (charts.length === 0) return;
|
|
108
|
+
|
|
109
|
+
let ApexChartsModule;
|
|
110
|
+
try {
|
|
111
|
+
ApexChartsModule = await import('apexcharts');
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.error('ApexCharts failed to load:', e);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const ApexCharts = ApexChartsModule.default || ApexChartsModule;
|
|
118
|
+
|
|
119
|
+
charts.forEach(container => {
|
|
120
|
+
if (container.getAttribute('data-initialized')) return;
|
|
121
|
+
|
|
122
|
+
const configStr = container.getAttribute('data-config');
|
|
123
|
+
if (!configStr) return;
|
|
124
|
+
|
|
125
|
+
const config = JSON.parse(configStr);
|
|
126
|
+
const target = container.querySelector('.chart-container');
|
|
127
|
+
const fallback = container.querySelector('.chart-fallback');
|
|
128
|
+
|
|
129
|
+
if (!target) return;
|
|
130
|
+
|
|
131
|
+
const options = {
|
|
132
|
+
series: config.series,
|
|
133
|
+
chart: {
|
|
134
|
+
type: 'bar',
|
|
135
|
+
height: config.height,
|
|
136
|
+
stacked: config.stacked,
|
|
137
|
+
toolbar: { show: false },
|
|
138
|
+
background: 'transparent',
|
|
139
|
+
fontFamily: 'Inter, sans-serif',
|
|
140
|
+
},
|
|
141
|
+
plotOptions: {
|
|
142
|
+
bar: {
|
|
143
|
+
horizontal: config.horizontal,
|
|
144
|
+
columnWidth: '55%',
|
|
145
|
+
borderRadius: 8,
|
|
146
|
+
borderRadiusApplication: 'end',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
colors: config.colors,
|
|
150
|
+
dataLabels: { enabled: false },
|
|
151
|
+
xaxis: {
|
|
152
|
+
categories: config.categories,
|
|
153
|
+
axisBorder: { show: false },
|
|
154
|
+
axisTicks: { show: false },
|
|
155
|
+
labels: { style: { colors: '#64748b', fontSize: '12px' } },
|
|
156
|
+
},
|
|
157
|
+
yaxis: {
|
|
158
|
+
labels: { style: { colors: '#64748b', fontSize: '12px' } },
|
|
159
|
+
},
|
|
160
|
+
grid: {
|
|
161
|
+
borderColor: 'rgba(255, 255, 255, 0.05)',
|
|
162
|
+
strokeDashArray: 4,
|
|
163
|
+
},
|
|
164
|
+
legend: {
|
|
165
|
+
show: true,
|
|
166
|
+
position: 'top',
|
|
167
|
+
horizontalAlign: 'right',
|
|
168
|
+
labels: { colors: '#94a3b8' },
|
|
169
|
+
},
|
|
170
|
+
tooltip: { theme: 'dark' },
|
|
171
|
+
theme: { mode: 'dark' }
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const chart = new ApexCharts(target, options);
|
|
176
|
+
chart.render().then(() => {
|
|
177
|
+
if (fallback) (fallback as HTMLElement).style.display = 'none';
|
|
178
|
+
});
|
|
179
|
+
container.setAttribute('data-initialized', 'true');
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.error('Failed to render chart:', err);
|
|
182
|
+
if (fallback) fallback.textContent = 'Failed to load chart';
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
initCharts();
|
|
188
|
+
document.addEventListener('astro:page-load', initCharts);
|
|
189
|
+
document.addEventListener('astro:after-swap', initCharts);
|
|
190
|
+
</script>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DonutChart — A minimalist donut chart component.
|
|
4
|
+
*/
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string;
|
|
7
|
+
labels?: string[];
|
|
8
|
+
series?: number[];
|
|
9
|
+
height?: number | string;
|
|
10
|
+
colors?: string[];
|
|
11
|
+
centerLabel?: string;
|
|
12
|
+
pie?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
title,
|
|
18
|
+
labels = ['Direct', 'Social', 'Referral'],
|
|
19
|
+
series = [44, 33, 23],
|
|
20
|
+
height = 350,
|
|
21
|
+
colors = ['var(--c-accent, #b8860b)', '#3b82f6', '#10b981', '#f59e0b', '#ef4444'],
|
|
22
|
+
centerLabel = 'Total',
|
|
23
|
+
pie = false,
|
|
24
|
+
className = '',
|
|
25
|
+
} = Astro.props;
|
|
26
|
+
|
|
27
|
+
const chartConfig = {
|
|
28
|
+
labels,
|
|
29
|
+
series,
|
|
30
|
+
height,
|
|
31
|
+
colors,
|
|
32
|
+
centerLabel,
|
|
33
|
+
pie,
|
|
34
|
+
};
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<div class={`premium-chart-card ${className}`} data-chart-type="donut" data-config={JSON.stringify(chartConfig)}>
|
|
38
|
+
{title && (
|
|
39
|
+
<div class="premium-chart-card__header">
|
|
40
|
+
<h3 class="premium-chart-card__title">{title}</h3>
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
<div class="premium-chart-card__body">
|
|
44
|
+
<div class="chart-container"></div>
|
|
45
|
+
<div class="chart-fallback">Loading Chart...</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.premium-chart-card {
|
|
51
|
+
background: rgba(255, 255, 255, 0.03);
|
|
52
|
+
backdrop-filter: blur(12px);
|
|
53
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
54
|
+
border-radius: var(--r-xl, 24px);
|
|
55
|
+
padding: var(--sp-6, 24px);
|
|
56
|
+
width: 100%;
|
|
57
|
+
min-width: 300px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.premium-chart-card__header {
|
|
61
|
+
margin-bottom: var(--sp-6, 24px);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.premium-chart-card__title {
|
|
65
|
+
font-size: 1.125rem;
|
|
66
|
+
font-weight: 700;
|
|
67
|
+
color: var(--c-text-1, #ffffff);
|
|
68
|
+
margin: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.premium-chart-card__body {
|
|
72
|
+
width: 100%;
|
|
73
|
+
position: relative;
|
|
74
|
+
min-height: 200px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.chart-container {
|
|
78
|
+
width: 100%;
|
|
79
|
+
position: relative;
|
|
80
|
+
z-index: 2;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.chart-fallback {
|
|
84
|
+
position: absolute;
|
|
85
|
+
inset: 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
font-size: 0.8rem;
|
|
90
|
+
color: var(--c-text-3, #64748b);
|
|
91
|
+
z-index: 1;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
|
|
95
|
+
<script>
|
|
96
|
+
async function initCharts() {
|
|
97
|
+
const charts = document.querySelectorAll('.premium-chart-card[data-chart-type="donut"]');
|
|
98
|
+
if (charts.length === 0) return;
|
|
99
|
+
|
|
100
|
+
let ApexChartsModule;
|
|
101
|
+
try {
|
|
102
|
+
ApexChartsModule = await import('apexcharts');
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error('ApexCharts failed to load:', e);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const ApexCharts = ApexChartsModule.default || ApexChartsModule;
|
|
109
|
+
|
|
110
|
+
charts.forEach(container => {
|
|
111
|
+
if (container.getAttribute('data-initialized')) return;
|
|
112
|
+
|
|
113
|
+
const configStr = container.getAttribute('data-config');
|
|
114
|
+
if (!configStr) return;
|
|
115
|
+
|
|
116
|
+
const config = JSON.parse(configStr);
|
|
117
|
+
const target = container.querySelector('.chart-container');
|
|
118
|
+
const fallback = container.querySelector('.chart-fallback');
|
|
119
|
+
|
|
120
|
+
if (!target) return;
|
|
121
|
+
|
|
122
|
+
const options = {
|
|
123
|
+
series: config.series,
|
|
124
|
+
labels: config.labels,
|
|
125
|
+
chart: {
|
|
126
|
+
type: config.pie ? 'pie' : 'donut',
|
|
127
|
+
height: config.height,
|
|
128
|
+
background: 'transparent',
|
|
129
|
+
fontFamily: 'Inter, sans-serif',
|
|
130
|
+
},
|
|
131
|
+
colors: config.colors,
|
|
132
|
+
stroke: { show: false },
|
|
133
|
+
dataLabels: { enabled: false },
|
|
134
|
+
plotOptions: {
|
|
135
|
+
pie: {
|
|
136
|
+
donut: {
|
|
137
|
+
size: '75%',
|
|
138
|
+
labels: {
|
|
139
|
+
show: !config.pie,
|
|
140
|
+
name: { show: true, color: '#94a3b8', fontSize: '14px' },
|
|
141
|
+
value: { show: true, color: '#ffffff', fontSize: '24px', fontWeight: 800 },
|
|
142
|
+
total: {
|
|
143
|
+
show: true,
|
|
144
|
+
label: config.centerLabel,
|
|
145
|
+
color: '#94a3b8',
|
|
146
|
+
formatter: (w) => w.globals.seriesGlobals.reduce((a, b) => a + b, 0),
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
legend: {
|
|
153
|
+
show: true,
|
|
154
|
+
position: 'bottom',
|
|
155
|
+
labels: { colors: '#94a3b8' },
|
|
156
|
+
},
|
|
157
|
+
tooltip: { theme: 'dark' },
|
|
158
|
+
theme: { mode: 'dark' }
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
const chart = new ApexCharts(target, options);
|
|
163
|
+
chart.render().then(() => {
|
|
164
|
+
if (fallback) (fallback as HTMLElement).style.display = 'none';
|
|
165
|
+
});
|
|
166
|
+
container.setAttribute('data-initialized', 'true');
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error('Failed to render chart:', err);
|
|
169
|
+
if (fallback) fallback.textContent = 'Failed to load chart';
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
initCharts();
|
|
175
|
+
document.addEventListener('astro:page-load', initCharts);
|
|
176
|
+
document.addEventListener('astro:after-swap', initCharts);
|
|
177
|
+
</script>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as OverlaysShowcase } from './OverlaysShowcase.astro';
|
|
8
|
-
export { default as DataShowcase } from './DataShowcase.astro';
|
|
9
|
-
export { default as TypographyShowcase } from './TypographyShowcase.astro';
|
|
1
|
+
// src/components/lib/sections/index.ts
|
|
2
|
+
// Barrel export for section components
|
|
3
|
+
|
|
4
|
+
export { default as HeroGradient } from './HeroGradient.astro';
|
|
5
|
+
export { default as HeroSplit } from './HeroSplit.astro';
|
|
6
|
+
export { default as HeroGlass } from './HeroGlass.astro';
|