From 5108a2bbb4f5338762d5b5f4f9f80488e4078430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Sefa=20Ar=C5=9Fiv?= Date: Wed, 29 May 2024 23:54:11 +0300 Subject: [PATCH 1/2] BUg fixed Export --- src/accordion/Accordion.tsx | 70 ++----------------------------- src/accordion/AccordionBody.tsx | 25 +++++++++++ src/accordion/AccordionHeader.tsx | 38 +++++++++++++++++ src/accordion/AccordionList.tsx | 11 +++++ src/index.ts | 3 ++ stories/Accordion.stories.tsx | 6 +-- 6 files changed, 83 insertions(+), 70 deletions(-) create mode 100644 src/accordion/AccordionBody.tsx create mode 100644 src/accordion/AccordionHeader.tsx create mode 100644 src/accordion/AccordionList.tsx diff --git a/src/accordion/Accordion.tsx b/src/accordion/Accordion.tsx index a56119e..f646295 100644 --- a/src/accordion/Accordion.tsx +++ b/src/accordion/Accordion.tsx @@ -1,34 +1,15 @@ -import React, { useState, ReactNode, createContext, useContext } from 'react'; -import { motion } from 'framer-motion'; - -interface AccordionProps { - children: ReactNode; -} +import React, { useState, ReactNode, createContext } from 'react'; interface AccordionItemProps { children: ReactNode; } -interface AccordionHeaderProps { - children: ReactNode; - className?: string; -} - -interface AccordionBodyProps { - children: ReactNode; - className?: string; -} - const AccordionContext = createContext({ isOpen: false, toggle: () => {}, }); -export const AccordionList = ({ children }: AccordionProps) => { - return
{children}
; -}; - -export const Accordion = ({ children }: AccordionItemProps) => { +const Accordion = ({ children }: AccordionItemProps) => { const [isOpen, setIsOpen] = useState(false); const toggle = () => setIsOpen(!isOpen); @@ -42,50 +23,5 @@ export const Accordion = ({ children }: AccordionItemProps) => { ); }; -export const AccordionHeader = ({ - children, - className, -}: AccordionHeaderProps) => { - const { isOpen, toggle } = useContext(AccordionContext); - return ( -
- - {children} - - -
- ); -}; - -export const AccordionBody = ({ children, className }: AccordionBodyProps) => { - const { isOpen } = useContext(AccordionContext); - return ( - -
- {children} -
-
- ); -}; - +export { AccordionContext }; export default Accordion; diff --git a/src/accordion/AccordionBody.tsx b/src/accordion/AccordionBody.tsx new file mode 100644 index 0000000..9c73313 --- /dev/null +++ b/src/accordion/AccordionBody.tsx @@ -0,0 +1,25 @@ +import React, { useContext, ReactNode } from 'react'; +import { motion } from 'framer-motion'; +import { AccordionContext } from './Accordion'; + +interface AccordionBodyProps { + children: ReactNode; + className?: string; +} + +const AccordionBody = ({ children, className }: AccordionBodyProps) => { + const { isOpen } = useContext(AccordionContext); + return ( + +
+ {children} +
+
+ ); +}; + +export default AccordionBody; diff --git a/src/accordion/AccordionHeader.tsx b/src/accordion/AccordionHeader.tsx new file mode 100644 index 0000000..23598f8 --- /dev/null +++ b/src/accordion/AccordionHeader.tsx @@ -0,0 +1,38 @@ +import React, { useContext, ReactNode } from 'react'; +import { motion } from 'framer-motion'; +import { AccordionContext } from './Accordion'; + +interface AccordionHeaderProps { + children: ReactNode; + className?: string; +} + +const AccordionHeader = ({ children, className }: AccordionHeaderProps) => { + const { isOpen, toggle } = useContext(AccordionContext); + return ( +
+ + {children} + + +
+ ); +}; + +export default AccordionHeader; diff --git a/src/accordion/AccordionList.tsx b/src/accordion/AccordionList.tsx new file mode 100644 index 0000000..b320648 --- /dev/null +++ b/src/accordion/AccordionList.tsx @@ -0,0 +1,11 @@ +import React, { ReactNode } from 'react'; + +interface AccordionProps { + children: ReactNode; +} + +const AccordionList = ({ children }: AccordionProps) => { + return
{children}
; +}; + +export default AccordionList; diff --git a/src/index.ts b/src/index.ts index 64cd9ed..c982147 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,3 +17,6 @@ export { default as Drawer } from './drawer/Drawer'; export { default as Dialog } from './dialog/Dialog'; export { default as Popover } from './popover/Popover'; export { default as Accordion } from './accordion/Accordion'; +export { default as AccordionBody } from './accordion/AccordionBody'; +export { default as AccordionHeader } from './accordion/AccordionHeader'; +export { default as AccordionList } from './accordion/AccordionList'; diff --git a/stories/Accordion.stories.tsx b/stories/Accordion.stories.tsx index b24fcc3..79f6e5f 100644 --- a/stories/Accordion.stories.tsx +++ b/stories/Accordion.stories.tsx @@ -1,11 +1,11 @@ import React from 'react'; +import type { Meta } from '@storybook/react'; import { + Accordion, AccordionBody, AccordionHeader, - Accordion, AccordionList, -} from '../src/accordion/Accordion'; -import type { Meta } from '@storybook/react'; +} from '../src/'; const meta = { title: 'Components/Accordion', From 5adb0b5046611ed280796b24e99e04939e1648a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Sefa=20Ar=C5=9Fiv?= Date: Wed, 29 May 2024 23:54:42 +0300 Subject: [PATCH 2/2] Upgrade to version 0.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f2634a..f0b7e68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codenteq/interfeys", - "version": "0.5.0", + "version": "0.5.1", "description": "Codenteq Interfeys Design System", "main": "dist/esm/index.js", "module": "dist/esm/index.js",