1616 * along with this program. If not, see <https://www.gnu.org/licenses/>.
1717 */
1818
19- import type { Styles , TextInputStylesNames } from "@mantine/core" ;
2019import { Box , Button , Checkbox , Flex , Group , Slider , Text , TextInput , Textarea , useMantineColorScheme } from "@mantine/core" ;
2120import { useForm } from "@mantine/form" ;
2221import React , { useCallback , useEffect , useRef , useState } from "react" ;
2322import { appVersion } from "./modals/version" ;
2423import { ProgressBar } from "./progressbar" ;
2524import { bytesToHumanReadableStr } from "trutil" ;
25+ import classes from "./createtorrentform.module.css" ;
2626const { appWindow, invoke, dialogOpen, dialogSave } = await import ( /* webpackChunkName: "taurishim" */ "taurishim" ) ;
2727
2828interface FormValues {
@@ -37,18 +37,10 @@ interface FormValues {
3737 version : string ,
3838}
3939
40- const textAreaStyles : Styles < TextInputStylesNames , Record < string , unknown > > = {
41- root : {
42- flexGrow : 1 ,
43- display : "flex" ,
44- flexDirection : "column" ,
45- } ,
46- wrapper : {
47- flexGrow : 1 ,
48- } ,
49- input : {
50- height : "100%" ,
51- } ,
40+ const textAreaClassNames = {
41+ root : classes . textAreaRoot ,
42+ wrapper : classes . textAreaWrapper ,
43+ input : classes . textAreaInput ,
5244} ;
5345
5446const byteLabel = ( b : number ) => {
@@ -85,7 +77,7 @@ interface InfobarState {
8577}
8678
8779export default function CreateTorrentForm ( ) {
88- const { toggleColorScheme } = useMantineColorScheme ( ) ;
80+ const { setColorScheme } = useMantineColorScheme ( ) ;
8981 const [ defaultTrackers , setDefaultTrackers ] = useState < string [ ] > ( [ ] ) ;
9082 const [ pieces , setPieces ] = useState ( {
9183 done : 0 ,
@@ -114,11 +106,11 @@ export default function CreateTorrentForm() {
114106 useEffect ( ( ) => {
115107 void appWindow . once < PassEventData > ( "pass-from-window" , ( { payload : data } ) => {
116108 const { colorScheme, defaultTrackers } = JSON . parse ( data . payload ) ;
117- toggleColorScheme ( colorScheme ) ;
109+ setColorScheme ( colorScheme ) ;
118110 setDefaultTrackers ( defaultTrackers ) ;
119111 } ) ;
120112 void invoke ( "pass_to_window" , { to : "main" , payload : "ready" } ) ;
121- } , [ toggleColorScheme ] ) ;
113+ } , [ setColorScheme ] ) ;
122114
123115 const { setFieldValue } = form ;
124116
@@ -245,12 +237,12 @@ export default function CreateTorrentForm() {
245237 const browseDisabled = [ "calculating" , "generating" ] . includes ( state . state ) ;
246238
247239 return (
248- < Flex direction = "column" h = "100%" w = "100%" p = "lg" gap = "lg " >
240+ < Flex direction = "column" h = "100%" w = "100%" p = "lg" gap = "md " >
249241 < Group align = "flex-end" >
250242 < TextInput
251243 label = { "Select file or directory" }
252244 { ...form . getInputProps ( "path" ) }
253- styles = { { root : { flexGrow : 1 } } }
245+ style = { { flexGrow : 1 } }
254246 readOnly
255247 autoComplete = "off" autoCorrect = "off" autoCapitalize = "off" spellCheck = "false" />
256248 < Button onClick = { onBrowseFile } disabled = { browseDisabled } > File</ Button >
@@ -263,6 +255,7 @@ export default function CreateTorrentForm() {
263255 < Text fz = "sm" > Piece size</ Text >
264256 < Slider
265257 pt = "2.5rem"
258+ mt = "-0.5rem"
266259 pb = "0.5rem"
267260 px = "1rem"
268261 scale = { ( v ) => 2 ** v }
@@ -284,21 +277,21 @@ export default function CreateTorrentForm() {
284277 label = "Private torrent"
285278 { ...form . getInputProps ( "private" , { type : "checkbox" } ) } />
286279 < Group align = "flex-end" >
287- < Box sx = { { flexGrow : 1 } } > Tracker list, one per line, empty line between tiers</ Box >
280+ < Box style = { { flexGrow : 1 } } > Tracker list, one per line, empty line between tiers</ Box >
288281 < Button onClick = { addDefaultTrackers } > Add default list</ Button >
289282 </ Group >
290283 < Textarea
291- styles = { textAreaStyles }
284+ classNames = { textAreaClassNames }
292285 value = { form . values . announceList . join ( "\n" ) }
293286 onChange = { ( e ) => { form . setFieldValue ( "announceList" , e . target . value . split ( "\n" ) ) ; } } />
294287 < Textarea
295- styles = { textAreaStyles }
288+ classNames = { textAreaClassNames }
296289 label = "Web seed URLs, one per line"
297290 value = { form . values . urlList . join ( "\n" ) }
298291 onChange = { ( e ) => { form . setFieldValue ( "urlList" , e . target . value . split ( "\n" ) ) ; } } />
299292 < Box h = "1.5rem" >
300293 { state . state === "error" &&
301- < Text color = "red" > { state . error } </ Text > }
294+ < Text c = "red" > { state . error } </ Text > }
302295 { state . state === "calculating" &&
303296 < Text > Calculating sizes...</ Text > }
304297 { state . state === "sizes" &&
@@ -316,7 +309,7 @@ export default function CreateTorrentForm() {
316309 { state . state === "done" &&
317310 < Text > { `Torrent infohash: ${ state . hash } ` } </ Text > }
318311 </ Box >
319- < Group position = "center" >
312+ < Group justify = "center" >
320313 { ( [ "idle" , "error" , "calculating" , "sizes" ] . includes ( state . state ) ) &&
321314 < Button miw = "10rem" onClick = { onGenerate } disabled = { state . state === "calculating" } > Generate</ Button > }
322315 { state . state === "generating" &&
0 commit comments