Skip to content

Commit 26a732a

Browse files
committed
docs: add swag promo
1 parent 0563bb0 commit 26a732a

File tree

6 files changed

+143
-10
lines changed

6 files changed

+143
-10
lines changed
64.2 KB
Loading
285 KB
Loading

apps/docs/src/app/page.tsx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { baseURL, meta, schema, changelog, roadmap, layout } from "@/resources";
1919
import { formatDate } from "./utils/formatDate";
2020
import { Products } from "@/product";
21+
import { PromoCard } from "@/components/PromoCard";
2122

2223
export async function generateMetadata() {
2324
return Meta.generate({
@@ -329,7 +330,46 @@ export default function Home() {
329330
<Row
330331
width={layout.sidebar.width}
331332
minWidth={layout.sidebar.width}
332-
m={{hide: true}}/>
333+
m={{hide: true}}
334+
fillHeight>
335+
<Column
336+
fill
337+
position="sticky"
338+
style={{maxHeight: "calc(100vh - 3.5rem)", top: "3.5rem"}}
339+
gap="-1">
340+
<Column fill borderLeft="neutral-alpha-medium" vertical="end">
341+
<Background
342+
fillWidth
343+
height={2}
344+
borderTop="neutral-alpha-medium"
345+
lines={{
346+
display: true,
347+
color: "neutral-alpha-weak",
348+
angle: -45,
349+
size: "4"
350+
}}/>
351+
<Row fillWidth padding="24" borderTop="neutral-alpha-medium">
352+
<Heading as="h3" variant="heading-strong-m">Support our recent launch!</Heading>
353+
</Row>
354+
</Column>
355+
{[
356+
{
357+
href: "https://store.dopler.app/product/curiosity-in-code-hooded-long-sleeve",
358+
image: "/images/docs/swag-promo-01.png",
359+
},
360+
{
361+
href: "https://store.dopler.app/product/curiosity-in-code-desk-mat",
362+
image: "/images/docs/swag-promo-02.png",
363+
}
364+
].map((product, index) => (
365+
<PromoCard
366+
key={index}
367+
href={product.href}
368+
image={product.image}
369+
/>
370+
))}
371+
</Column>
372+
</Row>
333373
</Row>
334374
);
335375
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"use client";
2+
3+
import { useRef, useState, useEffect } from "react";
4+
import {
5+
Row,
6+
Button,
7+
Card,
8+
Animation,
9+
Hover,
10+
LetterFx,
11+
Background,
12+
Media,
13+
Text
14+
} from "@once-ui-system/core";
15+
16+
export interface PromoCardProps {
17+
href: string;
18+
image: string;
19+
buttonText?: string;
20+
showOverlay?: boolean;
21+
}
22+
23+
export function PromoCard({
24+
href,
25+
image,
26+
}: PromoCardProps) {
27+
const triggerLetterFxRef = useRef<(() => void) | null>(null);
28+
const [isHovered, setIsHovered] = useState(false);
29+
30+
// Trigger animation when hovered and ref is available
31+
useEffect(() => {
32+
if (isHovered && triggerLetterFxRef.current) {
33+
// Small delay to ensure overlay is mounted
34+
const timer = setTimeout(() => {
35+
triggerLetterFxRef.current?.();
36+
}, 50);
37+
return () => clearTimeout(timer);
38+
}
39+
}, [isHovered]);
40+
41+
const cardContent = (
42+
<Card fillWidth href={href} overflow="hidden">
43+
<Animation scale={1.05} reverse fade={1} triggerType="hover">
44+
<Media src={image} priority sizes="400px"/>
45+
</Animation>
46+
</Card>
47+
);
48+
49+
return (
50+
<Row fillWidth
51+
onMouseEnter={() => setIsHovered(true)}
52+
onMouseLeave={() => setIsHovered(false)}
53+
>
54+
<Hover
55+
trigger={cardContent}
56+
overlay={
57+
<Row fill padding="4">
58+
<Row fill border="neutral-alpha-medium" radius="l" vertical="end" overflow="hidden">
59+
<Row fillWidth height="32">
60+
<Background
61+
fill
62+
borderTop="neutral-alpha-medium"
63+
lines={{
64+
display: true,
65+
color: "neutral-alpha-weak",
66+
angle: -45,
67+
size: "4"
68+
}}/>
69+
<Button data-border="sharp" size="s" suffixIcon="chevronRight">
70+
<Text variant="code-default-s">
71+
<LetterFx
72+
charset={["x", "y", "z", "0", "/", "!", "u", "o"]}
73+
trigger="custom"
74+
onTrigger={(triggerFn) => {
75+
triggerLetterFxRef.current = triggerFn;
76+
}}
77+
>
78+
Buy now
79+
</LetterFx>
80+
</Text>
81+
</Button>
82+
<Background
83+
fill
84+
borderTop="neutral-alpha-medium"
85+
lines={{
86+
display: true,
87+
color: "neutral-alpha-weak",
88+
angle: -45,
89+
size: "4"
90+
}}/>
91+
</Row>
92+
</Row>
93+
</Row>
94+
}
95+
/>
96+
</Row>
97+
);
98+
}

apps/docs/src/product/Products.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AvatarGroup, Card, Column, Grid, Media, Row, Text } from "@once-ui-syst
44

55
export function Products() {
66
return (
7-
<Grid fillWidth columns="2" m={{columns: 1}} gap="12" marginTop="16">
7+
<Grid fillWidth columns="2" s={{columns: 1}} gap="12" marginTop="16">
88
{[
99
{
1010
title: "Once UI Core",

apps/docs/src/product/Sidebar.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,28 +334,23 @@ const Sidebar: React.FC<SidebarProps> = ({ initialNavigation, ...rest }) => {
334334
}
335335
}, [initialNavigation, hasLoaded]);
336336

337-
// Create a stable container that doesn't change
338-
const containerStyle = useMemo(() => ({
339-
maxHeight: "calc(100vh - var(--static-space-64))",
340-
top: "4rem"
341-
}), []);
342-
343337
return (
344338
<Column
345339
fillHeight
346340
borderRight="neutral-alpha-medium"
347341
width={layout.sidebar.width}
348342
minWidth={layout.sidebar.width}
343+
paddingY="4"
349344
{...rest}>
350345
<Column
351-
position="sticky"
346+
position="sticky"
352347
fillHeight
353348
gap="2"
354349
as="nav"
355350
overflowY="auto"
356351
paddingX="12"
357352
paddingY="16"
358-
style={containerStyle}
353+
style={{maxHeight: "calc(100vh - 4rem)", top: "3.5rem"}}
359354
>
360355
{hasLoaded ? (
361356
<SidebarContent key={pathname} navigation={navigation} pathname={pathname} />

0 commit comments

Comments
 (0)