@@ -30,6 +30,12 @@ import { startingStateColor, stateSelectedColor } from "../consts/Colors";
3030import { PossibleTransitionValues } from "../consts/PossibleTransitionValues" ;
3131import { TestStringMaxLength } from "../consts/TestStringMaxLength" ;
3232import { TestStringStateId } from "../consts/StateIdsExtensions" ;
33+ import { AppBarAndDrawer } from "../common/AppBarAndDrawer" ;
34+ import { DrawerHeader } from "../common/DrawerHeader" ;
35+ import { MainContent } from "../common/MainContent" ;
36+ import { AppBarAndDrawerProps } from "../common/props/AppBarAndDrawerProps" ;
37+ import { GetDrawerTransitionTableColumns } from "../utils/GetDrawerTransitionTableColumns" ;
38+ import { GetDrawerTransitionTableRows } from "../utils/GetDrawerTransitionTableRows" ;
3339
3440const TestAString = ( props : TestAStringProps ) => {
3541 console . log ( "re rendering TestAString: props" ) ;
@@ -63,6 +69,8 @@ const TestAString = (props: TestAStringProps) => {
6369 > ( [ ] ) ;
6470 const [ dialogError , setDialogError ] = useState ( "" ) ;
6571
72+ const [ open , setOpen ] = useState ( 1 ) ;
73+
6674 useEffect ( ( ) => {
6775 if ( dataContext ) {
6876 setTestAStringStates (
@@ -264,6 +272,16 @@ const TestAString = (props: TestAStringProps) => {
264272 stateSize : dataContext . stateSize ,
265273 } ;
266274
275+ const appBarAndDrawerProps : AppBarAndDrawerProps = {
276+ title : "Test a String" ,
277+ open,
278+ setOpen,
279+ transitionTableProps : {
280+ rows : GetDrawerTransitionTableRows ( dataContext , TestStringStateId ) ,
281+ columns : GetDrawerTransitionTableColumns ( dataContext , false ) ,
282+ } ,
283+ } ;
284+
267285 return (
268286 < >
269287 < Dialog open = { props . isTestAStringDialogOpen } onClose = { handleClose } >
@@ -293,106 +311,101 @@ const TestAString = (props: TestAStringProps) => {
293311 </ Dialog >
294312
295313 { dialogError === "none" && (
296- < Box sx = { { flexGrow : 1 , m : 1 , mt : 5 } } >
297- < Typography
298- variant = "h5"
299- component = "div"
300- gutterBottom
301- align = "center"
302- fontWeight = { "bold" }
303- bgcolor = { stateSelectedColor }
304- >
305- Test a String
306- </ Typography >
307-
308- < Grid
309- container
310- columnSpacing = { {
311- xs : 1 ,
312- sm : 2 ,
313- md : 3 ,
314- } }
315- >
316- < Grid item xs = { 12 } alignItems = { "center" } >
317- < ButtonGroup
318- disableElevation
319- fullWidth
320- variant = "outlined"
321- size = "large"
322- >
323- { testString
324- . replaceAll ( "^" , "" )
325- . split ( "" )
326- . map ( ( char , index ) => (
327- < TextField
328- key = { index }
329- id = { `testString${ index } ` }
330- value = { char }
331- variant = "standard"
332- InputProps = { {
333- readOnly : true ,
334- sx : {
335- textAlignLast : "center" ,
336- } ,
337- } }
338- sx = { {
339- backgroundColor :
340- Math . floor ( ( testStringIndex - 1 ) / 2 ) === index
341- ? startingStateColor
342- : "inherit" ,
343- flexDirection : "inherit" ,
344- borderRadius : "20px" ,
345- border : `1px solid ${ stateSelectedColor } ` ,
346- borderWidth : "0 1px 0 1px" ,
347- } }
348- />
349- ) ) }
350-
351- < FormControl fullWidth >
352- < InputLabel id = "delay-select-label" > Delay</ InputLabel >
353- < Select
354- labelId = "delay-select-label"
355- id = "delay-select"
356- value = { duration . toString ( ) }
357- label = "Delay"
358- onChange = { handleDurationChange }
359- >
360- { AnimationDurationOptions . map ( ( option ) => (
361- < MenuItem key = { option } value = { option } >
362- { option }
363- </ MenuItem >
364- ) ) }
365- </ Select >
366- </ FormControl >
367-
368- < Button
369- onClick = { handleAnimation }
370- startIcon = {
371- isPlaying ? (
372- < PauseRoundedIcon />
373- ) : isComplete ? (
374- < ReplayRoundedIcon />
375- ) : (
376- < PlayArrowRoundedIcon />
377- )
378- }
379- >
380- { isPlaying ? "Pause" : isComplete ? "Replay" : "Play" }
381- </ Button >
382- < Button
383- variant = { isComplete ? "contained" : "outlined" }
384- onClick = { showNextRow }
385- disabled = { isReady }
314+ < Box sx = { { display : "flex" , m : 1 , mt : 5 } } >
315+ < AppBarAndDrawer { ...appBarAndDrawerProps } />
316+
317+ < MainContent open = { open } sx = { { paddingBottom : 12 } } >
318+ < DrawerHeader />
319+
320+ < Grid
321+ container
322+ columnSpacing = { {
323+ xs : 1 ,
324+ sm : 2 ,
325+ md : 3 ,
326+ } }
327+ >
328+ < Grid item xs = { 12 } alignItems = { "center" } >
329+ < ButtonGroup
330+ disableElevation
331+ fullWidth
332+ variant = "outlined"
333+ size = "large"
386334 >
387- { isComplete ? "Complete" : "Next" }
388- </ Button >
389- </ ButtonGroup >
390- </ Grid >
391- { /* Playground grid */ }
392- < Grid item xs = { 12 } >
393- < ToolsPlayground { ...playgroundProps } />
335+ { testString
336+ . replaceAll ( "^" , "" )
337+ . split ( "" )
338+ . map ( ( char , index ) => (
339+ < TextField
340+ key = { index }
341+ id = { `testString${ index } ` }
342+ value = { char }
343+ variant = "standard"
344+ InputProps = { {
345+ readOnly : true ,
346+ sx : {
347+ textAlignLast : "center" ,
348+ } ,
349+ } }
350+ sx = { {
351+ backgroundColor :
352+ Math . floor ( ( testStringIndex - 1 ) / 2 ) === index
353+ ? startingStateColor
354+ : "inherit" ,
355+ flexDirection : "inherit" ,
356+ borderRadius : "20px" ,
357+ border : `1px solid ${ stateSelectedColor } ` ,
358+ borderWidth : "0 1px 0 1px" ,
359+ } }
360+ />
361+ ) ) }
362+
363+ < FormControl fullWidth >
364+ < InputLabel id = "delay-select-label" > Delay</ InputLabel >
365+ < Select
366+ labelId = "delay-select-label"
367+ id = "delay-select"
368+ value = { duration . toString ( ) }
369+ label = "Delay"
370+ onChange = { handleDurationChange }
371+ >
372+ { AnimationDurationOptions . map ( ( option ) => (
373+ < MenuItem key = { option } value = { option } >
374+ { option }
375+ </ MenuItem >
376+ ) ) }
377+ </ Select >
378+ </ FormControl >
379+
380+ < Button
381+ onClick = { handleAnimation }
382+ startIcon = {
383+ isPlaying ? (
384+ < PauseRoundedIcon />
385+ ) : isComplete ? (
386+ < ReplayRoundedIcon />
387+ ) : (
388+ < PlayArrowRoundedIcon />
389+ )
390+ }
391+ >
392+ { isPlaying ? "Pause" : isComplete ? "Replay" : "Play" }
393+ </ Button >
394+ < Button
395+ variant = { isComplete ? "contained" : "outlined" }
396+ onClick = { showNextRow }
397+ disabled = { isReady }
398+ >
399+ { isComplete ? "Complete" : "Next" }
400+ </ Button >
401+ </ ButtonGroup >
402+ </ Grid >
403+ { /* Playground grid */ }
404+ < Grid item xs = { 12 } >
405+ < ToolsPlayground { ...playgroundProps } />
406+ </ Grid >
394407 </ Grid >
395- </ Grid >
408+ </ MainContent >
396409 </ Box >
397410 ) }
398411 </ >
0 commit comments