-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #536 from creativetimofficial/test
feat: update info bar
- Loading branch information
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import Link from "next/link"; | ||
import { | ||
Alert, | ||
Button, | ||
Chip, | ||
Typography | ||
} from "@material-tailwind/react"; | ||
|
||
const OFFER_STORAGE_KEY = "hideOfferBar"; | ||
|
||
export function OfferBar() { | ||
|
||
const [isVisible, setIsVisible] = useState(false); | ||
|
||
|
||
useEffect(() => { | ||
const shouldHide = localStorage.getItem(OFFER_STORAGE_KEY); | ||
if (!shouldHide) { | ||
setIsVisible(true); | ||
} | ||
|
||
const hideUntil = Number(shouldHide); | ||
const now = new Date().getTime(); | ||
if (hideUntil && now > hideUntil) { | ||
setIsVisible(true); | ||
} | ||
}, []); | ||
|
||
const handleClose = () => { | ||
setIsVisible(false); | ||
// add 2 days | ||
const hideUntil = new Date().getTime() + 2 * 24 * 60 * 60 * 1000; | ||
localStorage.setItem(OFFER_STORAGE_KEY, hideUntil.toString()); | ||
}; | ||
|
||
|
||
function Icon() { | ||
return ( | ||
<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> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
{isVisible && ( | ||
<Alert variant="ghost" className="w-full bg-blue-gray-50 justify-center rounded-none"> | ||
|
||
<div className="flex flex-wrap items-center justify-center !text-blue-gray-900"> | ||
<Link href="/blocks" className="font-medium m-0 flex items-center"> | ||
<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> | ||
blocks, now available for your use. | ||
|
||
<Link href="/blocks" className="font-bold"> | ||
Check out | ||
→ | ||
</Link> | ||
<button className="font-bold ml-10 mb-0 !text-grey-900" | ||
onClick={() => handleClose()} | ||
> | ||
<Icon /> | ||
</button> | ||
</div> | ||
</Alert> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default OfferBar; |
02c5e6b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
material-tailwind – ./
material-tailwind-ct-tailwind-team.vercel.app
material-tailwind.vercel.app
docs.material-tailwind.com
material-tailwind-git-main-ct-tailwind-team.vercel.app