Justin Haaheim commited on
Commit
a02a300
1 Parent(s): 34021fc

Make the react app usable on mobile devices/small screens, and clean up theme code (#167)

Browse files

* Fix UI resizing as text comes in

* Get rid of unneeded font size theme code

* Get rid of zIndex hacks that we used for chrome extension

* Get rid of minHeight to remove empty bar at bottom

* WIP try to get font to shrink

* Get responsive font size working

* Wrap the volume slider for narrow vieports

* Make input source row evenly spaced

streaming-react-app/src/StreamingInterface.css CHANGED
@@ -16,10 +16,6 @@
16
  border-radius: 8px;
17
  box-shadow: 0px 24px 30px rgba(0, 0, 0, 0.3);
18
  border: 1px solid rgba(0, 0, 0, 0.05);
19
- min-height: 300px;
20
- /* max-height: 95vh; */
21
- /* max-width: 625px; */
22
- /* min-width: 580px; */
23
  overflow: hidden;
24
  }
25
 
 
16
  border-radius: 8px;
17
  box-shadow: 0px 24px 30px rgba(0, 0, 0, 0.3);
18
  border: 1px solid rgba(0, 0, 0, 0.05);
 
 
 
 
19
  overflow: hidden;
20
  }
21
 
streaming-react-app/src/StreamingInterface.tsx CHANGED
@@ -59,6 +59,7 @@ import {getURLParams} from './URLParams';
59
  import debug from './debug';
60
  import DebugSection from './DebugSection';
61
  import Switch from '@mui/material/Switch';
 
62
 
