From d43ac0b0e4b8d03434fc9a787f85a50a5d590636 Mon Sep 17 00:00:00 2001 From: Yannick Date: Wed, 20 Jul 2022 15:39:47 +0200 Subject: [PATCH] Add the Placeholder component --- src/components/Button/Button.tsx | 28 ++++++++++ src/components/Placeholder/Placeholder.tsx | 37 +++++++++++++ src/components/Placeholder/index.ts | 2 + src/components/index.ts | 3 ++ src/docs/App.tsx | 2 + src/docs/components/Layout.tsx | 1 + src/docs/pages/Components/DialogDemo.tsx | 2 +- src/docs/pages/Components/DropdownDemo.tsx | 6 +-- src/docs/pages/Components/PlaceholderDemo.tsx | 52 +++++++++++++++++++ src/index.ts | 3 ++ 10 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 src/components/Placeholder/Placeholder.tsx create mode 100644 src/components/Placeholder/index.ts create mode 100644 src/docs/pages/Components/PlaceholderDemo.tsx diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 3d732b9..2f43f9d 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -39,6 +39,10 @@ interface IButtonProps extends ButtonHTMLAttributes { * As what the component should be rendered */ as?: T; + /** + * Is the button a placeholder + */ + placeholderWidth?: 0 | 1 | 2 | 3 | 4 | 5 | 25 | 50 | 75 | 100 | 'auto'; /** * Button contents. */ @@ -65,10 +69,34 @@ export function Button({ href, className, as, + placeholderWidth, ...props }: ButtonProps) { const Component = useMemo(() => (as ? as : (href ? 'a' : 'button')) as ElementType, [as, href]); + if (placeholderWidth) { + return ( + + + + + + + + ); +} diff --git a/src/index.ts b/src/index.ts index 5289d59..f372b57 100644 --- a/src/index.ts +++ b/src/index.ts @@ -148,6 +148,9 @@ export type { PivotPanelProps } from '@components/PivotPanel'; export { default as PivotPanels } from '@components/PivotPanels'; export type { PivotPanelsProps } from '@components/PivotPanels'; +export { default as Placeholder } from '@components/Placeholder'; +export type { PlaceholderProps } from '@components/Placeholder'; + export { default as Progress } from '@components/Progress'; export type { ProgressProps } from '@components/Progress';