Skip to content

Commit 02c5e6b

Browse files
authored
Merge pull request #536 from creativetimofficial/test
feat: update info bar
2 parents 4a7582d + 2b7edf8 commit 02c5e6b

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

pages/docs/[...slug].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ import getDirectoriesAndFile from "utils/get-directories-and-files";
181181

182182
// material tailwind html script
183183
import initHtmlScripts from "public/material-tailwind-html-v2";
184-
import OfferBar from "widgets/campaign/offer-bar";
184+
import OfferBar from "widgets/offer-bar";
185185

186186
const components = {
187187
h1: (props) => (

widgets/layout/docs-navbar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ export function DocsNavbar({ slug, setMobileNav }: DocsNavbar) {
159159
</a>
160160
</Tooltip>
161161
<Link href="/blocks#pricing">
162-
<Button size="sm" className="flex items-center justify-between bg-deep-orange-500 py-2.5">Black Friday</Button>
162+
<Button size="sm" className="flex items-center justify-between bg-gray-900 py-2.5">
163+
Pricing & FAQ
164+
</Button>
163165
</Link>
164166
</div>
165167
</div>

widgets/offer-bar.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React, { useEffect, useState } from "react";
2+
import Link from "next/link";
3+
import {
4+
Alert,
5+
Button,
6+
Chip,
7+
Typography
8+
} from "@material-tailwind/react";
9+
10+
const OFFER_STORAGE_KEY = "hideOfferBar";
11+
12+
export function OfferBar() {
13+
14+
const [isVisible, setIsVisible] = useState(false);
15+
16+
17+
useEffect(() => {
18+
const shouldHide = localStorage.getItem(OFFER_STORAGE_KEY);
19+
if (!shouldHide) {
20+
setIsVisible(true);
21+
}
22+
23+
const hideUntil = Number(shouldHide);
24+
const now = new Date().getTime();
25+
if (hideUntil && now > hideUntil) {
26+
setIsVisible(true);
27+
}
28+
}, []);
29+
30+
const handleClose = () => {
31+
setIsVisible(false);
32+
// add 2 days
33+
const hideUntil = new Date().getTime() + 2 * 24 * 60 * 60 * 1000;
34+
localStorage.setItem(OFFER_STORAGE_KEY, hideUntil.toString());
35+
};
36+
37+
38+
function Icon() {
39+
return (
40+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" className="h-6 w-6" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>
41+
);
42+
}
43+
44+
return (
45+
<>
46+
{isVisible && (
47+
<Alert variant="ghost" className="w-full bg-blue-gray-50 justify-center rounded-none">
48+
49+
<div className="flex flex-wrap items-center justify-center !text-blue-gray-900">
50+
<Link href="/blocks" className="font-medium m-0 flex items-center">
51+
<Chip variant="outlined" value="NEW" className="mr-2 !text-blue-gray-900 py-1 px-2" /> Material Tailwind Blocks</Link>, a comprehensive compilation of <Typography className="font-bold mx-1">170+</Typography>
52+
blocks, now available for your use.&nbsp;
53+
54+
<Link href="/blocks" className="font-bold">
55+
Check out
56+
&rarr;
57+
</Link>
58+
<button className="font-bold ml-10 mb-0 !text-grey-900"
59+
onClick={() => handleClose()}
60+
>
61+
<Icon />
62+
</button>
63+
</div>
64+
</Alert>
65+
)}
66+
</>
67+
);
68+
}
69+
70+
export default OfferBar;

0 commit comments

Comments
 (0)