Sale Countdown Promo Bar
7ovr/announcement-4FreeBlock
Sticky promo announcement bar with a live sale countdown ticking days, hours, minutes, and seconds beside a shop the sale button.
Install it
npx shadcn@latest add https://7ovr.com/r/announcement-4.jsonSource
1"use client"23import { useEffect, useState } from "react"4import { Button } from "@/components/ui/button"5import { IconPlaceholder } from "@/components/icons/icon-placeholder"67const SALE_DURATION_MS =8 2 * 24 * 60 * 60 * 1000 + 11 * 60 * 60 * 1000 + 34 * 60 * 1000 + 12 * 1000910type TimeLeft = {11 days: number12 hours: number13 minutes: number14 seconds: number15}1617function getTimeLeft(diffMs: number): TimeLeft {18 const diff = Math.max(0, diffMs)19 const totalSeconds = Math.floor(diff / 1000)20 return {21 days: Math.floor(totalSeconds / 86400),22 hours: Math.floor((totalSeconds % 86400) / 3600),23 minutes: Math.floor((totalSeconds % 3600) / 60),24 seconds: totalSeconds % 60,25 }26}2728function pad(value: number): string {29 return value.toString().padStart(2, "0")30}3132export default function AnnouncementBlock() {33 const [timeLeft, setTimeLeft] = useState<TimeLeft>(() =>34 getTimeLeft(SALE_DURATION_MS)35 )3637 useEffect(() => {38 const deadline = Date.now() + SALE_DURATION_MS39 const interval = setInterval(() => {40 setTimeLeft(getTimeLeft(deadline - Date.now()))41 }, 1000)4243 return () => clearInterval(interval)44 }, [])4546 return (47 <section className="flex min-h-svh w-full flex-col bg-muted/30 text-foreground">48 <div className="w-full bg-primary text-primary-foreground">49 <div className="mx-auto flex w-full max-w-6xl flex-col items-center gap-3 px-6 py-3 sm:flex-row sm:justify-between">50 <div className="flex flex-col items-center gap-2.5 sm:flex-row sm:gap-3">51 <span className="flex items-center gap-2 text-sm font-semibold">52 <IconPlaceholder53 lucide="Flame"54 tabler="IconFlame"55 hugeicons="FireIcon"56 phosphor="Fire"57 remixicon="RiFireLine"58 className="size-4 shrink-0"59 aria-hidden="true"60 />61 Summer Sale, up to 40% off62 </span>63 <span className="hidden h-4 w-px bg-primary-foreground/30 sm:block" />64 <span className="flex items-center gap-2 text-sm">65 <span className="text-primary-foreground/80">Sale ends in</span>66 <span className="flex items-center gap-1 font-mono text-sm font-semibold tabular-nums">67 <span className="rounded-md bg-primary-foreground/15 px-1.5 py-0.5">68 {pad(timeLeft.days)}d69 </span>70// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from 7ovr
All 241 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Mission Statement With Statsabout-1 | 7ovr | Blocks | Free | 1 dep | |
| Founder Story With Photoabout-2 | 7ovr | Blocks | Free | 1 dep | |
| Values Card Gridabout-3 | 7ovr | Blocks | Free | 1 dep | |
| Mission Vision Values Columnsabout-4 | 7ovr | Blocks | Free | 1 dep | |
| Recent Activity Cardactivity-1 | 7ovr | Blocks | Free | 1 dep | |
| Activity Grouped By Dayactivity-2 | 7ovr | Blocks | Free | 1 dep | |
| Audit Log With Icon Tilesactivity-3 | 7ovr | Blocks | Free | 1 dep | |
| Activity Tabs With Unreadactivity-4 | 7ovr | Blocks | Free | 1 dep |
