@@ -21,28 +21,34 @@ import ClipCutter from './routes/editor/ClipCutter';
21
21
import SimpleEditor from './routes/editor/SimpleEditor' ;
22
22
import Interstitial from './components/interstitial/Interstitial' ;
23
23
24
+ import riffTraxImage from './images/rifftrax.png' ;
25
+ import whatTheDubImage from './images/whatthedub.png' ;
26
+
24
27
import { useAtom } from 'jotai' ;
25
28
import { interstitialAtom } from './atoms/interstitial.atom' ;
26
29
27
30
import './App.css' ;
28
31
import 'react-toastify/dist/ReactToastify.css' ;
29
32
30
33
import { version } from '../../release/app/package.json' ;
34
+ import { gameAtom } from './atoms/game.atom' ;
31
35
32
36
const VERSION = version ;
33
37
38
+ const imageMap = {
39
+ rifftrax : riffTraxImage ,
40
+ whatthedub : whatTheDubImage ,
41
+ } ;
42
+
34
43
let App = ( props ) => {
35
44
const navigate = useNavigate ( ) ;
36
45
const location = useLocation ( ) ;
37
46
const [ interstitialState , setInterstitialState ] = useAtom ( interstitialAtom ) ;
38
- const [ game , setGame ] = useState ( 'rifftrax' ) ;
47
+ const [ game , setGame ] = useAtom ( gameAtom ) ;
39
48
const [ config , setConfig ] = useState ( { } ) ;
40
49
41
50
const changeGame = ( newGame ) => {
42
51
setGame ( newGame ) ;
43
- navigate ( `/${ location . pathname . split ( '/' ) [ 1 ] } /${ newGame } ` , {
44
- replace : true ,
45
- } ) ;
46
52
} ;
47
53
48
54
useEffect ( ( ) => {
@@ -78,27 +84,60 @@ let App = (props) => {
78
84
< Interstitial isOpen = { interstitialState . isOpen } >
79
85
{ interstitialState . message }
80
86
</ Interstitial >
81
- { location . pathname !== `/create/ ${ game } ` ? (
87
+ { ! location . pathname . includes ( `/create` ) ? (
82
88
< div >
83
- < h1 > Dub Editor</ h1 >
84
- < hr />
85
- < div > { VERSION } </ div >
86
- < label > Game:</ label >
87
- < select
88
- value = { game }
89
- onChange = { ( { target : { value } } ) => {
90
- changeGame ( value ) ;
89
+ < header
90
+ style = { {
91
+ display : 'flex' ,
92
+ flexDirection : 'row' ,
93
+ justifyContent : 'center' ,
94
+ alignItems : 'center' ,
95
+ gap : '10px' ,
91
96
} }
92
97
>
93
- < option value = "rifftrax" > Rifftrax</ option >
94
- < option value = "whatthedub" > What the Dub</ option >
95
- </ select >
98
+ < div
99
+ style = { {
100
+ display : 'flex' ,
101
+ flexDirection : 'row' ,
102
+ justifyContent : 'center' ,
103
+ alignItems : 'center' ,
104
+ gap : '10px' ,
105
+ } }
106
+ >
107
+ < h1 > Dub Editor</ h1 >
108
+ < div > { VERSION } </ div >
109
+ </ div >
110
+ < div >
111
+ < img
112
+ src = { imageMap [ game ] }
113
+ style = { {
114
+ width : '100px' ,
115
+ height : '100px' ,
116
+ objectFit : 'contain' ,
117
+ } }
118
+ />
119
+ < div >
120
+ < label > Game:</ label >
121
+ < select
122
+ value = { game }
123
+ onChange = { ( { target : { value } } ) => {
124
+ setGame ( value ) ;
125
+ } }
126
+ >
127
+ < option value = "rifftrax" > Rifftrax</ option >
128
+ < option value = "whatthedub" >
129
+ What the Dub
130
+ </ option >
131
+ </ select >
132
+ </ div >
133
+ </ div >
134
+ </ header >
96
135
< hr />
97
136
< Link
98
137
className = { ( { isActive } ) =>
99
138
isActive ? 'active' : null
100
139
}
101
- to = { `/videos/ ${ game } ` }
140
+ to = { `/videos` }
102
141
>
103
142
Clips
104
143
</ Link >
@@ -107,7 +146,7 @@ let App = (props) => {
107
146
className = { ( { isActive } ) =>
108
147
isActive ? 'active' : null
109
148
}
110
- to = { `/collections/ ${ game } ` }
149
+ to = { `/collections` }
111
150
>
112
151
Packs
113
152
</ Link >
@@ -116,7 +155,7 @@ let App = (props) => {
116
155
className = { ( { isActive } ) =>
117
156
isActive ? 'active' : null
118
157
}
119
- to = { `/config/ ${ game } ` }
158
+ to = { `/config` }
120
159
>
121
160
Config
122
161
</ Link >
@@ -125,7 +164,7 @@ let App = (props) => {
125
164
className = { ( { isActive } ) =>
126
165
isActive ? 'active' : null
127
166
}
128
- to = { `/about/ ${ game } ` }
167
+ to = { `/about` }
129
168
>
130
169
About
131
170
</ Link >
@@ -140,46 +179,30 @@ let App = (props) => {
140
179
) : null }
141
180
< div style = { { minHeight : '50vh' } } >
142
181
< Routes >
143
- < Route exact path = { `/about/:game` } element = { < About /> } />
144
- < Route exact path = { `/config/:game` } element = { < Config /> } />
145
- < Route
146
- exact
147
- path = { `/batch/:type` }
148
- element = { < ClipCutter game = { game } /> }
149
- />
150
- < Route
151
- exact
152
- path = { `/create/:type` }
153
- element = { < ClipEditor game = { game } /> }
154
- />
182
+ < Route exact path = { `/about` } element = { < About /> } />
183
+ < Route exact path = { `/config` } element = { < Config /> } />
184
+ < Route exact path = { `/batch` } element = { < ClipCutter /> } />
185
+ < Route exact path = { `/create` } element = { < ClipEditor /> } />
155
186
< Route
156
187
exact
157
- path = { `/create/advanced/:type ` }
188
+ path = { `/create/advanced` }
158
189
element = { < AdvancedEditor /> }
159
190
/>
160
191
< Route
161
192
exact
162
- path = { `/create/simple/:type ` }
193
+ path = { `/create/simple` }
163
194
element = { < SimpleEditor /> }
164
195
/>
165
196
< Route
166
197
exact
167
- path = { `/collections/:game ` }
198
+ path = { `/collections` }
168
199
element = { < CollectionManager /> }
169
200
/>
170
- < Route
171
- exact
172
- path = { `/videos/:game` }
173
- element = { < VideoList /> }
174
- />
175
- < Route
176
- exact
177
- path = { `/videos/:game/:id` }
178
- element = { < VideoView /> }
179
- />
201
+ < Route exact path = { `/videos` } element = { < VideoList /> } />
202
+ < Route exact path = { `/videos/:id` } element = { < VideoView /> } />
180
203
< Route
181
204
path = "*"
182
- element = { < Navigate to = "/videos/rifftrax " replace /> }
205
+ element = { < Navigate to = "/videos" replace /> }
183
206
/>
184
207
</ Routes >
185
208
</ div >
0 commit comments