1
+ import { CopyButton } from '@/modules/shared/copy/copy-button' ;
2
+ import { createRefreshableSignal } from '@/modules/shared/signals' ;
3
+ import { Button } from '@/modules/ui/components/button' ;
4
+ import { Card , CardContent , CardFooter , CardHeader , CardTitle } from '@/modules/ui/components/card' ;
1
5
import { Switch , SwitchControl , SwitchLabel , SwitchThumb } from '@/modules/ui/components/switch' ;
2
6
import { TextArea } from '@/modules/ui/components/textarea' ;
3
7
import { TextFieldRoot } from '@/modules/ui/components/textfield' ;
4
8
import { type Component , createSignal } from 'solid-js' ;
9
+ import { ToolHeader } from '../../components/tool-header' ;
5
10
import { useCurrentTool } from '../../tools.provider' ;
6
11
import defaultDictionary from './locales/en.json' ;
7
12
import { createToken } from './token-generator.models' ;
@@ -13,57 +18,90 @@ const TokenGeneratorTool: Component = () => {
13
18
const [ getUseSpecialCharacters , setUseSpecialCharacters ] = createSignal ( false ) ;
14
19
const [ getLength ] = createSignal ( 64 ) ;
15
20
16
- const { t } = useCurrentTool ( { defaultDictionary } ) ;
21
+ const { t, getTool } = useCurrentTool ( { defaultDictionary } ) ;
17
22
18
- const getToken = ( ) => createToken ( {
23
+ const [ getToken , refreshToken ] = createRefreshableSignal ( ( ) => createToken ( {
19
24
withUppercase : getUseUpperCase ( ) ,
20
25
withLowercase : getUseLowerCase ( ) ,
21
26
withNumbers : getUseNumbers ( ) ,
22
27
withSymbols : getUseSpecialCharacters ( ) ,
23
28
length : getLength ( ) ,
24
- } ) ;
29
+ } ) ) ;
25
30
26
31
return (
27
- < div class = "space-y-2 mx-auto max-w-1200px p-6" >
28
- < Switch class = "flex items-center space-x-2" checked = { getUseUpperCase ( ) } onChange = { setUseUpperCase } >
29
- < SwitchControl >
30
- < SwitchThumb />
31
- </ SwitchControl >
32
- < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
33
- { t ( 'uppercase' ) }
34
- </ SwitchLabel >
35
- </ Switch >
36
-
37
- < Switch class = "flex items-center space-x-2" checked = { getUseLowerCase ( ) } onChange = { setUseLowerCase } >
38
- < SwitchControl >
39
- < SwitchThumb />
40
- </ SwitchControl >
41
- < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
42
- { t ( 'lowercase' ) }
43
- </ SwitchLabel >
44
- </ Switch >
45
-
46
- < Switch class = "flex items-center space-x-2" checked = { getUseNumbers ( ) } onChange = { setUseNumbers } >
47
- < SwitchControl >
48
- < SwitchThumb />
49
- </ SwitchControl >
50
- < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
51
- { t ( 'numbers' ) }
52
- </ SwitchLabel >
53
- </ Switch >
54
-
55
- < Switch class = "flex items-center space-x-2" checked = { getUseSpecialCharacters ( ) } onChange = { setUseSpecialCharacters } >
56
- < SwitchControl >
57
- < SwitchThumb />
58
- </ SwitchControl >
59
- < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
60
- { t ( 'symbols' ) }
61
- </ SwitchLabel >
62
- </ Switch >
63
-
64
- < TextFieldRoot >
65
- < TextArea placeholder = "Your token will appear here" value = { getToken ( ) } readonly />
66
- </ TextFieldRoot >
32
+ < div >
33
+ < ToolHeader { ...getTool ( ) } />
34
+
35
+ < div class = "mx-auto max-w-1200px p-6 flex flex-col gap-4 md:flex-row items-start" >
36
+ < Card >
37
+ < CardHeader class = "border-b border-border" >
38
+ < CardTitle class = "text-muted-foreground" >
39
+ Configuration
40
+ </ CardTitle >
41
+ </ CardHeader >
42
+
43
+ < CardContent class = "pt-6 flex flex-col gap-2" >
44
+ < Switch class = "flex items-center gap-2" checked = { getUseUpperCase ( ) } onChange = { setUseUpperCase } >
45
+ < SwitchControl >
46
+ < SwitchThumb />
47
+ </ SwitchControl >
48
+ < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
49
+ { t ( 'uppercase' ) }
50
+ </ SwitchLabel >
51
+ </ Switch >
52
+
53
+ < Switch class = "flex items-center gap-2" checked = { getUseLowerCase ( ) } onChange = { setUseLowerCase } >
54
+ < SwitchControl >
55
+ < SwitchThumb />
56
+ </ SwitchControl >
57
+ < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
58
+ { t ( 'lowercase' ) }
59
+ </ SwitchLabel >
60
+ </ Switch >
61
+
62
+ < Switch class = "flex items-center gap-2" checked = { getUseNumbers ( ) } onChange = { setUseNumbers } >
63
+ < SwitchControl >
64
+ < SwitchThumb />
65
+ </ SwitchControl >
66
+ < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
67
+ { t ( 'numbers' ) }
68
+ </ SwitchLabel >
69
+ </ Switch >
70
+
71
+ < Switch class = "flex items-center gap-2" checked = { getUseSpecialCharacters ( ) } onChange = { setUseSpecialCharacters } >
72
+ < SwitchControl >
73
+ < SwitchThumb />
74
+ </ SwitchControl >
75
+ < SwitchLabel class = "text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70" >
76
+ { t ( 'symbols' ) }
77
+ </ SwitchLabel >
78
+ </ Switch >
79
+ </ CardContent >
80
+
81
+ </ Card >
82
+
83
+ < Card class = "flex-1" >
84
+ < CardHeader class = "border-b border-border flex justify-between flex-row py-3 items-center" >
85
+ < CardTitle class = "text-muted-foreground" >
86
+ Your token
87
+ </ CardTitle >
88
+
89
+ < div class = "flex justify-center items-center gap-2" >
90
+ < Button onClick = { refreshToken } variant = "outline" >
91
+ < div class = "i-tabler-refresh mr-2 text-base text-muted-foreground" />
92
+ Refresh token
93
+ </ Button >
94
+
95
+ < CopyButton textToCopy = { getToken } toastMessage = { t ( 'copy-toast' ) } />
96
+ </ div >
97
+ </ CardHeader >
98
+
99
+ < CardContent class = "pt-6 text-center" >
100
+ { getToken ( ) }
101
+ </ CardContent >
102
+
103
+ </ Card >
104
+ </ div >
67
105
</ div >
68
106
) ;
69
107
} ;
0 commit comments