v0.1 public beta early access on GitHub
Home / Screens / ecommerce-flash-sale
Screen template

Flash Sale

Flash sale grid: live countdown, discount badges, claimed-stock bars, cart additions

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light
$ npx lumioui add ecommerce-flash-sale
import { FlashSaleScreen } from "@/screens/ecommerce/flash-sale";
Registry dependencies6
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
ecommerce/flash-sale.tsxsource · yours to edit
import * as React from "react";
import { useState } from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Countdown, Glass, Icon, Image, Progress, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, Mount, Press, catalogImg, type CatalogPhoto } from "../shared";

interface Deal {
  id: string;
  name: string;
  price: number;
  was: number;
  photo: CatalogPhoto;
  /** Fraction already sold, 0–1 — drives the "claimed" bar. */
  claimed: number;
  left: number;
}

const DEALS: Deal[] = [
  { id: "d1", name: "Wool Overcoat", price: 174, was: 320, photo: "overcoat", claimed: 0.86, left: 7 },
  { id: "d2", name: "Volt Runner", price: 98, was: 160, photo: "runner", claimed: 0.72, left: 13 },
  { id: "d3", name: "Court Sneaker", price: 84, was: 120, photo: "sneakers", claimed: 0.64, left: 21 },
  { id: "d4", name: "Lace-Up Boots", price: 139, was: 240, photo: "boots", claimed: 0.91, left: 4 },
  { id: "d5", name: "Quilted Puffer", price: 129, was: 210, photo: "puffer", claimed: 0.58, left: 17 },
  { id: "d6", name: "Sherpa Denim", price: 96, was: 150, photo: "denimJacket", claimed: 0.77, left: 11 },
];

export interface FlashSaleScreenProps {
  deals?: Deal[];
  endsAt?: Date | number;
  onAddToCart?: (deal: Deal) => void;
  onBack?: () => void;
}

/** Flash sale — countdown-driven urgency grid: a ticking clock in the
 *  header, discount badges, struck prices, and a "claimed" bar per deal.
 *  Tapping a deal adds it to the cart badge. */
