From ac31b8ffc6284a34304f448ceff7e8fa83371f59 Mon Sep 17 00:00:00 2001 From: Hamza Miloud Amar Date: Mon, 1 Jul 2024 18:41:15 +0100 Subject: [PATCH] fix: remove tab stories until I figure a way to solve it --- apps/stories/stories/skeleton.stories.tsx | 291 +++++++++--------- .../{tabs.stories.tsx => tabs.storiesss.tsx} | 9 +- .../pillar-core/src/core/skeleton/index.tsx | 6 +- packages/pillar-core/src/core/tabs/index.ts | 1 - packages/pillar-core/src/core/tabs/index.tsx | 157 ++++++++++ .../pillar-core/src/core/tabs/tabs.type.ts | 3 +- 6 files changed, 309 insertions(+), 158 deletions(-) rename apps/stories/stories/{tabs.stories.tsx => tabs.storiesss.tsx} (97%) delete mode 100644 packages/pillar-core/src/core/tabs/index.ts create mode 100644 packages/pillar-core/src/core/tabs/index.tsx diff --git a/apps/stories/stories/skeleton.stories.tsx b/apps/stories/stories/skeleton.stories.tsx index 34b4c4bf..536ecdde 100644 --- a/apps/stories/stories/skeleton.stories.tsx +++ b/apps/stories/stories/skeleton.stories.tsx @@ -1,159 +1,160 @@ -// import { Avatar, Button, Flex, Skeleton, Text, Grid } from '@pillar-ui/core' -// import { useBooleanState } from '@pillar-ui/hooks' -// import { Meta } from '@storybook/react' -// import React, { useEffect, useRef } from 'react' - -import { Skeleton } from '@pillar-ui/core' +/* eslint-disable @next/next/no-img-element */ +import { + Avatar, + Button, + Flex, + Skeleton, + Text, + Grid, + SkeletonText, + SkeletonButton, + SkeletonAvatar, +} from '@pillar-ui/core' +import { useBooleanState } from '@pillar-ui/hooks' import { Meta } from '@storybook/react' +import React, { useEffect, useRef } from 'react' -// const meta: Meta = { -// title: 'Components/Skeleton', -// component: Skeleton, -// } - -// export default meta - -// function useLoading() { -// const { booleanValue: loading, setFalse } = useBooleanState(true) -// const timerRef = useRef() +const meta: Meta = { + title: 'Components/Skeleton', + component: Skeleton, +} -// useEffect(() => { -// const timerID = setTimeout(setFalse, 2000) +export default meta -// timerRef.current = timerID +function useLoading() { + const { booleanValue: loading, setFalse } = useBooleanState(true) + const timerRef = useRef() -// return () => { -// clearTimeout(timerRef.current) -// } -// }, [setFalse]) + useEffect(() => { + const timerID = setTimeout(setFalse, 2000) -// return loading -// } + timerRef.current = timerID -// export const SkeletonAvatar = () => { -// const loading = useLoading() -// return ( -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// ) -// } + return () => { + clearTimeout(timerRef.current) + } + }, [setFalse]) -// export const SkeletonTextLines = () => { -// const loading = useLoading() -// return ( -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// ) -// } + return loading +} -// export const SkeletonTextSizes = () => { -// const loading = useLoading() -// return ( -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// hello world -// -// -// ) -// } +export const Avatars = () => { + const loading = useLoading() + return ( + + + + + + + + + + + + + + + + + + ) +} -// export const SkeletonButton = () => { -// const loading = useLoading() -// return ( -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// ) -// } +export const SkeletonTextLines = () => { + const loading = useLoading() + return ( + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + ) +} -// export const SkeletonBox = () => { -// const loading = useLoading() -// return ( -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// ) -// } +export const SkeletonTextSizes = () => { + const loading = useLoading() + return ( + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + hello world + + + ) +} -const meta: Meta = { - title: 'Components/Skeleton', - component: Skeleton, +export const Buttons = () => { + const loading = useLoading() + return ( + + + + + + + + + + + + + + + ) } -export default Meta +export const SkeletonBox = () => { + const loading = useLoading() + return ( + + + + + + + + + + + + + + + ) +} diff --git a/apps/stories/stories/tabs.stories.tsx b/apps/stories/stories/tabs.storiesss.tsx similarity index 97% rename from apps/stories/stories/tabs.stories.tsx rename to apps/stories/stories/tabs.storiesss.tsx index 8955ca3d..e919921c 100644 --- a/apps/stories/stories/tabs.stories.tsx +++ b/apps/stories/stories/tabs.storiesss.tsx @@ -4,9 +4,6 @@ // import type { TabProps } from '@pillar-ui/core' // import { ArrowDown } from '@pillar-ui/icons' -import { Tabs } from '@pillar-ui/core' -import { Meta } from '@storybook/react' - // const meta: Meta = { // title: 'Components/Tabs', // component: Tabs, @@ -138,8 +135,4 @@ import { Meta } from '@storybook/react' // ) // } -const meta: Meta = { - title: 'Components/Tabs', - component: Tabs, -} -export const Playground = {} +export const a = 1 diff --git a/packages/pillar-core/src/core/skeleton/index.tsx b/packages/pillar-core/src/core/skeleton/index.tsx index 024758a6..644ac284 100644 --- a/packages/pillar-core/src/core/skeleton/index.tsx +++ b/packages/pillar-core/src/core/skeleton/index.tsx @@ -9,7 +9,7 @@ import { ForwardRefComponent } from '../../types/polymorphic.type' /////////////////////////////////////////////////////////////////////////////////////////////////// */ -const SkeletonAvatar = forwardRef((props, ref) => { +export const SkeletonAvatar = forwardRef((props, ref) => { const { size = 'xl', corner = 'full', children, isLoading = true, className, ...rest } = props const classNames = classnames(`skeleton skeleton--avatar u_size-${size} u_corner-${corner}`, { [className!]: !!className, @@ -25,7 +25,7 @@ SkeletonAvatar.displayName = 'SkeletonAvatar' /////////////////////////////////////////////////////////////////////////////////////////////////// */ -const SkeletonText = forwardRef((props, ref) => { +export const SkeletonText = forwardRef((props, ref) => { const { size = 'md', lines = 2.5, className, children, isLoading = true, as: Tag = 'div', ...rest } = props const ceilNumber = Math.ceil(lines) const classNames = classnames(`skeleton skeleton--text u_size-${size}`, { [className!]: !!className }) @@ -59,7 +59,7 @@ SkeletonText.displayName = 'SkeletonAvatar' /////////////////////////////////////////////////////////////////////////////////////////////////// */ -const SkeletonButton = forwardRef((props, ref) => { +export const SkeletonButton = forwardRef((props, ref) => { const { size = 'md', as: Tag = 'div', className, isLoading, children, ...rest } = props const classNames = classnames(`skeleton skeleton--btn btn__${size}`, { [className!]: !!className }) const content = diff --git a/packages/pillar-core/src/core/tabs/index.ts b/packages/pillar-core/src/core/tabs/index.ts deleted file mode 100644 index 55f323c5..00000000 --- a/packages/pillar-core/src/core/tabs/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Tabs } from './tabs' diff --git a/packages/pillar-core/src/core/tabs/index.tsx b/packages/pillar-core/src/core/tabs/index.tsx new file mode 100644 index 00000000..76d315a0 --- /dev/null +++ b/packages/pillar-core/src/core/tabs/index.tsx @@ -0,0 +1,157 @@ +// import { Children, forwardRef, useId } from 'react' +// import { ForwardRefComponent } from '../../types/polymorphic.type' +// import type { TabsProps, TabListProps, TabPanelProps, TabsProviderProps, TabProps } from './tabs.type' +// import { Flex } from '../flex' +// import { createContext } from '@pillar-ui/utils' +// import { useRovingIndex } from '@pillar-ui/hooks' + +// /* +// =============================================================================================== +// Tab List Core Component +// =============================================================================================== +// */ + +// const [TabsProvider, useTabsContext] = createContext({ name: 'Tabs' }) + +// export const TabList = forwardRef(({ children, ...rest }, ref) => { +// const { direction, handleKeySelect } = useTabsContext() ?? {} +// const flexDirection = direction === 'horizontal' ? ({ direction: 'column' } as const) : {} +// return ( +// +// {children} +// +// ) +// }) as ForwardRefComponent<'div', TabListProps> +// TabList.displayName = 'Pillar-TabList' + +// /* +// =============================================================================================== +// Tab Core Component +// =============================================================================================== +// */ + +// export const Tab = forwardRef(({ title, value, ...rest }, ref) => { +// const context = useTabsContext() +// const id = `${context?.id}-panel` + +// return ( +// +// ) +// }) as ForwardRefComponent<'button', TabProps> +// Tab.displayName = 'Pillar-Tab' + +// /* +// =============================================================================================== +// Tab Panel Core Component +// =============================================================================================== +// */ + +// export const TabPanel = forwardRef((props, ref) => { +// const { children, value, ...rest } = props +// const context = useTabsContext() +// const id = `${context?.id}-panel` +// if (value !== context?.selected) return null +// return ( +//
+// {children} +//
+// ) +// }) as ForwardRefComponent<'div', TabPanelProps> +// TabPanel.displayName = 'Pillar-TabPanel' + +// /* +// =============================================================================================== +// Tab Panels Core Component +// =============================================================================================== +// */ + +// export const TabPanels = forwardRef((props, ref) => { +// const { color = 'surface-12', children, ...rest } = props + +// return ( +//
+// {children} +//
+// ) +// }) as ForwardRefComponent<'div', TabPanelProps> +// TabPanels.displayName = 'Pillar-TabPanels' + +// /* +// =============================================================================================== +// Tabs Core Component +// =============================================================================================== +// */ + +// export const Tabs = forwardRef( +// ( +// { +// children, +// direction = 'vertical', +// defaultValue, +// size, +// variant = 'bordered', +// corner = 'sm', +// color = 'primary', +// ...rest +// }, +// ref +// ) => { +// const id = useId() +// const { focusedIndex, handleIndexChange, handleKeyEvent } = useRovingIndex(Children.count(children), { +// loop: true, +// defaultIndex: defaultValue, +// direction: direction, +// }) +// // const [selected, setSelected] = useState(defaultValue) +// // function handleSelect(value: string) { +// // setSelected(value) +// // } +// const context = { +// direction, +// selected: focusedIndex, +// handleSelect: handleIndexChange, +// handleKeySelect: handleKeyEvent, +// variant, +// corner, +// id, +// } + +// const flexDirection = direction === 'vertical' ? ({ direction: 'column' } as const) : {} + +// return ( +// +// +// {children} +// +// +// ) +// } +// ) as ForwardRefComponent<'div', TabsProps> + +// Tabs.displayName = 'Pillar-Paper' + +// export type { TabsProps, TabListProps, TabPanelProps, TabsProviderProps, TabProps } + +export const Tabs = () => { + return 'hell' +} diff --git a/packages/pillar-core/src/core/tabs/tabs.type.ts b/packages/pillar-core/src/core/tabs/tabs.type.ts index 3ddb5b38..490276b9 100644 --- a/packages/pillar-core/src/core/tabs/tabs.type.ts +++ b/packages/pillar-core/src/core/tabs/tabs.type.ts @@ -7,7 +7,7 @@ interface TabsBase { color?: Color defaultValue?: number size?: Size - variant?: Omit & 'bordered' + variant?: Omit | 'bordered' corner?: Corner id?: string } @@ -27,5 +27,6 @@ export interface TabListProps {} export interface TabsProviderProps extends TabsBase { handleSelect: (value: number) => void + handleKeySelect: ({ key, preventDefault }: KeyboardEvent) => void selected: number }