astro-component-kit 0.3.1 → 0.4.1
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 +133 -36
- package/package.json +17 -4
- package/src/components/index.ts +18 -202
- package/src/components/lib/Galaxy3D.astro +249 -137
- package/src/components/lib/app/AppSidebar.astro +249 -0
- package/src/components/lib/app/AppTopbar.astro +284 -0
- package/src/components/lib/app/ArrivalsBoard.astro +176 -0
- package/src/components/lib/app/AuthCard.astro +213 -0
- package/src/components/lib/app/DataTable.astro +346 -0
- package/src/components/lib/app/GuestProfileCard.astro +133 -0
- package/src/components/lib/app/HousekeepingBoard.astro +189 -0
- package/src/components/lib/app/PageHeader.astro +157 -0
- package/src/components/lib/app/PlanUsageCard.astro +112 -0
- package/src/components/lib/app/RoomRack.astro +207 -0
- package/src/components/lib/app/SettingsSection.astro +96 -0
- package/src/components/lib/app/SwitchRow.astro +71 -0
- package/src/components/lib/app/TeamMembers.astro +190 -0
- package/src/components/lib/app/app-icons.ts +52 -0
- package/src/components/lib/app/index.ts +19 -0
- package/src/components/lib/buttons/NeonBorderButton.astro +162 -0
- package/src/components/lib/buttons/RippleButton.astro +199 -0
- package/src/components/lib/buttons/SlideRevealButton.astro +159 -0
- package/src/components/lib/buttons/index.ts +4 -0
- package/src/components/lib/cards/GithubRepoCard.astro +176 -0
- package/src/components/lib/cards/PricingCompareMiniCard.astro +196 -0
- package/src/components/lib/cards/StatsTrendCard.astro +149 -0
- package/src/components/lib/cards/index.ts +3 -0
- package/src/components/lib/charts/ActivityRings.astro +105 -0
- package/src/components/lib/charts/AreaChart.astro +4 -4
- package/src/components/lib/charts/BarChart.astro +3 -3
- package/src/components/lib/charts/BoxPlotChart.astro +109 -0
- package/src/components/lib/charts/BubbleChart.astro +101 -0
- package/src/components/lib/charts/BulletChart.astro +160 -0
- package/src/components/lib/charts/BumpChart.astro +92 -0
- package/src/components/lib/charts/CandlestickChart.astro +105 -0
- package/src/components/lib/charts/ChartFrame.astro +373 -0
- package/src/components/lib/charts/DivergingBarChart.astro +98 -0
- package/src/components/lib/charts/DonutChart.astro +2 -2
- package/src/components/lib/charts/DumbbellChart.astro +92 -0
- package/src/components/lib/charts/ForecastLineChart.astro +125 -0
- package/src/components/lib/charts/FunnelChart.astro +122 -0
- package/src/components/lib/charts/GaugeChart.astro +111 -0
- package/src/components/lib/charts/GoalProgressChart.astro +97 -0
- package/src/components/lib/charts/GroupedBarChart.astro +125 -0
- package/src/components/lib/charts/HeatmapChart.astro +131 -0
- package/src/components/lib/charts/HistogramChart.astro +111 -0
- package/src/components/lib/charts/HorizontalBarChart.astro +155 -0
- package/src/components/lib/charts/KpiStatTile.astro +116 -0
- package/src/components/lib/charts/KpiTrendGrid.astro +60 -0
- package/src/components/lib/charts/LineChart.astro +160 -0
- package/src/components/lib/charts/LinearProgressGauge.astro +136 -0
- package/src/components/lib/charts/LollipopChart.astro +100 -0
- package/src/components/lib/charts/MeterGauge.astro +122 -0
- package/src/components/lib/charts/MetricDeltaTable.astro +125 -0
- package/src/components/lib/charts/PieChart.astro +135 -0
- package/src/components/lib/charts/PolarAreaChart.astro +85 -0
- package/src/components/lib/charts/PopulationPyramid.astro +122 -0
- package/src/components/lib/charts/PunchCardChart.astro +89 -0
- package/src/components/lib/charts/RadarChart.astro +94 -0
- package/src/components/lib/charts/RadarMetricChart.astro +168 -0
- package/src/components/lib/charts/RadialBarChart.astro +124 -0
- package/src/components/lib/charts/RangeAreaChart.astro +113 -0
- package/src/components/lib/charts/RetentionCohortTable.astro +126 -0
- package/src/components/lib/charts/SankeyChart.astro +128 -0
- package/src/components/lib/charts/ScatterPlot.astro +139 -0
- package/src/components/lib/charts/SegmentedBarChart.astro +119 -0
- package/src/components/lib/charts/SlopeChart.astro +105 -0
- package/src/components/lib/charts/SparklineChart.astro +87 -0
- package/src/components/lib/charts/StackedAreaChart.astro +130 -0
- package/src/components/lib/charts/StackedBarChart.astro +136 -0
- package/src/components/lib/charts/SunburstChart.astro +103 -0
- package/src/components/lib/charts/TreemapChart.astro +94 -0
- package/src/components/lib/charts/WaffleChart.astro +121 -0
- package/src/components/lib/charts/WaterfallChart.astro +118 -0
- package/src/components/lib/charts/chart-tooltip.ts +75 -0
- package/src/components/lib/charts/chart-utils.ts +271 -0
- package/src/components/lib/charts/index.ts +46 -0
- package/src/components/lib/data/ActivityHeatmapGrid.astro +157 -0
- package/src/components/lib/data/MetricComparisonRow.astro +109 -0
- package/src/components/lib/data/StatusTimelineFeed.astro +168 -0
- package/src/components/lib/data/index.ts +3 -0
- package/src/components/lib/ecommerce/CartDrawer.astro +483 -0
- package/src/components/lib/ecommerce/CartPageList.astro +290 -0
- package/src/components/lib/ecommerce/CartToast.astro +276 -0
- package/src/components/lib/ecommerce/CategoryTiles.astro +143 -0
- package/src/components/lib/ecommerce/CheckoutForm.astro +423 -0
- package/src/components/lib/ecommerce/CountdownBanner.astro +230 -0
- package/src/components/lib/ecommerce/FilterBar.astro +278 -0
- package/src/components/lib/ecommerce/FilterSidebar.astro +405 -0
- package/src/components/lib/ecommerce/LiveActivityToast.astro +213 -0
- package/src/components/lib/ecommerce/OrderSummary.astro +295 -0
- package/src/components/lib/ecommerce/ProductBuyBox.astro +247 -0
- package/src/components/lib/ecommerce/ProductCardMinimal.astro +229 -0
- package/src/components/lib/ecommerce/ProductGallery.astro +145 -0
- package/src/components/lib/ecommerce/ProductGrid.astro +118 -0
- package/src/components/lib/ecommerce/ProductMedia.astro +113 -0
- package/src/components/lib/ecommerce/ProductRating.astro +78 -0
- package/src/components/lib/ecommerce/ProductToolbar.astro +93 -0
- package/src/components/lib/ecommerce/PromoBar.astro +145 -0
- package/src/components/lib/ecommerce/StockIndicator.astro +127 -0
- package/src/components/lib/ecommerce/StoreHeader.astro +446 -0
- package/src/components/lib/ecommerce/StoreHero.astro +260 -0
- package/src/components/lib/ecommerce/StoreProductCard.astro +307 -0
- package/src/components/lib/ecommerce/TrustBadges.astro +101 -0
- package/src/components/lib/ecommerce/VariantPicker.astro +145 -0
- package/src/components/lib/ecommerce/cart-store.ts +151 -0
- package/src/components/lib/ecommerce/catalog-filter.ts +62 -0
- package/src/components/lib/ecommerce/index.ts +34 -0
- package/src/components/lib/ecommerce/product-icons.ts +28 -0
- package/src/components/lib/ecommerce/types.ts +70 -0
- package/src/components/lib/feedback/ProgressRingCounter.astro +118 -0
- package/src/components/lib/feedback/ToastNotificationGroup.astro +173 -0
- package/src/components/lib/feedback/index.ts +2 -0
- package/src/components/lib/forms/AnimatedInput.astro +4 -2
- package/src/components/lib/forms/CustomRadioGroup.astro +3 -1
- package/src/components/lib/forms/GlassInlineToggleGroup.astro +161 -0
- package/src/components/lib/forms/PasswordStrengthInput.astro +242 -0
- package/src/components/lib/forms/PhoneCountryInput.astro +145 -0
- package/src/components/lib/forms/TagsAutocompleteInput.astro +249 -0
- package/src/components/lib/forms/index.ts +5 -0
- package/src/components/lib/index.ts +2 -0
- package/src/components/lib/layout/BentoGrid3.astro +6 -4
- package/src/components/lib/layout/CenterFixedBox.astro +2 -2
- package/src/components/lib/layout/CenteredContainer.astro +4 -2
- package/src/components/lib/layout/ClusterHorizontal.astro +2 -2
- package/src/components/lib/layout/DiagonalSectionDivider.astro +69 -0
- package/src/components/lib/layout/FeatureHero.astro +4 -2
- package/src/components/lib/layout/FooterCenteredMinimal.astro +4 -2
- package/src/components/lib/layout/FullBleedSection.astro +2 -2
- package/src/components/lib/layout/GalleryGrid4.astro +2 -2
- package/src/components/lib/layout/HolyGrailGrid.astro +127 -0
- package/src/components/lib/layout/LandingSectionSplit.astro +5 -3
- package/src/components/lib/layout/MasonryGrid.astro +2 -2
- package/src/components/lib/layout/MinimalFooterGrid.astro +1 -1
- package/src/components/lib/layout/ScrollSnapSection.astro +1 -1
- package/src/components/lib/layout/SidebarLayoutWrapper.astro +4 -2
- package/src/components/lib/layout/SplitScreenLayout.astro +3 -3
- package/src/components/lib/layout/StepLayoutVertical.astro +1 -1
- package/src/components/lib/layout/StickySidebarWrapper.astro +4 -2
- package/src/components/lib/layout/index.ts +3 -1
- package/src/components/lib/navigation/QuickJumpDock.astro +125 -0
- package/src/components/lib/navigation/StepBreadcrumbBar.astro +151 -0
- package/src/components/lib/navigation/SubNavbarPills.astro +102 -0
- package/src/components/lib/navigation/index.ts +3 -0
- package/src/components/lib/overlays/CookiePreferencesDrawer.astro +226 -0
- package/src/components/lib/overlays/FloatingFeedbackWidget.astro +203 -0
- package/src/components/lib/overlays/ImageCompareSlider.astro +172 -0
- package/src/components/lib/overlays/index.ts +3 -0
- package/src/components/lib/sections/AgencyContactBrief.astro +194 -0
- package/src/components/lib/sections/AgencyFooterCta.astro +94 -0
- package/src/components/lib/sections/AgencyHeader.astro +161 -0
- package/src/components/lib/sections/AgencyHeroKinetic.astro +172 -0
- package/src/components/lib/sections/AgencyServicesList.astro +113 -0
- package/src/components/lib/sections/AgencyTeamGrid.astro +111 -0
- package/src/components/lib/sections/AgencyWorkGrid.astro +147 -0
- package/src/components/lib/sections/BlogGridSection.astro +133 -0
- package/src/components/lib/sections/ButtonsShowcase.astro +20 -18
- package/src/components/lib/sections/CardsShowcase.astro +28 -26
- package/src/components/lib/sections/CareersOpenings.astro +141 -0
- package/src/components/lib/sections/ChangelogSection.astro +151 -0
- package/src/components/lib/sections/ContactGlassForm.astro +10 -8
- package/src/components/lib/sections/ContactSplitMap.astro +141 -0
- package/src/components/lib/sections/CtaAppDownload.astro +13 -11
- package/src/components/lib/sections/CtaGlowBanner.astro +12 -10
- package/src/components/lib/sections/CtaNewsletterSection.astro +165 -0
- package/src/components/lib/sections/CtaSplitImage.astro +149 -0
- package/src/components/lib/sections/DataShowcase.astro +23 -21
- package/src/components/lib/sections/FaqAccordionSection.astro +8 -8
- package/src/components/lib/sections/FaqTwoColumn.astro +121 -0
- package/src/components/lib/sections/FeatureAlternatingRows.astro +192 -0
- package/src/components/lib/sections/FeatureBentoGrid.astro +13 -11
- package/src/components/lib/sections/FeatureIconGrid.astro +155 -0
- package/src/components/lib/sections/FeatureTabsShowcase.astro +182 -0
- package/src/components/lib/sections/FeatureTimelineFlow.astro +8 -6
- package/src/components/lib/sections/FeedbackShowcase.astro +15 -13
- package/src/components/lib/sections/FooterMegaSection.astro +157 -0
- package/src/components/lib/sections/FormsShowcase.astro +22 -20
- package/src/components/lib/sections/HeroDashboardPreview.astro +182 -0
- package/src/components/lib/sections/HeroGlass.astro +22 -20
- package/src/components/lib/sections/HeroGradient.astro +15 -13
- package/src/components/lib/sections/HeroMinimalCentered.astro +175 -0
- package/src/components/lib/sections/HeroShowcaseSplit.astro +306 -0
- package/src/components/lib/sections/HeroSplit.astro +13 -11
- package/src/components/lib/sections/HeroTerminal.astro +253 -0
- package/src/components/lib/sections/HeroWaitlist.astro +231 -0
- package/src/components/lib/sections/HowItWorksSteps.astro +180 -0
- package/src/components/lib/sections/IntegrationsGrid.astro +167 -0
- package/src/components/lib/sections/LayoutShowcase.astro +21 -19
- package/src/components/lib/sections/LogoCloudSection.astro +96 -0
- package/src/components/lib/sections/LogoWallGrid.astro +93 -0
- package/src/components/lib/sections/NavigationShowcase.astro +15 -13
- package/src/components/lib/sections/OverlaysShowcase.astro +21 -19
- package/src/components/lib/sections/PricingComparisonMatrix.astro +15 -13
- package/src/components/lib/sections/PricingSinglePlan.astro +159 -0
- package/src/components/lib/sections/PricingTierCards.astro +11 -9
- package/src/components/lib/sections/PricingToggleCards.astro +171 -0
- package/src/components/lib/sections/ShopCategoryHero.astro +103 -0
- package/src/components/lib/sections/ShopCollectionMosaic.astro +131 -0
- package/src/components/lib/sections/ShopFooterWordmark.astro +100 -0
- package/src/components/lib/sections/ShopHeaderEditorial.astro +396 -0
- package/src/components/lib/sections/ShopHeroEditorial.astro +151 -0
- package/src/components/lib/sections/ShopLookbook.astro +250 -0
- package/src/components/lib/sections/ShopNewsletterEditorial.astro +128 -0
- package/src/components/lib/sections/ShopProductRail.astro +150 -0
- package/src/components/lib/sections/ShopReviewsEditorial.astro +133 -0
- package/src/components/lib/sections/ShopValuesMarquee.astro +91 -0
- package/src/components/lib/sections/StatsCounterBand.astro +124 -0
- package/src/components/lib/sections/StatsDashboardSection.astro +85 -0
- package/src/components/lib/sections/StatsMetricShowcase.astro +9 -7
- package/src/components/lib/sections/TeamGridSection.astro +12 -10
- package/src/components/lib/sections/TestimonialCarousel.astro +167 -0
- package/src/components/lib/sections/TestimonialFeatured.astro +122 -0
- package/src/components/lib/sections/TestimonialGridSection.astro +188 -0
- package/src/components/lib/sections/TestimonialWallGlass.astro +11 -9
- package/src/components/lib/sections/TypographyShowcase.astro +10 -8
- package/src/components/lib/sections/index.ts +39 -0
- package/src/components/lib/templates/ecommerce/StoreCategoryPage.astro +160 -0
- package/src/components/lib/templates/ecommerce/StoreCheckoutPage.astro +98 -0
- package/src/components/lib/templates/ecommerce/StoreHomePage.astro +191 -0
- package/src/components/lib/templates/ecommerce/StoreLayout.astro +169 -0
- package/src/components/lib/templates/ecommerce/StoreProductPage.astro +165 -0
- package/src/components/lib/templates/ecommerce/data.ts +187 -0
- package/src/components/lib/templates/ecommerce/index.ts +14 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialBagPage.astro +52 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialCheckoutPage.astro +123 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialHomePage.astro +102 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialLayout.astro +216 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialProductPage.astro +205 -0
- package/src/components/lib/templates/ecommerce-editorial/EditorialShopPage.astro +112 -0
- package/src/components/lib/templates/ecommerce-editorial/data.ts +125 -0
- package/src/components/lib/templates/ecommerce-editorial/index.ts +16 -0
- package/src/components/lib/templates/saas-hotel/AppLayout.astro +83 -0
- package/src/components/lib/templates/saas-hotel/DashboardPage.astro +66 -0
- package/src/components/lib/templates/saas-hotel/GuestsPage.astro +65 -0
- package/src/components/lib/templates/saas-hotel/LandingPage.astro +213 -0
- package/src/components/lib/templates/saas-hotel/ReportsPage.astro +63 -0
- package/src/components/lib/templates/saas-hotel/ReservationsPage.astro +49 -0
- package/src/components/lib/templates/saas-hotel/RoomsPage.astro +48 -0
- package/src/components/lib/templates/saas-hotel/SettingsPage.astro +115 -0
- package/src/components/lib/templates/saas-hotel/SignInPage.astro +50 -0
- package/src/components/lib/templates/saas-hotel/data.ts +229 -0
- package/src/components/lib/templates/saas-hotel/index.ts +19 -0
- package/src/components/lib/templates/saas-hotel/lobby-theme.css +90 -0
- package/src/components/lib/typography/AnimatedCounterText.astro +102 -0
- package/src/components/lib/typography/CurvedPathHeading.astro +86 -0
- package/src/components/lib/typography/GradientTextMarquee.astro +105 -0
- package/src/components/lib/typography/HackerDecodeText.astro +85 -0
- package/src/components/lib/typography/index.ts +4 -0
- package/src/styles/global.css +113 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* BubbleChart — Three-variable scatter: x, y and bubble area (z). Larger
|
|
4
|
+
* bubbles are drawn first so small ones stay visible on top.
|
|
5
|
+
*
|
|
6
|
+
* @param {Array<{label: string, x: number, y: number, z: number, group?: number}>} items - Bubbles.
|
|
7
|
+
* @param {string[]} groups - Group names (max 3) mapped to color slots.
|
|
8
|
+
* @param {string} xLabel - X-axis title.
|
|
9
|
+
* @param {string} yLabel - Y-axis title.
|
|
10
|
+
* @param {string} zLabel - Bubble size meaning.
|
|
11
|
+
* @param {string[]} colors - Optional per-group colors.
|
|
12
|
+
* @param {string} variant - Card style (glass|solid|ghost).
|
|
13
|
+
* @param {string} size - Density (sm|md|lg).
|
|
14
|
+
*/
|
|
15
|
+
import ChartFrame from './ChartFrame.astro';
|
|
16
|
+
import { scaleLinear, niceTicks, colorAt, formatCompact } from './chart-utils';
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
title?: string;
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
items?: Array<{ label: string; x: number; y: number; z: number; group?: number }>;
|
|
22
|
+
groups?: string[];
|
|
23
|
+
xLabel?: string;
|
|
24
|
+
yLabel?: string;
|
|
25
|
+
zLabel?: string;
|
|
26
|
+
height?: number;
|
|
27
|
+
colors?: string[];
|
|
28
|
+
variant?: 'glass' | 'solid' | 'ghost';
|
|
29
|
+
size?: 'sm' | 'md' | 'lg';
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
title = 'Market opportunity',
|
|
35
|
+
subtitle = 'Growth vs margin, bubble = revenue',
|
|
36
|
+
items = [
|
|
37
|
+
{ label: 'Analytics', x: 34, y: 62, z: 120, group: 0 },
|
|
38
|
+
{ label: 'Payments', x: 18, y: 41, z: 260, group: 0 },
|
|
39
|
+
{ label: 'CRM', x: 9, y: 55, z: 180, group: 1 },
|
|
40
|
+
{ label: 'Hosting', x: 22, y: 28, z: 90, group: 1 },
|
|
41
|
+
{ label: 'AI tools', x: 71, y: 48, z: 70, group: 2 },
|
|
42
|
+
{ label: 'Security', x: 27, y: 72, z: 140, group: 2 },
|
|
43
|
+
{ label: 'Email', x: 6, y: 66, z: 60, group: 1 },
|
|
44
|
+
{ label: 'Design', x: 41, y: 58, z: 85, group: 0 },
|
|
45
|
+
],
|
|
46
|
+
groups = ['Core', 'Mature', 'Emerging'],
|
|
47
|
+
xLabel = 'YoY growth (%)',
|
|
48
|
+
yLabel = 'Gross margin (%)',
|
|
49
|
+
zLabel = 'Revenue ($M)',
|
|
50
|
+
height = 320,
|
|
51
|
+
colors,
|
|
52
|
+
variant = 'glass',
|
|
53
|
+
size = 'md',
|
|
54
|
+
className = '',
|
|
55
|
+
} = Astro.props;
|
|
56
|
+
|
|
57
|
+
const W = 640;
|
|
58
|
+
const H = height;
|
|
59
|
+
const m = { t: 20, r: 24, b: 40, l: 48 };
|
|
60
|
+
const xt = niceTicks(0, Math.max(...items.map((i) => i.x)), 5);
|
|
61
|
+
const yt = niceTicks(0, Math.max(...items.map((i) => i.y)), 4);
|
|
62
|
+
const x = scaleLinear(xt[0], xt[xt.length - 1], m.l, W - m.r);
|
|
63
|
+
const y = scaleLinear(yt[0], yt[yt.length - 1], H - m.b, m.t);
|
|
64
|
+
const zMax = Math.max(...items.map((i) => i.z)) || 1;
|
|
65
|
+
const r = (z: number) => 6 + Math.sqrt(z / zMax) * 30; // area-proportional radius
|
|
66
|
+
const sorted = [...items].sort((a, b) => b.z - a.z);
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
<ChartFrame
|
|
70
|
+
title={title}
|
|
71
|
+
subtitle={subtitle}
|
|
72
|
+
variant={variant}
|
|
73
|
+
size={size}
|
|
74
|
+
className={className}
|
|
75
|
+
legend={groups.slice(0, 3).map((g, i) => ({ label: g, color: colorAt(i, colors) }))}
|
|
76
|
+
table={{ headers: ['Item', 'Group', xLabel, yLabel, zLabel], rows: items.map((i) => [i.label, groups[i.group ?? 0] ?? '—', i.x, i.y, i.z]) }}
|
|
77
|
+
>
|
|
78
|
+
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${title}: bubble chart of ${items.length} items`}>
|
|
79
|
+
{yt.map((t) => (
|
|
80
|
+
<g>
|
|
81
|
+
<line class="cf-grid" x1={m.l} x2={W - m.r} y1={y(t)} y2={y(t)} />
|
|
82
|
+
<text class="cf-label" x={m.l - 8} y={y(t) + 4} text-anchor="end">{formatCompact(t)}</text>
|
|
83
|
+
</g>
|
|
84
|
+
))}
|
|
85
|
+
{xt.map((t) => <text class="cf-label" x={x(t)} y={H - m.b + 16} text-anchor="middle">{formatCompact(t)}</text>)}
|
|
86
|
+
<text class="cf-label" x={(m.l + W - m.r) / 2} y={H - 4} text-anchor="middle">{xLabel}</text>
|
|
87
|
+
<text class="cf-label" transform={`translate(12 ${(m.t + H - m.b) / 2}) rotate(-90)`} text-anchor="middle">{yLabel}</text>
|
|
88
|
+
|
|
89
|
+
{sorted.map((it) => {
|
|
90
|
+
const col = colorAt(it.group ?? 0, colors);
|
|
91
|
+
const rad = r(it.z);
|
|
92
|
+
return (
|
|
93
|
+
<g class="cf-mark cf-dim" tabindex="0" role="img" aria-label={`${it.label}: ${xLabel} ${it.x}, ${yLabel} ${it.y}, ${zLabel} ${it.z}`}
|
|
94
|
+
data-tip-title={it.label} data-tip={`${col}::${groups[it.group ?? 0] ?? ''}|${xLabel}: ${it.x}|${yLabel}: ${it.y}|${zLabel}: ${it.z}`}>
|
|
95
|
+
<circle cx={x(it.x)} cy={y(it.y)} r={rad} fill={col} fill-opacity="0.55" stroke={col} stroke-width="1.5" />
|
|
96
|
+
{rad > 18 && <text x={x(it.x)} y={y(it.y) + 4} text-anchor="middle" fill="#fff" font-size="11" font-weight="600">{it.label}</text>}
|
|
97
|
+
</g>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
</svg>
|
|
101
|
+
</ChartFrame>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* BulletChart — Compact KPI-vs-target bars with qualitative bands
|
|
4
|
+
* (poor / ok / good), a measure bar and a target tick. Stack several for a grid.
|
|
5
|
+
*
|
|
6
|
+
* @param {Array<{label: string, value: number, target: number, ranges: [number, number, number], unit?: string}>} metrics
|
|
7
|
+
* - Each metric with its qualitative band thresholds (ascending).
|
|
8
|
+
* @param {string} color - Measure bar color.
|
|
9
|
+
* @param {string} variant - Card style (glass|solid|ghost).
|
|
10
|
+
* @param {string} size - Density (sm|md|lg).
|
|
11
|
+
*/
|
|
12
|
+
import ChartFrame from './ChartFrame.astro';
|
|
13
|
+
|
|
14
|
+
interface Metric {
|
|
15
|
+
label: string;
|
|
16
|
+
value: number;
|
|
17
|
+
target: number;
|
|
18
|
+
ranges: [number, number, number];
|
|
19
|
+
unit?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
title?: string;
|
|
24
|
+
subtitle?: string;
|
|
25
|
+
metrics?: Metric[];
|
|
26
|
+
color?: string;
|
|
27
|
+
variant?: 'glass' | 'solid' | 'ghost';
|
|
28
|
+
size?: 'sm' | 'md' | 'lg';
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
title = 'Quarterly targets',
|
|
34
|
+
subtitle = 'Measure vs target with performance bands',
|
|
35
|
+
metrics = [
|
|
36
|
+
{ label: 'Revenue ($k)', value: 270, target: 250, ranges: [150, 225, 300] },
|
|
37
|
+
{ label: 'Profit', value: 23, target: 26, ranges: [20, 25, 30], unit: '%' },
|
|
38
|
+
{ label: 'New customers', value: 1650, target: 2100, ranges: [1400, 2000, 2500] },
|
|
39
|
+
{ label: 'NPS', value: 54, target: 50, ranges: [30, 50, 70] },
|
|
40
|
+
],
|
|
41
|
+
color = 'var(--c-text-1, #fff)',
|
|
42
|
+
variant = 'glass',
|
|
43
|
+
size = 'md',
|
|
44
|
+
className = '',
|
|
45
|
+
} = Astro.props;
|
|
46
|
+
|
|
47
|
+
const pct = (v: number, max: number) => `${Math.min(100, (v / max) * 100)}%`;
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
<ChartFrame
|
|
51
|
+
title={title}
|
|
52
|
+
subtitle={subtitle}
|
|
53
|
+
variant={variant}
|
|
54
|
+
size={size}
|
|
55
|
+
className={className}
|
|
56
|
+
table={{ headers: ['Metric', 'Value', 'Target', 'Status'], rows: metrics.map((mt) => [mt.label, `${mt.value}${mt.unit ?? ''}`, `${mt.target}${mt.unit ?? ''}`, mt.value >= mt.target ? 'On target' : 'Below target']) }}
|
|
57
|
+
>
|
|
58
|
+
<div class="bc">
|
|
59
|
+
{metrics.map((mt) => {
|
|
60
|
+
const max = mt.ranges[2];
|
|
61
|
+
const met = mt.value >= mt.target;
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
class="bc__row cf-mark"
|
|
65
|
+
tabindex="0"
|
|
66
|
+
role="meter"
|
|
67
|
+
aria-valuemin={0}
|
|
68
|
+
aria-valuemax={max}
|
|
69
|
+
aria-valuenow={mt.value}
|
|
70
|
+
aria-label={`${mt.label}: ${mt.value}${mt.unit ?? ''} of target ${mt.target}${mt.unit ?? ''}`}
|
|
71
|
+
data-tip-title={mt.label}
|
|
72
|
+
data-tip={`Value: ${mt.value}${mt.unit ?? ''}|Target: ${mt.target}${mt.unit ?? ''}|${met ? 'var(--chart-pos)::On target' : 'var(--chart-neg)::Below target'}`}
|
|
73
|
+
>
|
|
74
|
+
<div class="bc__meta">
|
|
75
|
+
<span class="bc__label">{mt.label}</span>
|
|
76
|
+
<span class="bc__value">
|
|
77
|
+
{mt.value}{mt.unit ?? ''}
|
|
78
|
+
<span class={`bc__status ${met ? 'bc__status--ok' : 'bc__status--bad'}`}>
|
|
79
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" aria-hidden="true">
|
|
80
|
+
{met ? <path d="M20 6 9 17l-5-5" /> : <><circle cx="12" cy="12" r="9" /><path d="M12 8v4M12 16h.01" /></>}
|
|
81
|
+
</svg>
|
|
82
|
+
{met ? 'On target' : 'Below'}
|
|
83
|
+
</span>
|
|
84
|
+
</span>
|
|
85
|
+
</div>
|
|
86
|
+
<div class="bc__track" aria-hidden="true">
|
|
87
|
+
<span class="bc__band" style={`width:${pct(mt.ranges[2], max)}; opacity:0.07`}></span>
|
|
88
|
+
<span class="bc__band" style={`width:${pct(mt.ranges[1], max)}; opacity:0.11`}></span>
|
|
89
|
+
<span class="bc__band" style={`width:${pct(mt.ranges[0], max)}; opacity:0.16`}></span>
|
|
90
|
+
<span class="bc__measure" style={`width:${pct(mt.value, max)}; background:${color}`}></span>
|
|
91
|
+
<span class="bc__target" style={`left:${pct(mt.target, max)}`}></span>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</div>
|
|
97
|
+
</ChartFrame>
|
|
98
|
+
|
|
99
|
+
<style>
|
|
100
|
+
.bc { display: grid; gap: 1rem; }
|
|
101
|
+
.bc__row {
|
|
102
|
+
display: grid;
|
|
103
|
+
gap: 0.45rem;
|
|
104
|
+
padding: 0.35rem;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
}
|
|
107
|
+
.bc__row:focus-visible { outline: 2px solid var(--c-primary-light, #d4a017); }
|
|
108
|
+
.bc__meta { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
|
|
109
|
+
.bc__label { font-size: 0.8125rem; color: var(--c-text-2, #a3a3a3); }
|
|
110
|
+
.bc__value {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 0.6rem;
|
|
114
|
+
font-weight: 650;
|
|
115
|
+
color: var(--c-text-1, #fff);
|
|
116
|
+
font-variant-numeric: tabular-nums;
|
|
117
|
+
}
|
|
118
|
+
.bc__status {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
gap: 0.25rem;
|
|
122
|
+
font-size: 0.6875rem;
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
color: var(--c-text-2, #a3a3a3);
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
.bc__status--ok svg { color: var(--chart-pos, #34c38f); }
|
|
128
|
+
.bc__status--bad svg { color: var(--chart-neg, #f06a6a); }
|
|
129
|
+
.bc__track {
|
|
130
|
+
position: relative;
|
|
131
|
+
height: 22px;
|
|
132
|
+
border-radius: 4px;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
}
|
|
135
|
+
.bc__band {
|
|
136
|
+
position: absolute;
|
|
137
|
+
inset: 0 auto 0 0;
|
|
138
|
+
background: #fff;
|
|
139
|
+
}
|
|
140
|
+
.bc__measure {
|
|
141
|
+
position: absolute;
|
|
142
|
+
left: 0;
|
|
143
|
+
top: 7px;
|
|
144
|
+
height: 8px;
|
|
145
|
+
border-radius: 0 3px 3px 0;
|
|
146
|
+
transform-origin: left;
|
|
147
|
+
animation: bc-grow 0.8s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
148
|
+
}
|
|
149
|
+
.bc__target {
|
|
150
|
+
position: absolute;
|
|
151
|
+
top: 3px;
|
|
152
|
+
bottom: 3px;
|
|
153
|
+
width: 3px;
|
|
154
|
+
margin-left: -1.5px;
|
|
155
|
+
border-radius: 2px;
|
|
156
|
+
background: var(--chart-4, #c98500);
|
|
157
|
+
}
|
|
158
|
+
@keyframes bc-grow { from { transform: scaleX(0); } }
|
|
159
|
+
@media (prefers-reduced-motion: reduce) { .bc__measure { animation: none; } }
|
|
160
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* BumpChart — Rank-over-time chart. Each line tracks one entity's position
|
|
4
|
+
* (1 = top) across periods, with labels at both ends.
|
|
5
|
+
*
|
|
6
|
+
* @param {string[]} periods - X-axis labels.
|
|
7
|
+
* @param {Array<{name: string, ranks: number[]}>} series - Rank per period (1-based), max 8.
|
|
8
|
+
* @param {string[]} colors - Optional per-series colors.
|
|
9
|
+
* @param {string} variant - Card style (glass|solid|ghost).
|
|
10
|
+
* @param {string} size - Density (sm|md|lg).
|
|
11
|
+
*/
|
|
12
|
+
import ChartFrame from './ChartFrame.astro';
|
|
13
|
+
import { colorAt, smoothPath, type Point } from './chart-utils';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
title?: string;
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
periods?: string[];
|
|
19
|
+
series?: Array<{ name: string; ranks: number[] }>;
|
|
20
|
+
colors?: string[];
|
|
21
|
+
variant?: 'glass' | 'solid' | 'ghost';
|
|
22
|
+
size?: 'sm' | 'md' | 'lg';
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
title = 'Framework popularity rank',
|
|
28
|
+
subtitle = 'Developer survey position by year',
|
|
29
|
+
periods = ['2021', '2022', '2023', '2024', '2025', '2026'],
|
|
30
|
+
series = [
|
|
31
|
+
{ name: 'Astro', ranks: [5, 4, 3, 2, 1, 1] },
|
|
32
|
+
{ name: 'Next', ranks: [1, 1, 1, 1, 2, 2] },
|
|
33
|
+
{ name: 'Svelte', ranks: [3, 2, 2, 3, 3, 4] },
|
|
34
|
+
{ name: 'Nuxt', ranks: [2, 3, 4, 4, 5, 3] },
|
|
35
|
+
{ name: 'Remix', ranks: [4, 5, 5, 5, 4, 5] },
|
|
36
|
+
],
|
|
37
|
+
colors,
|
|
38
|
+
variant = 'glass',
|
|
39
|
+
size = 'md',
|
|
40
|
+
className = '',
|
|
41
|
+
} = Astro.props;
|
|
42
|
+
|
|
43
|
+
const W = 640;
|
|
44
|
+
const maxRank = Math.max(...series.flatMap((s) => s.ranks));
|
|
45
|
+
const rowH = 44;
|
|
46
|
+
const H = maxRank * rowH + 36;
|
|
47
|
+
const m = { t: 30, l: 80, r: 80 };
|
|
48
|
+
const n = periods.length;
|
|
49
|
+
const x = (i: number) => m.l + (i / Math.max(1, n - 1)) * (W - m.l - m.r);
|
|
50
|
+
const y = (r: number) => m.t + (r - 1) * rowH + 8;
|
|
51
|
+
const lines = series.slice(0, 8).map((s, si) => ({
|
|
52
|
+
...s,
|
|
53
|
+
color: colorAt(si, colors),
|
|
54
|
+
pts: s.ranks.map((r, i): Point => [x(i), y(r)]),
|
|
55
|
+
}));
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
<ChartFrame
|
|
59
|
+
title={title}
|
|
60
|
+
subtitle={subtitle}
|
|
61
|
+
variant={variant}
|
|
62
|
+
size={size}
|
|
63
|
+
className={className}
|
|
64
|
+
legend={lines.map((l) => ({ label: l.name, color: l.color }))}
|
|
65
|
+
table={{ headers: ['Name', ...periods], rows: series.map((s) => [s.name, ...s.ranks.map((r) => `#${r}`)]) }}
|
|
66
|
+
>
|
|
67
|
+
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${title}: bump chart of ranks over ${n} periods`}>
|
|
68
|
+
{periods.map((p, i) => (
|
|
69
|
+
<g>
|
|
70
|
+
<line class="cf-grid" x1={x(i)} x2={x(i)} y1={m.t - 6} y2={H - 10} />
|
|
71
|
+
<text class="cf-label" x={x(i)} y={14} text-anchor="middle">{p}</text>
|
|
72
|
+
</g>
|
|
73
|
+
))}
|
|
74
|
+
{lines.map((l) => (
|
|
75
|
+
<g class="cf-mark cf-dim" tabindex="0" role="img"
|
|
76
|
+
aria-label={`${l.name}: ${l.ranks.map((r, i) => `${periods[i]} #${r}`).join(', ')}`}
|
|
77
|
+
data-tip-title={l.name}
|
|
78
|
+
data-tip={l.ranks.map((r, i) => `${periods[i]}: #${r}`).join('|')}>
|
|
79
|
+
<path d={smoothPath(l.pts)} fill="none" stroke={l.color} stroke-width="3" stroke-linecap="round" />
|
|
80
|
+
<path d={smoothPath(l.pts)} fill="none" stroke="transparent" stroke-width="16" />
|
|
81
|
+
{l.pts.map(([px, py], i) => (
|
|
82
|
+
<g>
|
|
83
|
+
<circle cx={px} cy={py} r="11" fill={l.color} stroke="var(--chart-surface, #0d0d0f)" stroke-width="2" />
|
|
84
|
+
<text x={px} y={py + 4} text-anchor="middle" font-size="10" font-weight="700" fill="#fff">{l.ranks[i]}</text>
|
|
85
|
+
</g>
|
|
86
|
+
))}
|
|
87
|
+
<text class="cf-label cf-label--strong" x={m.l - 18} y={l.pts[0][1] + 4} text-anchor="end">{l.name}</text>
|
|
88
|
+
<text class="cf-label cf-label--strong" x={W - m.r + 18} y={l.pts[n - 1][1] + 4}>{l.name}</text>
|
|
89
|
+
</g>
|
|
90
|
+
))}
|
|
91
|
+
</svg>
|
|
92
|
+
</ChartFrame>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* CandlestickChart — OHLC price chart. Bodies span open→close, wicks span
|
|
4
|
+
* low→high. Up candles are hollow, down candles filled, so direction is
|
|
5
|
+
* readable without color.
|
|
6
|
+
*
|
|
7
|
+
* @param {Array<{label: string, open: number, high: number, low: number, close: number}>} candles - OHLC data.
|
|
8
|
+
* @param {string} prefix - Price prefix.
|
|
9
|
+
* @param {number} height - SVG height in viewBox units (width is 640).
|
|
10
|
+
* @param {string} variant - Card style (glass|solid|ghost).
|
|
11
|
+
* @param {string} size - Density (sm|md|lg).
|
|
12
|
+
*/
|
|
13
|
+
import ChartFrame from './ChartFrame.astro';
|
|
14
|
+
import { scaleLinear, niceTicks, POSITIVE, NEGATIVE } from './chart-utils';
|
|
15
|
+
|
|
16
|
+
interface Candle { label: string; open: number; high: number; low: number; close: number }
|
|
17
|
+
interface Props {
|
|
18
|
+
title?: string;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
candles?: Candle[];
|
|
21
|
+
prefix?: string;
|
|
22
|
+
height?: number;
|
|
23
|
+
variant?: 'glass' | 'solid' | 'ghost';
|
|
24
|
+
size?: 'sm' | 'md' | 'lg';
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const demo: Candle[] = (() => {
|
|
29
|
+
let p = 182;
|
|
30
|
+
return Array.from({ length: 22 }, (_, i) => {
|
|
31
|
+
const r1 = Math.sin(i * 4.7) * 0.5 + Math.sin(i * 1.3) * 0.5;
|
|
32
|
+
const r2 = Math.abs(Math.sin(i * 9.1));
|
|
33
|
+
const open = p;
|
|
34
|
+
const close = Math.round((p + r1 * 6 + 0.6) * 100) / 100;
|
|
35
|
+
const high = Math.round((Math.max(open, close) + r2 * 3 + 0.4) * 100) / 100;
|
|
36
|
+
const low = Math.round((Math.min(open, close) - (1 - r2) * 3 - 0.4) * 100) / 100;
|
|
37
|
+
p = close;
|
|
38
|
+
return { label: `Oct ${i + 6}`, open, high, low, close };
|
|
39
|
+
});
|
|
40
|
+
})();
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
title = 'ACME / USD',
|
|
44
|
+
subtitle = 'Daily candles',
|
|
45
|
+
candles = demo,
|
|
46
|
+
prefix = '$',
|
|
47
|
+
height = 300,
|
|
48
|
+
variant = 'glass',
|
|
49
|
+
size = 'md',
|
|
50
|
+
className = '',
|
|
51
|
+
} = Astro.props;
|
|
52
|
+
|
|
53
|
+
const W = 640;
|
|
54
|
+
const H = height;
|
|
55
|
+
const m = { t: 12, r: 52, b: 28, l: 12 };
|
|
56
|
+
const ticks = niceTicks(Math.min(...candles.map((c) => c.low)), Math.max(...candles.map((c) => c.high)), 5);
|
|
57
|
+
const y = scaleLinear(ticks[0], ticks[ticks.length - 1], H - m.b, m.t);
|
|
58
|
+
const band = (W - m.l - m.r) / candles.length;
|
|
59
|
+
const bw = Math.max(3, band * 0.6);
|
|
60
|
+
const f = (v: number) => `${prefix}${v.toFixed(2)}`;
|
|
61
|
+
const last = candles[candles.length - 1];
|
|
62
|
+
const first = candles[0];
|
|
63
|
+
const change = ((last.close - first.open) / first.open) * 100;
|
|
64
|
+
const labelEvery = Math.ceil(candles.length / 6);
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
<ChartFrame
|
|
68
|
+
title={title}
|
|
69
|
+
subtitle={subtitle}
|
|
70
|
+
value={f(last.close)}
|
|
71
|
+
delta={`${change >= 0 ? '+' : ''}${change.toFixed(2)}%`}
|
|
72
|
+
deltaPositive={change >= 0}
|
|
73
|
+
variant={variant}
|
|
74
|
+
size={size}
|
|
75
|
+
className={className}
|
|
76
|
+
legend={[{ label: 'Up (hollow)', color: POSITIVE }, { label: 'Down (filled)', color: NEGATIVE }]}
|
|
77
|
+
table={{ headers: ['Date', 'Open', 'High', 'Low', 'Close'], rows: candles.map((c) => [c.label, f(c.open), f(c.high), f(c.low), f(c.close)]) }}
|
|
78
|
+
>
|
|
79
|
+
<svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label={`${title}: candlestick chart, ${candles.length} periods, ${change.toFixed(1)}% change`}>
|
|
80
|
+
{ticks.map((t) => (
|
|
81
|
+
<g>
|
|
82
|
+
<line class="cf-grid" x1={m.l} x2={W - m.r} y1={y(t)} y2={y(t)} />
|
|
83
|
+
<text class="cf-label" x={W - m.r + 8} y={y(t) + 4}>{f(t)}</text>
|
|
84
|
+
</g>
|
|
85
|
+
))}
|
|
86
|
+
{candles.map((c, i) => {
|
|
87
|
+
const cx = m.l + i * band + band / 2;
|
|
88
|
+
const up = c.close >= c.open;
|
|
89
|
+
const col = up ? POSITIVE : NEGATIVE;
|
|
90
|
+
const top = y(Math.max(c.open, c.close));
|
|
91
|
+
const h = Math.max(1.5, Math.abs(y(c.open) - y(c.close)));
|
|
92
|
+
return (
|
|
93
|
+
<g class="cf-mark cf-dim" tabindex="0" role="img"
|
|
94
|
+
aria-label={`${c.label}: open ${f(c.open)}, high ${f(c.high)}, low ${f(c.low)}, close ${f(c.close)}`}
|
|
95
|
+
data-tip-title={c.label} data-tip={`${col}::${up ? 'Up' : 'Down'} ${(((c.close - c.open) / c.open) * 100).toFixed(2)}%|O ${f(c.open)} · H ${f(c.high)}|L ${f(c.low)} · C ${f(c.close)}`}>
|
|
96
|
+
<rect x={cx - band / 2} y={m.t} width={band} height={H - m.t - m.b} fill="transparent" />
|
|
97
|
+
<line x1={cx} x2={cx} y1={y(c.high)} y2={y(c.low)} stroke={col} stroke-width="1.5" />
|
|
98
|
+
<rect x={cx - bw / 2} y={top} width={bw} height={h} rx="1.5" fill={up ? 'var(--chart-surface, #0d0d0f)' : col} stroke={col} stroke-width="1.5" />
|
|
99
|
+
{i % labelEvery === 0 && <text class="cf-label" x={cx} y={H - 8} text-anchor="middle">{c.label}</text>}
|
|
100
|
+
</g>
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
<line x1={m.l} x2={W - m.r} y1={y(last.close)} y2={y(last.close)} stroke="var(--c-text-1, #fff)" stroke-opacity="0.3" stroke-dasharray="3 4" aria-hidden="true" />
|
|
104
|
+
</svg>
|
|
105
|
+
</ChartFrame>
|