From d7d418db68bb78d789f03411a0f96ca7c73c8887 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 16 Nov 2023 14:19:28 +0300 Subject: [PATCH] packages/ui: add skeleton for input & checkbox --- apps/web/components/Form/Elements.tsx | 1 + packages/ui/checkbox.tsx | 26 +++++++++++++++++--------- packages/ui/input.tsx | 12 ++++++++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/apps/web/components/Form/Elements.tsx b/apps/web/components/Form/Elements.tsx index 2d482c1..55c29ae 100644 --- a/apps/web/components/Form/Elements.tsx +++ b/apps/web/components/Form/Elements.tsx @@ -25,6 +25,7 @@ export function Elements({ data, metaData }: Props) { return ( & - VariantProps; + VariantProps & { readonly loading: boolean }; export const Checkbox = forwardRef( - ({ className, title, ...props }, ref) => ( -
- - {title && ( -
- ) + ({ className, loading, title, ...props }, ref) => { + if (loading) return
; + + return ( +
+ + {title && ( +
+ ); + } ); diff --git a/packages/ui/input.tsx b/packages/ui/input.tsx index 49ee7e3..8c9120c 100644 --- a/packages/ui/input.tsx +++ b/packages/ui/input.tsx @@ -8,11 +8,15 @@ const variants = cva( ); export type InputProps = React.InputHTMLAttributes & - VariantProps; + VariantProps & { readonly loading?: boolean }; -export const Input = forwardRef(({ className, ...props }, ref) => ( - -)); +export const Input = forwardRef( + ({ className, loading, ...props }, ref) => { + if (loading) return
; + + return ; + } +); export const InputNumber = forwardRef((props, ref) => (