export function FlashSaleScreen({
  deals = DEALS,
  endsAt,
  onAddToCart,
  onBack,
}: FlashSaleScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const target = React.useMemo(
    () => endsAt ?? Date.now() + 1000 * 60 * 60 * 5 + 1000 * 60 * 23,
    [endsAt]
  );
  const [cart, setCart] = useState(0);
  const [added, setAdded] = useState<Set<string>>(new Set());

  const add = (deal: Deal) => {
    haptics.light();
    setAdded((s) => {
      const next = new Set(s);
      if (!next.has(deal.id)) {
        next.add(deal.id);
        setCart((c) => c + 1);
        onAddToCart?.(deal);
      }
      return next;
    });
  };

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + cart disc. */}
      <View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
        <View className="flex-row items-center justify-between">
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={onBack}
              accessibilityRole="button"
              accessibilityLabel="Back"
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Press>
          </Glass>
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              accessibilityRole="button"
              accessibilityLabel={cart > 0 ? `Cart, ${cart} items` : "Cart"}
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="shopping-cart" size="sm" color="foreground" />
            </Press>
            {cart > 0 ? (
              <View className="absolute -right-1 -top-1 h-5 min-w-5 items-center justify-center rounded-full bg-[#BEF04C] px-1">
                <Text className="text-[10px] font-bold text-[#1B1B26]">
                  {cart}
                </Text>
              </View>
            ) : null}
          </Glass>
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <LumioMark size={18} />
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Flash <Text className="italic text-[#65A30D]">Sale</Text>
            </Text>
          </View>
        </View>
      </View>

      {/* Urgency hero — the ticking clock is the whole point of the page. */}
      <View className="mx-6 mb-4 flex-row items-center justify-between overflow-hidden rounded-3xl bg-[#1B1B26] px-5 py-4" style={{ marginTop: insets.top + 60 }}>
        <Glass interactive effect="regular" sheen={0.4} tintColor="#FFFFFF14" className="absolute inset-0 rounded-3xl" pointerEvents="none" />
        <Mount delay={60}>
          <Text variant="muted" className="text-white/60">
            Deal ends in
          </Text>
          <Countdown
            to={target}
            format="auto"
            textClassName="text-white text-2xl font-bold"
          />
        </Mount>
        <Mount delay={120} className="items-end gap-1">
          <View className="rounded-full bg-[#BEF04C] px-2.5 py-1">
            <Text className="text-[11px] font-bold text-[#1B1B26]">
              {`Up to -${Math.max(...deals.map((d) => Math.round((1 - d.price / d.was) * 100)))}%`}
            </Text>
          </View>
          <Text variant="small" className="text-white/60">
            {deals.length} deals live
          </Text>
        </Mount>
      </View>

      {/* Members-first nudge — flash-sale pages monetize urgency. */}
      <Mount delay={150}>
        <View className="mx-6 mb-3 flex-row items-center gap-2 overflow-hidden rounded-2xl bg-[#EDF8C4] px-4 py-2.5 dark:bg-[#1E2410]">
          <Icon name="zap" size="sm" color="#65A30D" />
          <Text variant="small" className="flex-1 text-xs">
            Members saw these prices 30 minutes ago
          </Text>
          <Text variant="small" className="font-semibold text-[#65A30D]">
            Join
          </Text>
        </View>
      </Mount>

      <ScrollView
        className="flex-1"
        contentContainerClassName="px-6 pb-8"
        showsVerticalScrollIndicator={false}
      >
        <Mount delay={180} className="flex-row flex-wrap justify-between gap-y-5">
          {deals.map((d) => {
            const off = Math.round((1 - d.price / d.was) * 100);
            const inCart = added.has(d.id);
            return (
              <Press
                key={d.id}
                pressedScale={0.97}
                onPress={() => add(d)}
                accessibilityRole="button"
                accessibilityLabel={`${d.name}, $${d.price}, was $${d.was}`}
                className="w-[48%]"
              >
                <View className="overflow-hidden rounded-2xl bg-muted">
                  <Image
                    source={{ uri: catalogImg(d.photo, 400, 480) }}
                    className="h-40 w-full"
                    accessibilityLabel={d.name}
                  />
                  <View className="absolute left-2 top-2 rounded-full bg-[#BEF04C] px-2 py-0.5">
                    <Text variant="small" className="font-bold text-[#1B1B26]">
                      -{off}%
                    </Text>
                  </View>
                  {inCart ? (
                    <View className="absolute right-2 top-2 h-6 w-6 items-center justify-center rounded-full bg-[#1B1B26]">
                      <Icon name="check" size="sm" color="#BEF04C" />
                    </View>
                  ) : null}
                </View>
                <Text variant="large" numberOfLines={1} className="pt-2">
                  {d.name}
                </Text>
                <View className="flex-row items-baseline gap-2 pb-1">
                  <Text variant="large">${d.price}</Text>
                  <Text variant="muted" className="line-through">
                    ${d.was}
                  </Text>
                </View>
                <Progress value={Math.round(d.claimed * 100)} className="h-1" indicatorClassName="bg-[#65A30D]" />
                <Text variant="small" className="pt-1 text-muted-foreground">
                  {Math.round(d.claimed * 100)}% claimed · {d.left} left
                </Text>
              </Press>
            );
          })}
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
FlashSaleScreen.displayName = "FlashSaleScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Flash Sale" screen in React Native using LumioUI.

Goal: Flash sale grid: live countdown, discount badges, claimed-stock bars, cart additions Match the reference implementation's layout, behavior, and motion exactly — this is a production screen, not a mockup.

## Setup

Fastest path — install the screen plus its component deps:

```bash
npx lumioui add ecommerce-flash-sale
```

Or pull just the components: `npx lumioui add badge countdown icon image progress text`

Native packages:
- @lumioui/ui@latest
- @lumioui/core@latest
- react-native-safe-area-context@*
- react-native-reanimated@*
- react-native-svg@*
- nativewind@*

Stack assumptions: Expo SDK 54 / RN 0.81, Reanimated 4, NativeWind v4, TypeScript strict, Expo Go compatible.

## Components — how, where, when

### `badge` — Compact status pill with variants, icons and pulse option.
- imported but not rendered directly — likely used through a sibling or as a utility

### `countdown` — Live countdown with per-digit tick animation, compact and labeled-block layouts, completion haptic.
- `<Countdown>` ×1

### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×4

### `image` — Cached image with placeholder, fallback and aspect handling.
- `<Image>` ×1

### `progress` — Animated fill bar with indeterminate sweep mode.
- `<Progress>` ×1

### `text` — Themed type scale from caption to display.
- `<Text>` ×13

## Conventions (non-negotiable)

