Skip to content

Commit

Permalink
Update collapse-menu-button
Browse files Browse the repository at this point in the history
  • Loading branch information
salimi-my committed May 2, 2024
1 parent 1ffd898 commit 9e2344a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 56 deletions.
42 changes: 10 additions & 32 deletions src/components/demo/collapse-menu-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Link from "next/link";
import { useState } from "react";
import { ChevronDown, ChevronUp, Dot, LucideIcon } from "lucide-react";
import { ChevronDown, Dot, LucideIcon } from "lucide-react";

import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -57,7 +57,10 @@ export function CollapseMenuButton({
onOpenChange={setIsCollapsed}
className="w-full"
>
<CollapsibleTrigger asChild>
<CollapsibleTrigger
className="[&[data-state=open]>div>div>svg]:rotate-180"
asChild
>
<Button
variant={active ? "secondary" : "ghost"}
className="w-full justify-start h-10"
Expand Down Expand Up @@ -86,16 +89,15 @@ export function CollapseMenuButton({
: "-translate-x-96 opacity-0"
)}
>
{isCollapsed ? (
<ChevronUp size={18} />
) : (
<ChevronDown size={18} />
)}
<ChevronDown
size={18}
className="transition-transform duration-200"
/>
</div>
</div>
</Button>
</CollapsibleTrigger>
<CollapsibleContent>
<CollapsibleContent className="overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down">
{submenus.map(({ href, label, active }, index) => (
<Button
key={index}
Expand Down Expand Up @@ -137,30 +139,6 @@ export function CollapseMenuButton({
<span className={cn(isOpen === false ? "" : "mr-4")}>
<Icon size={18} />
</span>
<p
className={cn(
"whitespace-nowrap",
isOpen === false
? "-translate-x-96 opacity-0 hidden"
: "translate-x-0 opacity-100"
)}
>
{label}
</p>
</div>
<div
className={cn(
"whitespace-nowrap",
isOpen
? "translate-x-0 opacity-100"
: "-translate-x-96 opacity-0"
)}
>
{isCollapsed ? (
<ChevronUp size={18} />
) : (
<ChevronDown size={18} />
)}
</div>
</div>
</Button>
Expand Down
58 changes: 34 additions & 24 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type { Config } from "tailwindcss"
import type { Config } from "tailwindcss";

const config = {
darkMode: ["class"],
content: [
'./pages/**/*.{ts,tsx}',
'./components/**/*.{ts,tsx}',
'./app/**/*.{ts,tsx}',
'./src/**/*.{ts,tsx}',
],
"./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./app/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}"
],
prefix: "",
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
"2xl": "1400px"
}
},
extend: {
colors: {
Expand All @@ -26,55 +26,65 @@ const config = {
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
foreground: "hsl(var(--primary-foreground))"
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
foreground: "hsl(var(--secondary-foreground))"
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
foreground: "hsl(var(--destructive-foreground))"
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
foreground: "hsl(var(--muted-foreground))"
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
foreground: "hsl(var(--accent-foreground))"
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
foreground: "hsl(var(--popover-foreground))"
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
foreground: "hsl(var(--card-foreground))"
}
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
sm: "calc(var(--radius) - 4px)"
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
to: { height: "var(--radix-accordion-content-height)" }
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
to: { height: "0" }
},
"collapsible-down": {
from: { height: "0" },
to: { height: "var(--radix-collapsible-content-height)" }
},
"collapsible-up": {
from: { height: "var(--radix-collapsible-content-height)" },
to: { height: "0" }
}
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
"collapsible-down": "collapsible-down 0.2s ease-out",
"collapsible-up": "collapsible-up 0.2s ease-out"
}
}
},
plugins: [require("tailwindcss-animate")],
} satisfies Config
plugins: [require("tailwindcss-animate")]
} satisfies Config;

export default config
export default config;

0 comments on commit 9e2344a

Please sign in to comment.