63
  const AUDIO_STREAM_DEFAULTS: {
64
  [key in SupportedInputSource]: BrowserAudioStreamConfig;
@@ -754,8 +755,7 @@ export default function StreamingInterface() {
754
  <Box
755
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
756
  // @ts-ignore Not sure why it's complaining about complexity here
757
- minWidth={'550px'}
758
- maxWidth={'660px'}>
759
  <div className="main-container-sra">
760
  <div className="top-section-sra horizontal-padding-sra">
761
  <div className="header-container-sra">
@@ -881,74 +881,83 @@ export default function StreamingInterface() {
881
  </FormControl>
882
  </Box>
883
 
884
- <Stack direction="row" spacing={3.5}>
885
- <FormControl disabled={streamFixedConfigOptionsDisabled}>
886
- <RadioGroup
887
- aria-labelledby="output-modes-radio-group-label"
888
- value={outputMode}
889
- onChange={(e) =>
890
- setOutputMode(e.target.value as SupportedOutputMode)
891
- }
892
- name="output-modes-radio-buttons-group">
893
- {
894
- // TODO: Use supported modalities from agentCapabilities
895
- SUPPORTED_OUTPUT_MODES.map(({value, label}) => (
896
- <FormControlLabel
897
- key={value}
898
- value={value}
899
- control={<Radio />}
900
- label={label}
901
- />
902
- ))
903
- }
904
- </RadioGroup>
905
- </FormControl>
906
-
907
- <Stack
908
- direction="column"
909
- spacing={1}
910
- alignItems="flex-start"
911
- sx={{flexGrow: 1}}>
912
- {currentAgent?.dynamicParams?.includes(
913
- 'expressive',
914
- ) && (
915
- <FormControlLabel
916
- control={
917
- <Switch
918
- checked={enableExpressive ?? false}
919
- onChange={(
920
- event: React.ChangeEvent<HTMLInputElement>,
921
- ) => {
922
- const newValue = event.target.checked;
923
- setEnableExpressive(newValue);
924
- onSetDynamicConfig({expressive: newValue});
925
- }}
926
- />
927
  }
928
- label="Expressive"
929
- />
930
- )}
931
-
932
- {isListener && (
933
- <Box
934
- sx={{
935
- flexGrow: 1,
936
- paddingX: 1.5,
937
- paddingY: 1.5,
938
- width: '100%',
939
- }}>
940
- {volumeSliderNode}
941
- </Box>
942
- )}
943
- </Stack>
944
- </Stack>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
945
  </Stack>
946
 
947
  <Stack
948
  direction="row"
949
  spacing={2}
950
  justifyContent="space-between">
951
- <div>
952
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
953
  <FormLabel id="input-source-radio-group-label">
954
  Input Source
@@ -972,8 +981,8 @@ export default function StreamingInterface() {
972
  ))}
973
  </RadioGroup>
974
  </FormControl>
975
- </div>
976
- <div>
977
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
978
  <FormLabel>Options</FormLabel>
979
  <FormControlLabel
@@ -1022,7 +1031,7 @@ export default function StreamingInterface() {
1022
  label="Server Debug Flag"
1023
  />
1024
  </FormControl>
1025
- </div>
1026
  </Stack>
1027
 
1028
  <Stack direction="row" spacing={2}>
 
59
  import debug from './debug';
60
  import DebugSection from './DebugSection';
61
  import Switch from '@mui/material/Switch';
62
+ import {Grid} from '@mui/material';
63
 
64
  const AUDIO_STREAM_DEFAULTS: {
65
  [key in SupportedInputSource]: BrowserAudioStreamConfig;
 
755
  <Box
756
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
757
  // @ts-ignore Not sure why it's complaining about complexity here
758
+ sx={{width: '100%', maxWidth: '660px', minWidth: '320px'}}>
 
759
  <div className="main-container-sra">
760
  <div className="top-section-sra horizontal-padding-sra">
761
  <div className="header-container-sra">
 
881
  </FormControl>
882
  </Box>
883
 
884
+ <Grid container>
885
+ <Grid item xs={12} sm={4}>
886
+ <FormControl
887
+ disabled={streamFixedConfigOptionsDisabled}>
888
+ <RadioGroup
889
+ aria-labelledby="output-modes-radio-group-label"
890
+ value={outputMode}
891
+ onChange={(e) =>
892
+ setOutputMode(
893
+ e.target.value as SupportedOutputMode,
894
+ )
895
+ }
896
+ name="output-modes-radio-buttons-group">
897
+ {
898
+ // TODO: Use supported modalities from agentCapabilities
899
+ SUPPORTED_OUTPUT_MODES.map(({value, label}) => (
900
+ <FormControlLabel
901
+ key={value}
902
+ value={value}
903
+ control={<Radio />}
904
+ label={label}
905
+ />
906
+ ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
907
  }
908
+ </RadioGroup>
909
+ </FormControl>
910
+ </Grid>
911
+
912
+ <Grid item xs={12} sm={8}>
913
+ <Stack
914
+ direction="column"
915
+ spacing={1}
916
+ alignItems="flex-start"
917
+ sx={{flexGrow: 1}}>
918
+ {currentAgent?.dynamicParams?.includes(
919
+ 'expressive',
920
+ ) && (
921
+ <FormControlLabel
922
+ control={
923
+ <Switch
924
+ checked={enableExpressive ?? false}
925
+ onChange={(
926
+ event: React.ChangeEvent<HTMLInputElement>,
927
+ ) => {
928
+ const newValue = event.target.checked;
929
+ setEnableExpressive(newValue);
930
+ onSetDynamicConfig({
931
+ expressive: newValue,
932
+ });
933
+ }}
934
+ />
935
+ }
936
+ label="Expressive"
937
+ />
938
+ )}
939
+
940
+ {isListener && (
941
+ <Box
942
+ sx={{
943
+ flexGrow: 1,
944
+ paddingX: 1.5,
945
+ paddingY: 1.5,
946
+ width: '100%',
947
+ }}>
948
+ {volumeSliderNode}
949
+ </Box>
950
+ )}
951
+ </Stack>
952
+ </Grid>
953
+ </Grid>
954
  </Stack>
955
 
956
  <Stack
957
  direction="row"
958
  spacing={2}
959
  justifyContent="space-between">
960
+ <Box sx={{flex: 1}}>
961
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
962
  <FormLabel id="input-source-radio-group-label">
963
  Input Source
 
981
  ))}
982
  </RadioGroup>
983
  </FormControl>
984
+ </Box>
985
+ <Box sx={{flex: 1}}>
986
  <FormControl disabled={streamFixedConfigOptionsDisabled}>
987
  <FormLabel>Options</FormLabel>
988
  <FormControlLabel
 
1031
  label="Server Debug Flag"
1032
  />
1033
  </FormControl>
1034
+ </Box>
1035
  </Stack>
1036
 
1037
  <Stack direction="row" spacing={2}>
streaming-react-app/src/theme.ts CHANGED
@@ -1,27 +1,4 @@
1
  import {createTheme} from '@mui/material/styles';
2
- // import {red} from '@mui/material/colors';
3
-
4
- const Z_INDEX_BASE = 9999999;
5
-
6
- function getHtmlFontSize(): number | null {
7
- let fontSize: number | null = null;
8
- try {
9
- // NOTE: Even when this is not explicitly set it still returns a value
10
- const fontSizeString = window
11
- .getComputedStyle(document.getElementsByTagName('html')[0])
12
- .getPropertyValue('font-size');
13
- fontSize = parseInt(fontSizeString, 10);
14
- } catch (e) {
15
- console.error('Error getting font size', e);
16
- }
17
-
18
- return fontSize;
19
- }
20
-
21
- const htmlFontSize = getHtmlFontSize();
22
-
23
- const htmlFontSizeObject =
24
- htmlFontSize == null ? {} : {htmlFontSize: htmlFontSize};
25
 
26
  const themeObject = {
27
  palette: {
@@ -35,7 +12,6 @@ const themeObject = {
35
  text: {primary: '#1C2A33'},
36
  },
37
  typography: {
38
- ...htmlFontSizeObject,
39
  fontFamily: [
40
  'Optimistic Text',
41
  'Roboto',
@@ -43,26 +19,22 @@ const themeObject = {
43
  'Arial',
44
  'sans-serif',
45
  ].join(','),
46
- h1: {fontSize: 16, fontWeight: '500'},
47
- body1: {fontSize: 16},
48
- },
49
- // Because our chrome extension uses a high z-index, we need to
50
- // provide that base here so MUI stuff renders correctly
51
- zIndex: {
52
- mobileStepper: Z_INDEX_BASE + 1000,
53
- fab: Z_INDEX_BASE + 1050,
54
- speedDial: Z_INDEX_BASE + 1050,
55
- appBar: Z_INDEX_BASE + 1100,
56
- drawer: Z_INDEX_BASE + 1200,
57
- modal: Z_INDEX_BASE + 1300,
58
- snackbar: Z_INDEX_BASE + 1400,
59
- tooltip: Z_INDEX_BASE + 1500,
60
  },
61
  };
62
 
63
- console.log('themeObject', themeObject);
64
-
65
- // A custom theme for this app
66
  const theme = createTheme(themeObject);
67
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  export default theme;
 
1
  import {createTheme} from '@mui/material/styles';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  const themeObject = {
4
  palette: {
 
12
  text: {primary: '#1C2A33'},
13
  },
14
  typography: {
 
15
  fontFamily: [
16
  'Optimistic Text',
17
  'Roboto',
 
19
  'Arial',
20
  'sans-serif',
21
  ].join(','),
22
+ h1: {fontSize: '1rem', fontWeight: '500'},
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  },
24
  };
25
 
 
 
 
26
  const theme = createTheme(themeObject);
27
 
28
+ /**
29
+ * Set up a responsive font size at the 600px breakpoint
30
+ */
31
+ // default is 1rem (16px)
32
+ theme.typography.body1[theme.breakpoints.down('sm')] = {fontSize: '0.875rem'};
33
+ // default is 1rem (16px)
34
+ theme.typography.h1[theme.breakpoints.down('sm')] = {fontSize: '0.875rem'};
35
+ // default is 0.875rem (14px)
36
+ theme.typography.button[theme.breakpoints.down('sm')] = {fontSize: '0.75rem'};
37
+ // default is 0.875rem (14px)
38
+ theme.typography.body2[theme.breakpoints.down('sm')] = {fontSize: '0.75rem'};
39
+
40
  export default theme;