- Styling via NativeWind `className` with semantic tokens only: `bg-background`, `text-foreground`, `bg-card`, `text-card-foreground`, `bg-secondary`, `bg-muted`, `text-muted-foreground`, `bg-accent`, `bg-destructive`, `border-border`. Hard-coded colors only inside media overlays (`text-white`, `bg-black/N`).
- Motion via the token presets from `@lumioui/core` (`spring.press`, `spring.surface`, `spring.glide`, `timing.fast`, `timing.slow`, …) — no bespoke spring configs or durations.
- Gate transform motion behind `useReducedMotion()`; keep opacity/color feedback, drop travel and overshoot.
- Haptics via `useHaptic()`: `light` on press, `selection` on toggle/select, `warning` on invalid input. Never import expo-haptics directly.
- Press feedback via `usePressAnimation()` (~0.97 scale), not `activeOpacity` tricks.
- a11y: `accessibilityRole` + `accessibilityLabel` on every control, touch targets ≥44pt.
- Entrance choreography: staggered `Mount` wrappers (delay 0/60/120…) so regions land in sequence instead of popping in at once.
- Wrap the screen in `SafeAreaView`; keep dark mode working via the semantic tokens.

## Deliverable

One file: `screens/ecommerce/flash-sale.tsx` exporting FlashSaleScreen. Preserve the props interface — the host app wires the callbacks (navigation, submit handlers) through them.

## Reference implementation

The LumioUI source for this screen — reproduce it faithfully:

