Skip to content

Commit 89e4c83

Browse files
committed
accordian component
1 parent c6fbd58 commit 89e4c83

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

pages/all-components.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useRouter } from "next/router"
22
import { useEffect, useState } from "react"
3-
import { PageLayout, Text, LinkTo, Slider, Seperator, Image, List, ArticleHeader } from "../src/components"
3+
import { PageLayout, Text, LinkTo, Slider, Seperator, Image, List, Accordian } from "../src/components"
44
import { ListType, ImageSize, TextAlign } from "../src/shared/enums"
55
import { combineClasses } from "../src/utils/utils";
66
import CodeBlock from "../src/components/CodeBlock";
7-
import { HowToUseList, HowToUseSeperator, HowToUsePageLayout, HowToUseImageCode, HowToUseTextCode, HowToUseLinkTo, HowToUseSlider } from "../src/constants/codeBlocks";
7+
import { HowToUseList, HowToUseSeperator, HowToUsePageLayout, HowToUseImageCode, HowToUseTextCode, HowToUseLinkTo, HowToUseSlider, HowToUseAccordian } from "../src/constants/codeBlocks";
88

99
interface iSideBtnLinks {
1010
component: string,
@@ -238,6 +238,19 @@ const AllComponents = () => {
238238
<CodeBlock code={HowToUseSlider} className="my-5" />
239239
{/* <Image src="/public/images/tutorials/how-to-use-slider.svg" alt="how to use image slider | webexpe.com" /> */}
240240
</section>
241+
242+
<section className={cardBBorder} id="imageslider">
243+
<Text subtitle className="mb-5 pb-3 border-b md:!text-3xl font-bold">
244+
Accordian
245+
</Text>
246+
<b>Demo</b>
247+
<Accordian title="Accordian Title" keepOpen>
248+
Accordian content
249+
</Accordian>
250+
<b>How to use</b>
251+
<CodeBlock code={HowToUseAccordian} className="mb-5 mt-3" />
252+
</section>
253+
241254
<div className="px-4 py-3 dark:bg-slate-800 bg-blue-200 rounded my-5">
242255
<Text p className="!text-lg leading-relaxed mb-0">
243256
For any any queries related to this project / template feel free to connect with us at <u>webexpe13@gmail.com</u>.

src/components/Accordian/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ChevronRightIcon } from '@heroicons/react/outline'
2+
import { useState } from 'react';
3+
import { combineClasses } from '../../utils/utils';
4+
5+
const Accordian = ({ title = "Accordian Title", children, keepOpen = false }: any) => {
6+
const [open, setOpen] = useState(keepOpen);
7+
8+
const openAccordian = () => {
9+
setOpen(!open)
10+
}
11+
12+
return (
13+
<div className="border-b border-slate-300 pb-1 my-3 w-full">
14+
<h3 className='md:text-xl text-[18px] font-bold cursor-pointer hover:opacity-80 transition-opacity flex justify-between md:items-center items-start' onClick={openAccordian}>
15+
{title} <ChevronRightIcon className={combineClasses('md:w-[30px] w-[25px] md:pt-0 pt-1 transition-transform text-blue-800 ml-3 shrink-0', open ? '-rotate-90' : 'rotate-90')} />
16+
</h3>
17+
<div className={combineClasses('md:text-[18px] text-[16px] text-slate-700 dark:text-slate-300 font-regular overflow-hidden transition-all w-full ring-blue-200 rounded px-3',
18+
open ? 'max-h-[300px] my-3 ring-1 p-2 ' : 'max-h-[0px]')}>
19+
{children}
20+
</div>
21+
</div>
22+
)
23+
}
24+
25+
export default Accordian;

src/components/Search/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Search = ({ closeSearch }: ISearch) => {
2626
<div className='flex justify-between items-center md:pt-10 pt-5'>
2727
<h1 className={'text-[45px] font-bold'}>Search</h1>
2828
<button name="search-button" aria-label="search button" type="button" className={classes.search_close_icon} onClick={closeSearch}>
29-
<XIcon className='text-slate-800 dark:text-white text-[20px]' />
29+
<XIcon className='text-slate-800 dark:text-white' />
3030
</button>
3131
</div>
3232
<div className="mb-[40px] mt-3">

src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export {default as Image} from "./ArticleImage";
55
export {default as Seperator} from "./Seperator";
66
export {default as List} from "./List";
77
export {default as LinkTo} from "./LinkTo";
8-
export {default as Slider} from "./Slider";
8+
export {default as Slider} from "./Slider";
9+
export {default as Accordian} from "./Accordian";

src/constants/codeBlocks.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ export const HowToUseList = `
100100
export default Article;
101101
`
102102

103+
104+
export const HowToUseAccordian = `
105+
// import Accordian from components
106+
import { ..., Accordian, ... } from "../../../src/components";
107+
const Article = () => {
108+
return (
109+
<Accordian title="Accordian Title" />
110+
Accordian Content
111+
</Accordian>
112+
{/* or if your want to keep it open by default */}
113+
<Accordian title="Accordian Title" keepOpen />
114+
Accordian Content
115+
</Accordian>
116+
)
117+
}
118+
119+
export default Article;
120+
`
121+
103122
export const HowToUseSeperator = `
104123
// import Seperator from components
105124
import { ..., Seperator, ... } from "../../../src/components";
@@ -258,6 +277,7 @@ export const rightSideAdCode= `
258277
259278
export default Article;
260279
`;
280+
261281
export const Article_Entry_inList = `
262282
// Import author profiles, just type the name you have set in _BLOG_SETUP inside the curly brackets
263283
import { MAYUR, RUPALI } from './_BLOG_SETUP';

0 commit comments

Comments
 (0)