Skip to content

Commit 33c4610

Browse files
authored
Merge pull request #5 from zubinqayam/main
Commit all pending 4
2 parents f66e845 + 834f83d commit 33c4610

File tree

4 files changed

+759
-0
lines changed

4 files changed

+759
-0
lines changed

.github/workflows/python-app.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python 3.10
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: "3.10"
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest
38+
run: |
39+
pytest

components/ui/accordion.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import * as React from 'react';
2+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
3+
import { ChevronDown } from 'lucide-react';
4+
5+
import { cn } from '../../lib/utils';
6+
7+
const Accordion = AccordionPrimitive.Root;
8+
9+
const AccordionItem = React.forwardRef<
10+
React.ElementRef<typeof AccordionPrimitive.Item>,
11+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
12+
>(({ className, ...props }, ref) => (
13+
<AccordionPrimitive.Item ref={ref} className={cn('border-b', className)} {...props} />
14+
));
15+
AccordionItem.displayName = 'AccordionItem';
16+
17+
const AccordionTrigger = React.forwardRef<
18+
React.ElementRef<typeof AccordionPrimitive.Trigger>,
19+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
20+
>(({ className, children, ...props }, ref) => (
21+
<AccordionPrimitive.Header className="flex">
22+
<AccordionPrimitive.Trigger
23+
ref={ref}
24+
className={cn(
25+
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
26+
className
27+
)}
28+
{...props}
29+
>
30+
{children}
31+
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
32+
</AccordionPrimitive.Trigger>
33+
</AccordionPrimitive.Header>
34+
));
35+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
36+
37+
const AccordionContent = React.forwardRef<
38+
React.ElementRef<typeof AccordionPrimitive.Content>,
39+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
40+
>(({ className, children, ...props }, ref) => (
41+
<AccordionPrimitive.Content
42+
ref={ref}
43+
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
44+
{...props}
45+
>
46+
<div className={cn('pb-4 pt-0', className)}>{children}</div>
47+
</AccordionPrimitive.Content>
48+
));
49+
50+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
51+
52+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };

lib/utils.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export type ClassValue = string | number | null | false | undefined | ClassDictionary | ClassArray;
2+
3+
interface ClassDictionary {
4+
[key: string]: any;
5+
}
6+
7+
interface ClassArray extends Array<ClassValue> {}
8+
9+
function toVal(mix: ClassValue): string {
10+
let str = '';
11+
if (typeof mix === 'string' || typeof mix === 'number') {
12+
str += mix;
13+
} else if (Array.isArray(mix)) {
14+
for (const item of mix) {
15+
const val = toVal(item);
16+
if (val) {
17+
if (str) str += ' ';
18+
str += val;
19+
}
20+
}
21+
} else if (mix && typeof mix === 'object') {
22+
for (const key in mix as ClassDictionary) {
23+
if ((mix as ClassDictionary)[key]) {
24+
if (str) str += ' ';
25+
str += key;
26+
}
27+
}
28+
}
29+
return str;
30+
}
31+
32+
export function cn(...inputs: ClassValue[]): string {
33+
let str = '';
34+
for (const input of inputs) {
35+
const val = toVal(input);
36+
if (val) {
37+
if (str) str += ' ';
38+
str += val;
39+
}
40+
}
41+
return str;
42+
}

0 commit comments

Comments
 (0)