Skip to content

Commit

Permalink
Merge pull request #18 from manavsiddharthgupta/develop
Browse files Browse the repository at this point in the history
[ADDED] collapsible purchased items component
  • Loading branch information
manavsiddharthgupta authored Nov 23, 2023
2 parents c6c282c + 8c69c25 commit a572c24
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 64 deletions.
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@headlessui/react": "^1.7.17",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
5 changes: 5 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@
.remove-arrow {
-moz-appearance: textfield;
}

::-webkit-scrollbar {
width: 0; /* Remove scrollbar space */
background: transparent; /* Optional: just make scrollbar invisible */
}
23 changes: 5 additions & 18 deletions src/app/invoice/create/preview-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {
TooltipTrigger
} from '@/components/ui/tooltip'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { ChevronDown, Info } from 'lucide-react'
import { Info } from 'lucide-react'
import { formatAmount } from '@/lib/helpers'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { StatusBadge } from '@/components/status-badge'
import CollapsiblePurchasedItems from './purchased-items'

const PreviewModal = () => {
// Todo: Will have to revamp the code structure
Expand Down Expand Up @@ -72,24 +73,10 @@ const PreviewModal = () => {
</p>
</div>
</div>
<div className='flex justify-center'>
<Button
variant='link'
className='text-center flex gap-2 items-center dark:text-sky-300 text-sky-600 hover:no-underline'
>
View Invoice Details
<ChevronDown className='mt-1' />
</Button>
</div>
<CollapsiblePurchasedItems />
<Separator className='mt-1 mb-3 bg-black/20 dark:bg-white/20 h-[0.5px]' />
<div className='w-full flex justify-between mb-3'>
<div className='w-1/2'>
{/* <div className='w-24 h-24 rounded-full border-[1.5px] border-black p-1'>
<div className='rounded-full border-[1px] border-black border-dashed h-full flex justify-center items-center'>
<h1 className='text-xl font-bold -rotate-12'>Unpaid</h1>
</div>
</div> */}
</div>
<div className='w-1/2'>{/* notes */}</div>
<div className='w-2/6'>
<div className='w-full flex justify-between items-center'>
<span className='text-zinc-800/60 dark:text-zinc-200/60 text-sm'>
Expand Down
88 changes: 88 additions & 0 deletions src/app/invoice/create/purchased-items.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
'use client'
import { Button } from '@/components/ui/button'
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger
} from '@/components/ui/collapsible'
import { formatAmount } from '@/lib/helpers'
import { ChevronDown, ChevronUp } from 'lucide-react'
import { useState } from 'react'
const CollapsiblePurchasedItems = () => {
const [isopen, setIfOpen] = useState(false)
return (
<Collapsible open={isopen} onOpenChange={setIfOpen}>
<div className='flex justify-center'>
<CollapsibleTrigger asChild>
<Button
variant='link'
className='text-center flex gap-2 items-center dark:text-sky-300 text-sky-600 hover:no-underline'
>
View Invoice Details
{isopen ? (
<ChevronUp className='mt-1' />
) : (
<ChevronDown className='mt-1' />
)}
</Button>
</CollapsibleTrigger>
</div>
<CollapsibleContent className='transition-all data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down'>
<h1 className='font-medium text-base'>Purchased Items</h1>
<div className='my-2 border border-zinc-600/20 dark:border-zinc-500/20 rounded-sm'>
<table className='w-full text-sm'>
<thead>
<tr className='text-zinc-800/50 dark:text-zinc-300/50 border-b border-zinc-600/20 dark:border-zinc-500/20'>
<td className='p-2'>Name</td>
<td className='text-center p-2'>Qty</td>
<td className='text-right p-2'>Amount</td>
</tr>
</thead>
<tbody>
<tr className='border-b border-zinc-600/20 dark:border-zinc-500/20'>
<td className='p-2'>Something Uniques 2</td>
<td className='text-center p-2'>1</td>
<td className='text-right p-2'>{formatAmount(829)}</td>
</tr>
<tr>
<td className='p-2'>Something Uniques</td>
<td className='text-center p-2'>3</td>
<td className='text-right p-2'>{formatAmount(7231)}</td>
</tr>
</tbody>
</table>
</div>
<div className='w-full flex justify-end'>
<div className='w-2/6 text-sm'>
<div className='w-full flex justify-between items-center mb-1'>
<span className='text-zinc-800/60 dark:text-zinc-200/60'>
Total Amount
</span>
<span>{formatAmount(5273)}</span>
</div>
<div className='flex w-full justify-between relative mb-1'>
<span className='absolute -left-4 top-1/2 -translate-y-1/2 leading-3 font-bold'>
+
</span>
<span className='text-zinc-800/60 dark:text-zinc-200/60'>
Tax
</span>
<span>₹ 16.00</span>
</div>
<div className='flex w-full justify-between relative mb-1'>
<span className='absolute -left-4 top-1/2 -translate-y-1/2 leading-3 font-bold'>
-
</span>
<span className='text-zinc-800/60 dark:text-zinc-200/60'>
Discount
</span>
<span>₹ 18.00</span>
</div>
</div>
</div>
</CollapsibleContent>
</Collapsible>
)
}

export default CollapsiblePurchasedItems
11 changes: 11 additions & 0 deletions src/components/ui/collapsible.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client"

import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"

const Collapsible = CollapsiblePrimitive.Root

const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger

const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent

export { Collapsible, CollapsibleTrigger, CollapsibleContent }
102 changes: 56 additions & 46 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,93 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ["class"],
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}'
],
theme: {
container: {
center: true,
padding: "2rem",
padding: '2rem',
screens: {
"2xl": "1400px",
},
'2xl': '1400px'
}
},
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
border: 'hsl(var(--border))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))'
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))'
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
DEFAULT: 'hsl(var(--destructive))',
foreground: 'hsl(var(--destructive-foreground))'
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))'
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))'
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))'
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))'
}
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)'
},
keyframes: {
"accordion-down": {
'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 },
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
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",
},
'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'
}
},
darkMode: "class",
darkMode: 'class',
variants: {
extend: {
backgroundColor: ["dark"],
textColor: ["dark"],
},
},
backgroundColor: ['dark'],
textColor: ['dark']
}
}
},
plugins: [require("tailwindcss-animate")],
};
plugins: [require('tailwindcss-animate')]
}

0 comments on commit a572c24

Please sign in to comment.