22
33import reflex as rx
44
5- from app .core .variables import ICON_SIZE_MEDIUM , ICON_SIZE_XL , MAX_DIALOG_WIDTH , SIZE_MEDIUM , SPACING_LARGE , SPACING_SMALL , TEXT_SIZE_LABEL
5+ from app .core .variables import (
6+ ICON_SIZE_MEDIUM ,
7+ ICON_SIZE_XL ,
8+ MAX_DIALOG_WIDTH ,
9+ PADDING_MEDIUM ,
10+ SIZE_MEDIUM ,
11+ SPACING_LARGE ,
12+ SPACING_MEDIUM ,
13+ SPACING_SMALL ,
14+ SPACING_TINY ,
15+ TEXT_SIZE_LABEL ,
16+ )
617from app .features .keys .state import KeysState
718from app .shared .components .dialogs import entity_delete_dialog
819
@@ -11,23 +22,32 @@ def keys_created_dialog() -> rx.Component:
1122 """Dialog to display the newly created API key."""
1223 return rx .dialog .root (
1324 rx .dialog .content (
14- rx .dialog .title (
25+ rx .vstack (
26+ # Header
1527 rx .hstack (
16- rx .icon ("check_check" , size = ICON_SIZE_XL , color = rx .color ("green" , 11 )),
17- "API Key created successfully!" ,
18- spacing = SPACING_SMALL ,
28+ rx .icon ("circle_check" , size = ICON_SIZE_XL , color = rx .color ("green" , 9 )),
29+ rx .vstack (
30+ rx .dialog .title ("API key created" , margin = "0" ),
31+ spacing = SPACING_TINY ,
32+ align = "start" ,
33+ ),
34+ spacing = SPACING_MEDIUM ,
1935 align = "center" ,
20- )
21- ),
22- rx .dialog .description (
23- "Copy your API key now. You won't be able to see it again!" ,
24- color = rx .color ("red" , 11 ),
25- weight = "bold" ,
26- ),
27- rx .vstack (
36+ width = "100%" ,
37+ ),
38+ # Warning
39+ rx .callout (
40+ "Copy your key now, for security reasons you won't be able to see it again." ,
41+ icon = "triangle_alert" ,
42+ color_scheme = "amber" ,
43+ variant = "surface" ,
44+ size = "1" ,
45+ width = "100%" ,
46+ ),
47+ # Key
2848 rx .vstack (
2949 rx .text (
30- "Your API Key: " ,
50+ "Your API key " ,
3151 size = TEXT_SIZE_LABEL ,
3252 weight = "bold" ,
3353 color = rx .color ("mauve" , 11 ),
@@ -42,19 +62,35 @@ def keys_created_dialog() -> rx.Component:
4262 spacing = SPACING_SMALL ,
4363 width = "100%" ,
4464 ),
45- rx .dialog .close (
65+ # Footer
66+ rx .hstack (
67+ rx .dialog .close (
68+ rx .button (
69+ "Done" ,
70+ on_click = KeysState .clear_created_key ,
71+ variant = "soft" ,
72+ color_scheme = "gray" ,
73+ size = SIZE_MEDIUM ,
74+ ),
75+ ),
4676 rx .button (
47- rx .icon ("check" , size = ICON_SIZE_MEDIUM ),
48- "I've copied the key" ,
49- on_click = KeysState .clear_created_key ,
77+ rx .icon ("copy" , size = ICON_SIZE_MEDIUM ),
78+ "Copy API key" ,
79+ on_click = [
80+ rx .set_clipboard (KeysState .created_key ),
81+ rx .toast .success ("API key copied to clipboard" , position = "bottom-right" ),
82+ ],
5083 size = SIZE_MEDIUM ,
51- width = "100%" ,
5284 ),
85+ spacing = SPACING_MEDIUM ,
86+ justify = "end" ,
87+ width = "100%" ,
5388 ),
5489 spacing = SPACING_LARGE ,
5590 width = "100%" ,
5691 ),
5792 max_width = MAX_DIALOG_WIDTH ,
93+ padding = PADDING_MEDIUM ,
5894 ),
5995 open = KeysState .is_created_dialog_open ,
6096 on_open_change = KeysState .handle_created_dialog_change ,
0 commit comments