diff --git a/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.stories.tsx b/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.stories.tsx index ab5ea48372..de92e38880 100644 --- a/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.stories.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.stories.tsx @@ -11,14 +11,11 @@ const Template: ComponentStory = (args) => ; export const AvatarAsLetter = Template.bind({}); AvatarAsLetter.args = { - asChild: true, - children: 'M', + children: 'MR', }; export const AvatarAsDefault = Template.bind({}); -AvatarAsDefault.args = { - asChild: true, -}; +AvatarAsDefault.args = {}; export const AvatarByImgSrc = Template.bind({}); AvatarByImgSrc.args = { diff --git a/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.tsx b/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.tsx index b4fc4c6427..fda86b54a7 100644 --- a/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/avatar/Avatar.tsx @@ -1,4 +1,5 @@ import cx from 'classnames'; +import { forwardRef } from 'react'; import { IconContext } from 'react-icons'; import { HiOutlineUser } from 'react-icons/hi'; import { twMerge } from 'tailwind-merge'; @@ -6,7 +7,6 @@ import { twMerge } from 'tailwind-merge'; import { Typography } from '@/components/typography/Typography'; type AvatarType = { - asChild?: boolean; alt?: string; src?: string; className?: string; @@ -14,46 +14,37 @@ type AvatarType = { onClick?: () => void; }; -const Child = ({ children }: { children: AvatarType['children'] }) => { - return ( - <> - {children ? ( - children - ) : ( - - - - )} - - ); -}; - -export const Avatar = (props: AvatarType) => { - const { - asChild = false, - children = undefined, - src = '', - alt = '', - className = '', - onClick, - } = props; +const DefaultIcon = () => ( + + + +); - return ( - - ); -}; +export const Avatar = forwardRef( + ({ children = , src = '', alt = '', className = '', onClick }, ref) => { + return ( + + ); + }, +); diff --git a/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.stories.tsx b/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.stories.tsx index 9654ae7243..fe5a4a6842 100644 --- a/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.stories.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.stories.tsx @@ -33,6 +33,28 @@ export const ModalWithTrigger = () => { ); }; +export const TriggerFromLeft = () => { + const [open, setOpen] = useState(false); + const ref = useRef(null); + + return ( + <> + + setOpen(false)} + elementToFocusOnCloseRef={ref} + direction="left" + > +
This is a content
+
+ + ); +}; + export const WithoutTitle = () => { const [open, setOpen] = useState(false); const ref = useRef(null); diff --git a/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.tsx b/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.tsx index af4d649450..92f817bb40 100644 --- a/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.tsx +++ b/deepfence_frontend/packages/ui-components/src/components/modal/SlidingModal.tsx @@ -15,6 +15,7 @@ type ChildrenType = { children: React.ReactNode; }; export interface ModalProps extends DialogPrimitive.DialogProps { + direction?: 'left' | 'right'; width?: string; title?: string; footer?: React.ReactNode; @@ -86,6 +87,7 @@ export const SlidingModal: FC = ({ elementToFocusOnCloseRef, open, width = 'w-9/12', // 33.333333% + direction = 'right', ...rest }) => { const state = useUpdateStateIfMounted(open); @@ -96,6 +98,14 @@ export const SlidingModal: FC = ({ setWasOpen(open); }, [open]); + let inAnimation = 'animate-slide-right-in'; + let outAnimation = `animate-slide-right-out`; + + if (direction === 'left') { + inAnimation = 'animate-slide-left-in'; + outAnimation = 'animate-slide-left-out'; + } + return ( @@ -107,14 +117,16 @@ export const SlidingModal: FC = ({ > elementToFocusOnCloseRef?.current?.focus()} diff --git a/deepfence_frontend/packages/ui-components/tailwind.config.cjs b/deepfence_frontend/packages/ui-components/tailwind.config.cjs index c2daae34f6..5c37d2cbee 100644 --- a/deepfence_frontend/packages/ui-components/tailwind.config.cjs +++ b/deepfence_frontend/packages/ui-components/tailwind.config.cjs @@ -47,6 +47,12 @@ module.exports = { 'slide-right-out': { '0%': { right: 0 }, }, + 'slide-left-in': { + '100%': { left: 0 }, + }, + 'slide-left-out': { + '0%': { left: 0 }, + }, 'opacity-in': { '0%': { opacity: 0 }, '100%': { opacity: 1 }, @@ -102,6 +108,8 @@ module.exports = { 'pop-out': 'pop-out 0.5s ease', 'slide-right-in': 'slide-right-in 0.5s forwards', 'slide-right-out': 'slide-right-out 0.5s forwards', + 'slide-left-in': 'slide-left-in 0.2s forwards', + 'slide-left-out': 'slide-left-out 0.5s forwards', 'slide-opacity-out': 'slide-opacity-out 0.3s ease', 'opacity-out': 'opacity-out 0.5s ease', 'opacity-in': 'opacity-in 0.5s ease',