File tree 5 files changed +64
-11
lines changed
5 files changed +64
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @kleros/ui-components-library" ,
3
- "version" : " 3.0.1 " ,
3
+ "version" : " 3.1.2 " ,
4
4
"description" : " UI components library which implements the Kleros design system." ,
5
5
"source" : " ./src/lib/index.ts" ,
6
6
"main" : " ./dist/esm/ui-components-library.js" ,
Original file line number Diff line number Diff line change @@ -2,23 +2,50 @@ import React from "react";
2
2
import { cn } from "../../utils" ;
3
3
import {
4
4
Modal as AriaModal ,
5
+ Dialog ,
6
+ ModalOverlay ,
7
+ type DialogProps ,
5
8
type ModalOverlayProps ,
6
9
} from "react-aria-components" ;
7
10
11
+ interface ModalProps
12
+ extends Omit < ModalOverlayProps , "children" > ,
13
+ React . RefAttributes < HTMLDivElement > {
14
+ /** classname that applies to the modal overlay. */
15
+ modalOverlayClassname ?: ModalOverlayProps [ "className" ] ;
16
+ children ?: DialogProps [ "children" ] ;
17
+ }
18
+
19
+ /** A modal is an overlay element which blocks interaction with elements outside it. */
8
20
function Modal ( {
9
21
className,
22
+ modalOverlayClassname,
23
+ children,
10
24
...props
11
- } : ModalOverlayProps & React . RefAttributes < HTMLDivElement > ) {
25
+ } : Readonly < ModalProps > ) {
12
26
return (
13
- < AriaModal
27
+ < ModalOverlay
14
28
className = { cn (
15
- "bg-klerosUIComponentsWhiteBackground h-[200px] w-[328px]" ,
16
- "rounded-base box-border" ,
17
- className ,
29
+ "fixed top-0 left-0 isolate" ,
30
+ "z-20 h-(--visual-viewport-height) w-full bg-black/[50%] backdrop-blur-md" ,
31
+ "flex items-center justify-center" ,
32
+ "entering:animate-[fadeIn_100ms_ease-out] exiting:animate-[fadeOut_100ms_ease-in]" ,
33
+ modalOverlayClassname ,
18
34
) }
35
+ { ...props }
19
36
>
20
- { props . children }
21
- </ AriaModal >
37
+ < AriaModal { ...props } >
38
+ < Dialog
39
+ className = { cn (
40
+ "bg-klerosUIComponentsWhiteBackground h-[200px] w-[328px] outline-none" ,
41
+ "rounded-base box-border" ,
42
+ className ,
43
+ ) }
44
+ >
45
+ { children }
46
+ </ Dialog >
47
+ </ AriaModal >
48
+ </ ModalOverlay >
22
49
) ;
23
50
}
24
51
export default Modal ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export { default as Button } from "./button";
6
6
7
7
export { default as Card } from "./container/card" ;
8
8
export { default as Box } from "./container/box" ;
9
+ export { default as Modal } from "./container/modal" ;
9
10
10
11
export { default as DisplayLarge } from "./display/large" ;
11
12
export { default as DisplayIcon } from "./display/icon" ;
Original file line number Diff line number Diff line change 1
1
import type { Meta , StoryObj } from "@storybook/react" ;
2
-
2
+ import React , { useState } from "react" ;
3
3
import { IPreviewArgs } from "./utils" ;
4
4
5
- import ModalComponent from "../lib/container/box" ;
5
+ import ModalComponent from "../lib/container/modal" ;
6
+ import { Button } from "../lib" ;
6
7
7
8
const meta = {
8
9
component : ModalComponent ,
9
10
title : "Containers/Modal" ,
10
11
tags : [ "autodocs" ] ,
12
+ argTypes : {
13
+ isOpen : {
14
+ control : "boolean" ,
15
+ } ,
16
+ isDismissable : {
17
+ control : "boolean" ,
18
+ } ,
19
+ } ,
11
20
} satisfies Meta < typeof ModalComponent > ;
12
21
13
22
export default meta ;
@@ -19,5 +28,21 @@ export const Modal: Story = {
19
28
themeUI : "dark" ,
20
29
backgroundUI : "light" ,
21
30
className : "w-[500px]" ,
31
+ isDismissable : true ,
32
+ } ,
33
+ render : function Render ( args ) {
34
+ const [ isOpen , setOpen ] = useState ( false ) ;
35
+ return (
36
+ < div >
37
+ < Button text = "Press me!" onPress = { ( ) => setOpen ( true ) } />
38
+ < ModalComponent { ...args } isOpen = { isOpen } onOpenChange = { setOpen } >
39
+ < div className = "flex size-full items-center justify-center" >
40
+ < p className = "text-klerosUIComponentsPrimaryText font-semibold" >
41
+ I am a Modal.
42
+ </ p >
43
+ </ div >
44
+ </ ModalComponent >
45
+ </ div >
46
+ ) ;
22
47
} ,
23
48
} ;
Original file line number Diff line number Diff line change 34
34
--klerosUIComponentsBaseRadius : 3px ;
35
35
}
36
36
37
- : root [ class = " dark" ] {
37
+ : root . dark {
38
38
--klerosUIComponentsName : dark;
39
39
--klerosUIComponentsPrimaryPurple : # 7e1bd4 ;
40
40
--klerosUIComponentsSecondaryPurple : # b45fff ;
You can’t perform that action at this time.
0 commit comments