88 IconButton ,
99 Slider ,
1010 Stack ,
11+ useTheme ,
12+ useMediaQuery ,
1113} from "@mui/material" ;
1214import {
1315 MdPlayArrow ,
@@ -29,65 +31,23 @@ export const Controls = () => {
2931 } : {
3032 spacing : number ;
3133 isDistributed ?: boolean ;
32- } ) => (
33- < Box >
34- < Box
35- sx = { {
36- display : "flex" ,
37- width : "100%" ,
38- ...( isDistributed
39- ? { justifyContent : "space-between" }
40- : { justifyContent : "space-between" , gap : spacing } ) ,
41- } }
42- >
43- { /* Playback controls - distributed individually in poor example */ }
44- { isDistributed ? (
45- < >
46- < IconButton size = "small" sx = { { color : "white" } } >
47- < MdSkipPrevious size = { 24 } />
48- </ IconButton >
49- < IconButton size = "small" sx = { { color : "white" } } >
50- < MdPlayArrow size = { 24 } />
51- </ IconButton >
52- < IconButton size = "small" sx = { { color : "white" } } >
53- < MdSkipNext size = { 24 } />
54- </ IconButton >
34+ } ) => {
35+ const theme = useTheme ( ) ;
36+ const isMobile = useMediaQuery ( theme . breakpoints . down ( "sm" ) ) ;
5537
56- { /* Volume */ }
57- < IconButton size = "small" sx = { { color : "white" } } >
58- < MdVolumeUp size = { 24 } />
59- </ IconButton >
60- < Slider
61- size = "small"
62- defaultValue = { 70 }
63- sx = { {
64- color : "#fff" ,
65- width : 100 ,
66- "& .MuiSlider-thumb" : {
67- width : 12 ,
68- height : 12 ,
69- } ,
70- } }
71- />
72-
73- { /* Settings controls - distributed individually */ }
74- < IconButton size = "small" sx = { { color : "white" } } >
75- < MdClosedCaption size = { 24 } />
76- </ IconButton >
77- < IconButton size = "small" sx = { { color : "white" } } >
78- < MdSpeed size = { 24 } />
79- </ IconButton >
80- < IconButton size = "small" sx = { { color : "white" } } >
81- < MdSettings size = { 24 } />
82- </ IconButton >
83- < IconButton size = "small" sx = { { color : "white" } } >
84- < MdFullscreen size = { 24 } />
85- </ IconButton >
86- </ >
87- ) : (
88- < >
89- { /* Left controls group */ }
90- < Stack direction = "row" spacing = { spacing / 4 } >
38+ return (
39+ < Box >
40+ < Box
41+ sx = { {
42+ display : "flex" ,
43+ width : "100%" ,
44+ ...( isDistributed
45+ ? { justifyContent : "space-between" }
46+ : { justifyContent : "space-between" , gap : spacing } ) ,
47+ } }
48+ >
49+ { isDistributed ? (
50+ < >
9151 < IconButton size = "small" sx = { { color : "white" } } >
9252 < MdSkipPrevious size = { 24 } />
9353 </ IconButton >
@@ -97,29 +57,29 @@ export const Controls = () => {
9757 < IconButton size = "small" sx = { { color : "white" } } >
9858 < MdSkipNext size = { 24 } />
9959 </ IconButton >
100- </ Stack >
10160
102- { /* Volume controls */ }
103- < Stack direction = "row" spacing = { spacing / 4 } alignItems = "center" >
104- < IconButton size = "small" sx = { { color : "white" } } >
105- < MdVolumeUp size = { 24 } />
106- </ IconButton >
107- < Slider
108- size = "small"
109- defaultValue = { 70 }
110- sx = { {
111- color : "#fff" ,
112- width : 100 ,
113- "& .MuiSlider-thumb" : {
114- width : 12 ,
115- height : 12 ,
116- } ,
117- } }
118- />
119- </ Stack >
61+ { /* Volume */ }
62+ { ! isMobile && (
63+ < >
64+ < IconButton size = "small" sx = { { color : "white" } } >
65+ < MdVolumeUp size = { 24 } />
66+ </ IconButton >
67+ < Slider
68+ size = "small"
69+ defaultValue = { 70 }
70+ sx = { {
71+ color : "#fff" ,
72+ width : 100 ,
73+ "& .MuiSlider-thumb" : {
74+ width : 12 ,
75+ height : 12 ,
76+ } ,
77+ } }
78+ />
79+ </ >
80+ ) }
12081
121- { /* Right controls group */ }
122- < Stack direction = "row" spacing = { spacing / 4 } >
82+ { /* Settings controls - distributed individually */ }
12383 < IconButton size = "small" sx = { { color : "white" } } >
12484 < MdClosedCaption size = { 24 } />
12585 </ IconButton >
@@ -132,15 +92,72 @@ export const Controls = () => {
13292 < IconButton size = "small" sx = { { color : "white" } } >
13393 < MdFullscreen size = { 24 } />
13494 </ IconButton >
135- </ Stack >
136- </ >
137- ) }
95+ </ >
96+ ) : (
97+ < >
98+ { /* Left controls group */ }
99+ < Stack direction = "row" spacing = { spacing / 4 } >
100+ < IconButton size = "small" sx = { { color : "white" } } >
101+ < MdSkipPrevious size = { 24 } />
102+ </ IconButton >
103+ < IconButton size = "small" sx = { { color : "white" } } >
104+ < MdPlayArrow size = { 24 } />
105+ </ IconButton >
106+ < IconButton size = "small" sx = { { color : "white" } } >
107+ < MdSkipNext size = { 24 } />
108+ </ IconButton >
109+ </ Stack >
110+
111+ { /* Volume controls */ }
112+
113+ { ! isMobile && (
114+ < Stack
115+ direction = "row"
116+ spacing = { spacing / 4 }
117+ alignItems = "center"
118+ >
119+ < IconButton size = "small" sx = { { color : "white" } } >
120+ < MdVolumeUp size = { 24 } />
121+ </ IconButton >
122+ < Slider
123+ size = "small"
124+ defaultValue = { 70 }
125+ sx = { {
126+ color : "#fff" ,
127+ width : 100 ,
128+ "& .MuiSlider-thumb" : {
129+ width : 12 ,
130+ height : 12 ,
131+ } ,
132+ } }
133+ />
134+ </ Stack >
135+ ) }
136+
137+ { /* Right controls group */ }
138+ < Stack direction = "row" spacing = { spacing / 4 } >
139+ < IconButton size = "small" sx = { { color : "white" } } >
140+ < MdClosedCaption size = { 24 } />
141+ </ IconButton >
142+ < IconButton size = "small" sx = { { color : "white" } } >
143+ < MdSpeed size = { 24 } />
144+ </ IconButton >
145+ < IconButton size = "small" sx = { { color : "white" } } >
146+ < MdSettings size = { 24 } />
147+ </ IconButton >
148+ < IconButton size = "small" sx = { { color : "white" } } >
149+ < MdFullscreen size = { 24 } />
150+ </ IconButton >
151+ </ Stack >
152+ </ >
153+ ) }
154+ </ Box >
138155 </ Box >
139- </ Box >
140- ) ;
156+ ) ;
157+ } ;
141158
142159 return (
143- < Container >
160+ < Container sx = { { pb : 8 } } >
144161 < Grid container spacing = { 4 } >
145162 { /* Poor spacing example */ }
146163 < Grid item xs = { 12 } >
0 commit comments