```tsx
import * as React from "react";
import { useState } from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Countdown, Glass, Icon, Image, Progress, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, Mount, Press, catalogImg, type CatalogPhoto } from "../shared";

interface Deal {
  id: string;
  name: string;
  price: number;
  was: number;
  photo: CatalogPhoto;
  /** Fraction already sold, 0–1 — drives the "claimed" bar. */
  claimed: number;
  left: number;
}

const DEALS: Deal[] = [
  { id: "d1", name: "Wool Overcoat", price: 174, was: 320, photo: "overcoat", claimed: 0.86, left: 7 },
  { id: "d2", name: "Volt Runner", price: 98, was: 160, photo: "runner", claimed: 0.72, left: 13 },
  { id: "d3", name: "Court Sneaker", price: 84, was: 120, photo: "sneakers", claimed: 0.64, left: 21 },
  { id: "d4", name: "Lace-Up Boots", price: 139, was: 240, photo: "boots", claimed: 0.91, left: 4 },
  { id: "d5", name: "Quilted Puffer", price: 129, was: 210, photo: "puffer", claimed: 0.58, left: 17 },
  { id: "d6", name: "Sherpa Denim", price: 96, was: 150, photo: "denimJacket", claimed: 0.77, left: 11 },
];

export interface FlashSaleScreenProps {
  deals?: Deal[];
  endsAt?: Date | number;
  onAddToCart?: (deal: Deal) => void;
  onBack?: () => void;
}

/** Flash sale — countdown-driven urgency grid: a ticking clock in the
 *  header, discount badges, struck prices, and a "claimed" bar per deal.
 *  Tapping a deal adds it to the cart badge. */
export function FlashSaleScreen({
  deals = DEALS,
  endsAt,
  onAddToCart,
  onBack,
}: FlashSaleScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const target = React.useMemo(
    () => endsAt ?? Date.now() + 1000 * 60 * 60 * 5 + 1000 * 60 * 23,
    [endsAt]
  );
  const [cart, setCart] = useState(0);
  const [added, setAdded] = useState<Set<string>>(new Set());

  const add = (deal: Deal) => {
    haptics.light();
    setAdded((s) => {
      const next = new Set(s);
      if (!next.has(deal.id)) {
        next.add(deal.id);
        setCart((c) => c + 1);
        onAddToCart?.(deal);
      }
      return next;
    });
  };

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + cart disc. */}
      <View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
        <View className="flex-row items-center justify-between">
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={onBack}
              accessibilityRole="button"
              accessibilityLabel="Back"
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Press>
          </Glass>
          <Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
            <Press
              accessibilityRole="button"
              accessibilityLabel={cart > 0 ? `Cart, ${cart} items` : "Cart"}
              className="h-9 w-9 items-center justify-center"
            >
              <Icon name="shopping-cart" size="sm" color="foreground" />
            </Press>
            {cart > 0 ? (
              <View className="absolute -right-1 -top-1 h-5 min-w-5 items-center justify-center rounded-full bg-[#BEF04C] px-1">
                <Text className="text-[10px] font-bold text-[#1B1B26]">
                  {cart}
                </Text>
              </View>
            ) : null}
          </Glass>
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
            <Glass effect="regular" className="absolute inset-0 rounded-full" />
            <LumioMark size={18} />
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Flash <Text className="italic text-[#65A30D]">Sale</Text>
            </Text>
          </View>
        </View>
      </View>

      {/* Urgency hero — the ticking clock is the whole point of the page. */}
      <View className="mx-6 mb-4 flex-row items-center justify-between overflow-hidden rounded-3xl bg-[#1B1B26] px-5 py-4" style={{ marginTop: insets.top + 60 }}>
        <Glass interactive effect="regular" sheen={0.4} tintColor="#FFFFFF14" className="absolute inset-0 rounded-3xl" pointerEvents="none" />
        <Mount delay={60}>
          <Text variant="muted" className="text-white/60">
            Deal ends in
          </Text>
          <Countdown
            to={target}
            format="auto"
            textClassName="text-white text-2xl font-bold"
          />
        </Mount>
        <Mount delay={120} className="items-end gap-1">
          <View className="rounded-full bg-[#BEF04C] px-2.5 py-1">
            <Text className="text-[11px] font-bold text-[#1B1B26]">
              {`Up to -${Math.max(...deals.map((d) => Math.round((1 - d.price / d.was) * 100)))}%`}
            </Text>
          </View>
          <Text variant="small" className="text-white/60">
            {deals.length} deals live
          </Text>
        </Mount>
      </View>

      {/* Members-first nudge — flash-sale pages monetize urgency. */}
      <Mount delay={150}>
        <View className="mx-6 mb-3 flex-row items-center gap-2 overflow-hidden rounded-2xl bg-[#EDF8C4] px-4 py-2.5 dark:bg-[#1E2410]">
          <Icon name="zap" size="sm" color="#65A30D" />
          <Text variant="small" className="flex-1 text-xs">
            Members saw these prices 30 minutes ago
          </Text>
          <Text variant="small" className="font-semibold text-[#65A30D]">
            Join
          </Text>
        </View>
      </Mount>

      <ScrollView
        className="flex-1"
        contentContainerClassName="px-6 pb-8"
        showsVerticalScrollIndicator={false}
      >
        <Mount delay={180} className="flex-row flex-wrap justify-between gap-y-5">
          {deals.map((d) => {
            const off = Math.round((1 - d.price / d.was) * 100);
            const inCart = added.has(d.id);
            return (
              <Press
                key={d.id}
                pressedScale={0.97}
                onPress={() => add(d)}
                accessibilityRole="button"
                accessibilityLabel={`${d.name}, $${d.price}, was $${d.was}`}
                className="w-[48%]"
              >
                <View className="overflow-hidden rounded-2xl bg-muted">
                  <Image
                    source={{ uri: catalogImg(d.photo, 400, 480) }}
                    className="h-40 w-full"
                    accessibilityLabel={d.name}
                  />
                  <View className="absolute left-2 top-2 rounded-full bg-[#BEF04C] px-2 py-0.5">
                    <Text variant="small" className="font-bold text-[#1B1B26]">
                      -{off}%
                    </Text>
                  </View>
                  {inCart ? (
                    <View className="absolute right-2 top-2 h-6 w-6 items-center justify-center rounded-full bg-[#1B1B26]">
                      <Icon name="check" size="sm" color="#BEF04C" />
                    </View>
                  ) : null}
                </View>
                <Text variant="large" numberOfLines={1} className="pt-2">
                  {d.name}
                </Text>
                <View className="flex-row items-baseline gap-2 pb-1">
                  <Text variant="large">${d.price}</Text>
                  <Text variant="muted" className="line-through">
                    ${d.was}
                  </Text>
                </View>
                <Progress value={Math.round(d.claimed * 100)} className="h-1" indicatorClassName="bg-[#65A30D]" />
                <Text variant="small" className="pt-1 text-muted-foreground">
                  {Math.round(d.claimed * 100)}% claimed · {d.left} left
                </Text>
              </Press>
            );
          })}
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
FlashSaleScreen.displayName = "FlashSaleScreen";
```

Screen: https://lumioui.dev/screens/ecommerce-flash-sale
iPhone 17 · iOS
9:41
Live preview — the real screen via Expo Web · open full ↗