From ff1f89e8a5ceb31e0f122a96f03c41f8c59fab46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Sefa=20Ar=C5=9Fiv?= Date: Sun, 7 Apr 2024 21:45:26 +0300 Subject: [PATCH 1/2] Bug fixed & UI upgrade --- src/drawer/Drawer.tsx | 18 ++++++++++++++++-- src/input/Input.tsx | 12 ++++++++---- src/select/Select.tsx | 4 ++++ stories/Input.stories.ts | 12 ++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/drawer/Drawer.tsx b/src/drawer/Drawer.tsx index 9167068..8f960ee 100644 --- a/src/drawer/Drawer.tsx +++ b/src/drawer/Drawer.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; interface IDrawerProps { @@ -8,6 +8,20 @@ interface IDrawerProps { } export default function Modal({ isOpen, onClose, children }: IDrawerProps) { + useEffect(() => { + const handleKeyPress = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + onClose(); + } + }; + + window.addEventListener('keydown', handleKeyPress); + + return () => { + window.removeEventListener('keydown', handleKeyPress); + }; + }, []); + return ( {isOpen && ( @@ -27,7 +41,7 @@ export default function Modal({ isOpen, onClose, children }: IDrawerProps) { damping: 30, delay: 0.1, }} - className="bg-white w-80 h-full shadow-xl overflow-y-auto"> + className="bg-white dark:bg-black border-l border-brand w-80 h-full shadow-xl overflow-y-auto">
{children}
{ type: InputType; @@ -69,9 +71,11 @@ const Input = forwardRef( { required?: boolean; disabled?: boolean; messages?: string | string[]; + label?: string; } const Select = forwardRef( @@ -25,11 +27,13 @@ const Select = forwardRef( required, disabled, messages = [], + label, ...props }: ISelectProps, ref: Ref, ) => (
+ {label && }