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,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ProductToolbar — Catalog heading bar: title, live result count and a sort select
|
|
4
|
+
* (built on ModernSelect) that drives FilterSidebar's sorting.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} title - Page heading. Default 'All products'.
|
|
7
|
+
* @param {string} description - Optional supporting copy.
|
|
8
|
+
* @param {number} total - Initial product count. Default 0.
|
|
9
|
+
* @param {string} target - ProductGrid id. Default 'product-grid'.
|
|
10
|
+
* @param {string} filtersId - FilterSidebar form id (sort select becomes `${filtersId}-sort`). Default 'catalog-filters'.
|
|
11
|
+
* @param {Array<{label: string, value: string}>} sortOptions - Sort choices (values: featured|price-asc|price-desc|rating|name).
|
|
12
|
+
* @param {string} countLabel - Text after the count. Default 'products'.
|
|
13
|
+
* @param {string} headingLevel - Title element (h1|h2). Default 'h1'.
|
|
14
|
+
* @param {string} variant - Layout (split|stacked). Default 'split'.
|
|
15
|
+
* @param {string} className - Extra class.
|
|
16
|
+
*
|
|
17
|
+
* Accessibility: the count lives in a polite live region so filter changes are announced.
|
|
18
|
+
*/
|
|
19
|
+
import ModernSelect from '../forms/ModernSelect.astro';
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
total?: number;
|
|
25
|
+
target?: string;
|
|
26
|
+
filtersId?: string;
|
|
27
|
+
sortOptions?: Array<{ label: string; value: string }>;
|
|
28
|
+
countLabel?: string;
|
|
29
|
+
headingLevel?: 'h1' | 'h2';
|
|
30
|
+
variant?: 'split' | 'stacked';
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
title = 'All products',
|
|
36
|
+
description,
|
|
37
|
+
total = 0,
|
|
38
|
+
target = 'product-grid',
|
|
39
|
+
filtersId = 'catalog-filters',
|
|
40
|
+
sortOptions = [
|
|
41
|
+
{ label: 'Featured', value: 'featured' },
|
|
42
|
+
{ label: 'Price: low to high', value: 'price-asc' },
|
|
43
|
+
{ label: 'Price: high to low', value: 'price-desc' },
|
|
44
|
+
{ label: 'Top rated', value: 'rating' },
|
|
45
|
+
{ label: 'Name A–Z', value: 'name' },
|
|
46
|
+
],
|
|
47
|
+
countLabel = 'products',
|
|
48
|
+
headingLevel = 'h1',
|
|
49
|
+
variant = 'split',
|
|
50
|
+
className = '',
|
|
51
|
+
} = Astro.props;
|
|
52
|
+
|
|
53
|
+
const Heading = headingLevel;
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
<div class="p-toolbar-cq">
|
|
57
|
+
<div class:list={['p-toolbar', `p-toolbar--${variant}`, className]}>
|
|
58
|
+
<div class="p-toolbar__text">
|
|
59
|
+
<Heading class="p-toolbar__title">{title}</Heading>
|
|
60
|
+
{description && <p class="p-toolbar__desc">{description}</p>}
|
|
61
|
+
<p class="p-toolbar__count" aria-live="polite">
|
|
62
|
+
<span data-result-count={target}>{total}</span> {countLabel}
|
|
63
|
+
</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="p-toolbar__sort">
|
|
66
|
+
<ModernSelect label="Sort by" id={`${filtersId}-sort`} name="sort" options={sortOptions} />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.p-toolbar-cq { container-type: inline-size; }
|
|
73
|
+
.p-toolbar {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: flex-end;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
gap: var(--sp-6, 1.5rem);
|
|
78
|
+
padding-bottom: var(--sp-5, 1.25rem);
|
|
79
|
+
margin-bottom: var(--sp-6, 1.5rem);
|
|
80
|
+
border-bottom: 1px solid var(--c-border, rgb(var(--ink-rgb, 255 255 255) / 0.05));
|
|
81
|
+
}
|
|
82
|
+
.p-toolbar--stacked { flex-direction: column; align-items: stretch; }
|
|
83
|
+
.p-toolbar__title { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 900; letter-spacing: -0.035em; color: var(--c-text-1, #fff); }
|
|
84
|
+
.p-toolbar__desc { max-width: 40rem; margin: var(--sp-2, 0.5rem) 0 0; color: var(--c-text-2, #a3a3a3); }
|
|
85
|
+
.p-toolbar__count { margin: var(--sp-2, 0.5rem) 0 0; font-size: 0.85rem; color: var(--c-text-2, #a3a3a3); }
|
|
86
|
+
.p-toolbar__count span { color: var(--c-text-1, #fff); font-weight: 700; }
|
|
87
|
+
.p-toolbar__sort { width: 220px; flex-shrink: 0; }
|
|
88
|
+
|
|
89
|
+
@container (max-width: 640px) {
|
|
90
|
+
.p-toolbar { flex-direction: column; align-items: stretch; }
|
|
91
|
+
.p-toolbar__sort { width: 100%; }
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* PromoBar — Slim announcement bar for shipping offers, sales or codes,
|
|
4
|
+
* with rotating messages and an optional dismiss button.
|
|
5
|
+
*
|
|
6
|
+
* @param {string[]} messages - One or more messages; several rotate every `interval` ms.
|
|
7
|
+
* @param {string} href - Optional link for the whole bar.
|
|
8
|
+
* @param {number} interval - Rotation interval in ms. Default 4500.
|
|
9
|
+
* @param {boolean} dismissible - Show a close button (remembered per session). Default true.
|
|
10
|
+
* @param {string} variant - Style (gold|glass|dark). Default 'gold'.
|
|
11
|
+
* @param {string} size - Height (sm|md). Default 'sm'.
|
|
12
|
+
* @param {string} storageKey - sessionStorage key for the dismissed state. Default 'ack-promo-closed'.
|
|
13
|
+
* @param {string} className - Extra class.
|
|
14
|
+
*
|
|
15
|
+
* Accessibility: rotation pauses on hover/focus and is disabled with reduced motion;
|
|
16
|
+
* messages live in a polite live region only after the user interacts, never on load.
|
|
17
|
+
*/
|
|
18
|
+
interface Props {
|
|
19
|
+
messages?: string[];
|
|
20
|
+
href?: string;
|
|
21
|
+
interval?: number;
|
|
22
|
+
dismissible?: boolean;
|
|
23
|
+
variant?: 'gold' | 'glass' | 'dark';
|
|
24
|
+
size?: 'sm' | 'md';
|
|
25
|
+
storageKey?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
messages = ['Free shipping on orders over $75', 'Use code ASTRO10 for 10% off your first order', '30-day free returns'],
|
|
31
|
+
href,
|
|
32
|
+
interval = 4500,
|
|
33
|
+
dismissible = true,
|
|
34
|
+
variant = 'gold',
|
|
35
|
+
size = 'sm',
|
|
36
|
+
storageKey = 'ack-promo-closed',
|
|
37
|
+
className = '',
|
|
38
|
+
} = Astro.props;
|
|
39
|
+
|
|
40
|
+
const Tag = href ? 'a' : 'div';
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<div class:list={['promo-bar', `promo-bar--${variant}`, `promo-bar--${size}`, className]} data-promo-bar data-interval={interval} data-key={storageKey}>
|
|
44
|
+
<Tag class="promo-bar__track" href={href}>
|
|
45
|
+
{messages.map((m, i) => (
|
|
46
|
+
<span class:list={['promo-bar__msg', { 'is-active': i === 0 }]} aria-hidden={i === 0 ? undefined : 'true'}>{m}</span>
|
|
47
|
+
))}
|
|
48
|
+
</Tag>
|
|
49
|
+
{dismissible && (
|
|
50
|
+
<button class="promo-bar__close" type="button" aria-label="Dismiss announcement" data-promo-close>
|
|
51
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg>
|
|
52
|
+
</button>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
document.querySelectorAll<HTMLElement>('[data-promo-bar]').forEach((bar) => {
|
|
58
|
+
const key = bar.dataset.key || 'ack-promo-closed';
|
|
59
|
+
try {
|
|
60
|
+
if (window.sessionStorage.getItem(key)) { bar.hidden = true; return; }
|
|
61
|
+
} catch { /* storage blocked */ }
|
|
62
|
+
|
|
63
|
+
bar.querySelector('[data-promo-close]')?.addEventListener('click', () => {
|
|
64
|
+
bar.hidden = true;
|
|
65
|
+
try { window.sessionStorage.setItem(key, '1'); } catch { /* ignore */ }
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const msgs = Array.from(bar.querySelectorAll<HTMLElement>('.promo-bar__msg'));
|
|
69
|
+
if (msgs.length < 2 || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
70
|
+
let index = 0;
|
|
71
|
+
let paused = false;
|
|
72
|
+
bar.addEventListener('mouseenter', () => { paused = true; });
|
|
73
|
+
bar.addEventListener('mouseleave', () => { paused = false; });
|
|
74
|
+
bar.addEventListener('focusin', () => { paused = true; });
|
|
75
|
+
bar.addEventListener('focusout', () => { paused = false; });
|
|
76
|
+
window.setInterval(() => {
|
|
77
|
+
if (paused || document.hidden) return;
|
|
78
|
+
msgs[index].classList.remove('is-active');
|
|
79
|
+
msgs[index].setAttribute('aria-hidden', 'true');
|
|
80
|
+
index = (index + 1) % msgs.length;
|
|
81
|
+
msgs[index].classList.add('is-active');
|
|
82
|
+
msgs[index].removeAttribute('aria-hidden');
|
|
83
|
+
}, Number(bar.dataset.interval) || 4500);
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
.promo-bar {
|
|
89
|
+
position: relative;
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
min-height: 36px;
|
|
94
|
+
padding: 0 48px;
|
|
95
|
+
font-size: 0.8rem;
|
|
96
|
+
font-weight: 600;
|
|
97
|
+
letter-spacing: 0.01em;
|
|
98
|
+
}
|
|
99
|
+
.promo-bar[hidden] { display: none; }
|
|
100
|
+
.promo-bar--md { min-height: 44px; font-size: 0.875rem; }
|
|
101
|
+
.promo-bar--gold { background: linear-gradient(90deg, #b8860b, #d4a017, #b8860b); color: #140f00; }
|
|
102
|
+
.promo-bar--glass { background: rgb(var(--ink-rgb, 255 255 255) / 0.04); border-bottom: 1px solid var(--c-border, rgb(var(--ink-rgb, 255 255 255) / 0.05)); color: var(--c-text-1, #fff); }
|
|
103
|
+
.promo-bar--dark { background: var(--c-bg-2, #111); color: var(--c-text-1, #fff); }
|
|
104
|
+
|
|
105
|
+
.promo-bar__track {
|
|
106
|
+
display: grid;
|
|
107
|
+
place-items: center;
|
|
108
|
+
width: 100%;
|
|
109
|
+
color: inherit;
|
|
110
|
+
text-decoration: none;
|
|
111
|
+
}
|
|
112
|
+
a.promo-bar__track:hover { text-decoration: underline; color: inherit; }
|
|
113
|
+
.promo-bar__msg {
|
|
114
|
+
grid-area: 1 / 1;
|
|
115
|
+
text-align: center;
|
|
116
|
+
opacity: 0;
|
|
117
|
+
transform: translateY(6px);
|
|
118
|
+
transition: opacity 0.4s ease, transform 0.4s ease;
|
|
119
|
+
pointer-events: none;
|
|
120
|
+
}
|
|
121
|
+
.promo-bar__msg.is-active { opacity: 1; transform: none; pointer-events: auto; }
|
|
122
|
+
|
|
123
|
+
.promo-bar__close {
|
|
124
|
+
position: absolute;
|
|
125
|
+
right: 4px;
|
|
126
|
+
top: 50%;
|
|
127
|
+
transform: translateY(-50%);
|
|
128
|
+
display: grid;
|
|
129
|
+
place-items: center;
|
|
130
|
+
width: 36px;
|
|
131
|
+
height: 36px;
|
|
132
|
+
border: 0;
|
|
133
|
+
border-radius: var(--r-full, 9999px);
|
|
134
|
+
background: transparent;
|
|
135
|
+
color: inherit;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
opacity: 0.75;
|
|
138
|
+
}
|
|
139
|
+
.promo-bar__close:hover { opacity: 1; background: rgba(0, 0, 0, 0.1); }
|
|
140
|
+
.promo-bar__close:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
|
|
141
|
+
|
|
142
|
+
@media (prefers-reduced-motion: reduce) {
|
|
143
|
+
.promo-bar__msg { transition: none; }
|
|
144
|
+
}
|
|
145
|
+
</style>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* StockIndicator — Urgency notice for product pages: low-stock bar ("Only 3 left") and a
|
|
4
|
+
* live "N people are viewing this" counter that drifts gently.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} stock - Units left. Default 3.
|
|
7
|
+
* @param {number} threshold - At or below this value the low-stock style is used. Default 5.
|
|
8
|
+
* @param {number} capacity - Value that fills the bar completely. Default 20.
|
|
9
|
+
* @param {number} viewers - Starting number of viewers (0 hides the line). Default 14.
|
|
10
|
+
* @param {boolean} live - Let the viewers count move every few seconds. Default true.
|
|
11
|
+
* @param {string} variant - Style (card|inline). Default 'card'.
|
|
12
|
+
* @param {string} size - Density (sm|md). Default 'md'.
|
|
13
|
+
* @param {string} className - Extra class.
|
|
14
|
+
*
|
|
15
|
+
* Accessibility: stock text is real text (not colour alone); the moving viewers number is not
|
|
16
|
+
* announced (aria-live off) to avoid noise; animation stops with prefers-reduced-motion.
|
|
17
|
+
*/
|
|
18
|
+
interface Props {
|
|
19
|
+
stock?: number;
|
|
20
|
+
threshold?: number;
|
|
21
|
+
capacity?: number;
|
|
22
|
+
viewers?: number;
|
|
23
|
+
live?: boolean;
|
|
24
|
+
variant?: 'card' | 'inline';
|
|
25
|
+
size?: 'sm' | 'md';
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
stock = 3,
|
|
31
|
+
threshold = 5,
|
|
32
|
+
capacity = 20,
|
|
33
|
+
viewers = 14,
|
|
34
|
+
live = true,
|
|
35
|
+
variant = 'card',
|
|
36
|
+
size = 'md',
|
|
37
|
+
className = '',
|
|
38
|
+
} = Astro.props;
|
|
39
|
+
|
|
40
|
+
const low = stock > 0 && stock <= threshold;
|
|
41
|
+
const state = stock <= 0 ? 'out' : low ? 'low' : 'ok';
|
|
42
|
+
const pct = Math.max(4, Math.min(100, (stock / capacity) * 100));
|
|
43
|
+
const message = state === 'out' ? 'Sold out — join the waitlist' : low ? `Only ${stock} left — order soon` : 'In stock and ready to ship';
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
<div class:list={['stock', `stock--${state}`, `stock--${variant}`, `stock--${size}`, className]} data-stock-indicator data-viewers={viewers} data-live={live ? '' : undefined}>
|
|
47
|
+
<p class="stock__msg">
|
|
48
|
+
<span class="stock__icon" aria-hidden="true">
|
|
49
|
+
{state === 'ok'
|
|
50
|
+
? <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
|
|
51
|
+
: <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2 3 14h9l-1 8 10-12h-9z"/></svg>}
|
|
52
|
+
</span>
|
|
53
|
+
<strong>{message}</strong>
|
|
54
|
+
</p>
|
|
55
|
+
{state !== 'out' && (
|
|
56
|
+
<div class="stock__bar" aria-hidden="true"><span style={`width: ${pct}%`}></span></div>
|
|
57
|
+
)}
|
|
58
|
+
{viewers > 0 && (
|
|
59
|
+
<p class="stock__viewers" aria-live="off">
|
|
60
|
+
<span class="stock__eye" aria-hidden="true">
|
|
61
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg>
|
|
62
|
+
</span>
|
|
63
|
+
<span><strong data-viewers-count>{viewers}</strong> people are viewing this right now</span>
|
|
64
|
+
</p>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
document.querySelectorAll<HTMLElement>('[data-stock-indicator][data-live]:not([data-bound])').forEach((el) => {
|
|
70
|
+
el.dataset.bound = '';
|
|
71
|
+
const out = el.querySelector<HTMLElement>('[data-viewers-count]');
|
|
72
|
+
if (!out || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
73
|
+
const base = Number(el.dataset.viewers) || 0;
|
|
74
|
+
let value = base;
|
|
75
|
+
window.setInterval(() => {
|
|
76
|
+
if (document.hidden) return;
|
|
77
|
+
const step = Math.random() < 0.5 ? -1 : 1;
|
|
78
|
+
value = Math.max(Math.max(1, base - 4), Math.min(base + 6, value + step));
|
|
79
|
+
out.textContent = String(value);
|
|
80
|
+
out.classList.remove('is-bump');
|
|
81
|
+
void out.offsetWidth;
|
|
82
|
+
out.classList.add('is-bump');
|
|
83
|
+
}, 6500);
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
.stock {
|
|
89
|
+
--stock-tone: var(--c-success, #34d399);
|
|
90
|
+
display: grid;
|
|
91
|
+
gap: var(--sp-2, 0.5rem);
|
|
92
|
+
}
|
|
93
|
+
.stock--low { --stock-tone: var(--c-warning, #fbbf24); }
|
|
94
|
+
.stock--out { --stock-tone: var(--c-danger, #f87171); }
|
|
95
|
+
.stock--card {
|
|
96
|
+
padding: var(--sp-4, 1rem);
|
|
97
|
+
border-radius: var(--r-md, 12px);
|
|
98
|
+
border: 1px solid color-mix(in srgb, var(--stock-tone) 30%, transparent);
|
|
99
|
+
background: color-mix(in srgb, var(--stock-tone) 7%, transparent);
|
|
100
|
+
}
|
|
101
|
+
.stock--sm.stock--card { padding: var(--sp-3, 0.75rem); }
|
|
102
|
+
|
|
103
|
+
.stock__msg { display: flex; align-items: center; gap: var(--sp-2, 0.5rem); margin: 0; font-size: 0.9rem; color: var(--c-text-1, #fff); }
|
|
104
|
+
.stock__icon {
|
|
105
|
+
display: grid;
|
|
106
|
+
place-items: center;
|
|
107
|
+
width: 26px;
|
|
108
|
+
height: 26px;
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
color: var(--stock-tone);
|
|
111
|
+
background: color-mix(in srgb, var(--stock-tone) 16%, transparent);
|
|
112
|
+
}
|
|
113
|
+
.stock--low .stock__icon { animation: stock-pulse 1.8s ease-in-out infinite; }
|
|
114
|
+
.stock__bar { height: 6px; border-radius: 999px; background: rgb(var(--ink-rgb, 255 255 255) / 0.08); overflow: hidden; }
|
|
115
|
+
.stock__bar span { display: block; height: 100%; border-radius: inherit; background: var(--stock-tone); }
|
|
116
|
+
.stock__viewers { display: flex; align-items: center; gap: var(--sp-2, 0.5rem); margin: 0; font-size: 0.8rem; color: var(--c-text-2, #a3a3a3); }
|
|
117
|
+
.stock__viewers strong { color: var(--c-text-1, #fff); display: inline-block; min-width: 1.2em; }
|
|
118
|
+
.stock__viewers strong.is-bump { animation: stock-bump 0.4s ease-out; }
|
|
119
|
+
.stock__eye { display: grid; place-items: center; color: var(--c-text-2, #a3a3a3); }
|
|
120
|
+
|
|
121
|
+
@keyframes stock-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--stock-tone) 12%, transparent); } }
|
|
122
|
+
@keyframes stock-bump { from { transform: translateY(-3px); opacity: 0.4; } }
|
|
123
|
+
|
|
124
|
+
@media (prefers-reduced-motion: reduce) {
|
|
125
|
+
.stock--low .stock__icon { animation: none; }
|
|
126
|
+
}
|
|
127
|
+
</style>
|