-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
248 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Demo } from "@/components/demo"; | ||
import { Header, HeaderCenter, HeaderContainer, HeaderLeft, HeaderMobileMenuTrigger, HeaderRight } from "@/components/gluons/header"; | ||
import { Button } from "@/components/ui/button"; | ||
import { AlignLeft } from "lucide-react"; | ||
|
||
const HeaderPage = async () => { | ||
|
||
return ( | ||
<Demo | ||
title="Header.tsx" | ||
lang="tsx" | ||
code={`header.tsx`} | ||
lineNumbers={true} | ||
className="!my-0" | ||
> | ||
<Header> | ||
<HeaderContainer> | ||
<HeaderLeft> | ||
<HeaderMobileMenuTrigger className="@lg:hidden"/> | ||
<img src="/logoipsum.svg" alt="Logo" /> | ||
</HeaderLeft> | ||
<HeaderCenter> | ||
Center | ||
</HeaderCenter> | ||
<HeaderRight> | ||
Right | ||
</HeaderRight> | ||
</HeaderContainer> | ||
</Header> | ||
<main className="container mx-auto h-full max-h-[500px] pt-8 px-4 @md:px-6 @lg:px-8"> | ||
<div className="flex flex-col gap-3 @lg:gap-4"> | ||
<div className="flex h-12 bg-muted rounded-md" /> | ||
<div className="grid grid-cols-3 gap-3 @lg:gap-4"> | ||
{Array.from({ length: 3 }).map((_, i) => ( | ||
<div key={i} className="col-span-1 bg-muted justify-center items-center aspect-square rounded-md" /> | ||
))} | ||
</div> | ||
<div className="flex h-64 bg-muted rounded-md" /> | ||
<div className="grid grid-cols-2 gap-3 @lg:gap-4"> | ||
{Array.from({ length: 4 }).map((_, i) => ( | ||
<div key={i} className="col-span-1 bg-muted justify-center items-center aspect-square rounded-md" /> | ||
))} | ||
</div> | ||
<div className="flex h-64 bg-muted rounded-md mb-8" /> | ||
</div> | ||
</main> | ||
</Demo> | ||
) | ||
} | ||
|
||
export default HeaderPage; |
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,151 @@ | ||
"use client" | ||
|
||
import React from "react"; | ||
import { cn } from "@/lib/utils"; | ||
import { Head } from "react-day-picker"; | ||
import { Button } from "../ui/button"; | ||
import { AlignLeft } from "lucide-react"; | ||
import { Slot } from "@radix-ui/react-slot" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
const Header = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props}, ref) => ( | ||
<header | ||
ref={ref} | ||
className={cn( | ||
"@container sticky top-0 z-50 w-full border-b border-border/40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
|
||
)); | ||
Header.displayName = "Header"; | ||
|
||
const HeaderContainer = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"container flex flex-row items-center justify-between h-14 gap-4 py-0 @lg:py-2 mx-auto", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
HeaderContainer.displayName = "HeaderContainer"; | ||
|
||
const HeaderLeft = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"relative flex-1 flex flex-row items-center justify-start h-full gap-4", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
HeaderLeft.displayName = "HeaderLeft"; | ||
|
||
const headerCenterVariants = cva( | ||
"relative flex-1 hidden @lg:flex flex-row items-center justify-center h-full gap-4", | ||
{ | ||
variants: { | ||
align: { | ||
left: "justify-start", | ||
center: "justify-center", | ||
right: "justify-end", | ||
} | ||
}, | ||
defaultVariants: { | ||
align: "center", | ||
}, | ||
} | ||
); | ||
|
||
export interface HeaderCenterProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof headerCenterVariants> { | ||
asChild?: boolean; | ||
} | ||
|
||
const HeaderCenter = React.forwardRef< | ||
HTMLDivElement, | ||
HeaderCenterProps | ||
>(({ className, align, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : "div" | ||
return ( | ||
<Comp | ||
ref={ref} | ||
className={cn(headerCenterVariants({ align, className }))} | ||
{...props} | ||
/> | ||
); | ||
}); | ||
HeaderCenter.displayName = "HeaderCenter"; | ||
|
||
const HeaderRight = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"relative flex-1 flex flex-row items-center justify-end h-full gap-4", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
HeaderRight.displayName = "HeaderRight"; | ||
|
||
const HeaderMobileMenuTrigger = React.forwardRef< | ||
HTMLButtonElement, | ||
React.ButtonHTMLAttributes<HTMLButtonElement> | ||
>(({ className, ...props }, ref) => ( | ||
<Button | ||
ref={ref} | ||
size="icon" | ||
variant="ghost" | ||
className={cn( | ||
className | ||
)} | ||
{...props} | ||
> | ||
<AlignLeft /> | ||
</Button> | ||
)); | ||
HeaderMobileMenuTrigger.displayName = "HeaderMobileMenuTrigger"; | ||
|
||
const HeaderMobileMenu = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"absolute top-14 left-0 w-full h-[300px] bg-background", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
HeaderMobileMenu.displayName = "HeaderMobileMenu"; | ||
|
||
export { | ||
Header, | ||
HeaderContainer, | ||
HeaderLeft, | ||
HeaderCenter, | ||
headerCenterVariants, | ||
HeaderRight, | ||
HeaderMobileMenuTrigger, | ||
HeaderMobileMenu, | ||
}; |
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,10 @@ | ||
"use client" | ||
|
||
let demoContainer: HTMLElement | null = null; | ||
|
||
if (typeof document !== 'undefined') { | ||
demoContainer = document.getElementById("demoPreviewContainer"); | ||
console.log(demoContainer, "demoContainer"); | ||
} | ||
|
||
export const demoPreviewId = demoContainer; |