Skip to content

Commit 3c49fad

Browse files
committed
Inline CSS for Settings component
1 parent f63c5a4 commit 3c49fad

28 files changed

+60
-71
lines changed

src/components/GraphViewport.tsx

+2-16
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,7 @@ export default class GraphViewport extends Component<
126126
const isLoading = this.state.svgViewport == null;
127127
const { svgViewport } = this.state;
128128
return (
129-
<Box
130-
sx={(theme) => ({
131-
flex: 1,
132-
position: 'relative',
133-
display: 'inline-block',
134-
width: '100%',
135-
height: '100%',
136-
maxHeight: '100%',
137-
138-
[theme.breakpoints.down('md')]: {
139-
height: '50%',
140-
maxWidth: 'none',
141-
},
142-
})}
143-
>
129+
<>
144130
<Box
145131
role="img"
146132
aria-label="Visual representation of the GraphQL schema"
@@ -189,7 +175,7 @@ export default class GraphViewport extends Component<
189175
</Stack>
190176
)}
191177
{isLoading && <LoadingAnimation />}
192-
</Box>
178+
</>
193179
);
194180
}
195181

src/components/Voyager.css

-27
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,4 @@
3030
max-width: none;
3131
}
3232
}
33-
34-
& > .menu-content {
35-
position: absolute;
36-
z-index: 5;
37-
bottom: var(--panel-spacing);
38-
left: calc(var(--doc-panel-width) + var(--panel-spacing));
39-
background: var(--doc-panel-bg-color);
40-
box-shadow: 0 4px 4px -2px var(--shadow-color);
41-
border: 1px solid var(--shadow-color);
42-
padding: var(--spacing-unit);
43-
44-
& > .setting-other-options {
45-
display: flex;
46-
47-
& > label:first-of-type {
48-
padding-right: var(--spacing-unit);
49-
}
50-
51-
& > label {
52-
margin-bottom: calc(var(--panel-spacing) - var(--spacing-unit));
53-
}
54-
}
55-
56-
@media (--small-viewport) {
57-
left: 10px;
58-
}
59-
}
6033
}

src/components/Voyager.tsx

+34-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import './Voyager.css';
22
import './viewport.css';
33

4+
import Box from '@mui/material/Box';
45
import Button from '@mui/material/Button';
56
import Stack from '@mui/material/Stack';
67
import { ThemeProvider } from '@mui/material/styles';
@@ -127,7 +128,6 @@ export default function Voyager(props: VoyagerProps) {
127128
<ThemeProvider theme={theme}>
128129
<div className="graphql-voyager">
129130
{!hideDocs && renderPanel()}
130-
{!hideSettings && renderSettings()}
131131
{renderGraphViewport()}
132132
{allowToChangeSchema && renderIntrospectionModal()}
133133
</div>
@@ -190,30 +190,41 @@ export default function Voyager(props: VoyagerProps) {
190190
);
191191
}
192192

193-
function renderSettings() {
194-
if (typeGraph == null) return null;
195-
196-
return (
197-
<Settings
198-
options={displayOptions}
199-
typeGraph={typeGraph}
200-
onChange={(options) =>
201-
setDisplayOptions((oldOptions) => ({ ...oldOptions, ...options }))
202-
}
203-
/>
204-
);
205-
}
206-
207193
function renderGraphViewport() {
208194
return (
209-
<GraphViewport
210-
typeGraph={typeGraph}
211-
selectedTypeID={selected.typeID}
212-
selectedEdgeID={selected.edgeID}
213-
onSelectNode={handleSelectNode}
214-
onSelectEdge={handleSelectEdge}
215-
ref={viewportRef}
216-
/>
195+
<Box
196+
sx={(theme) => ({
197+
flex: 1,
198+
position: 'relative',
199+
display: 'inline-block',
200+
width: '100%',
201+
height: '100%',
202+
maxHeight: '100%',
203+
204+
[theme.breakpoints.down('md')]: {
205+
height: '50%',
206+
maxWidth: 'none',
207+
},
208+
})}
209+
>
210+
{!hideSettings && (
211+
<Settings
212+
options={displayOptions}
213+
typeGraph={typeGraph}
214+
onChange={(options) =>
215+
setDisplayOptions((oldOptions) => ({ ...oldOptions, ...options }))
216+
}
217+
/>
218+
)}
219+
<GraphViewport
220+
typeGraph={typeGraph}
221+
selectedTypeID={selected.typeID}
222+
selectedEdgeID={selected.edgeID}
223+
onSelectNode={handleSelectNode}
224+
onSelectEdge={handleSelectEdge}
225+
ref={viewportRef}
226+
/>
227+
</Box>
217228
);
218229
}
219230

src/components/settings/Settings.tsx

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
import Checkbox from '@mui/material/Checkbox';
2+
import Stack from '@mui/material/Stack';
23

34
import { TypeGraph } from '../../graph/type-graph';
45
import { VoyagerDisplayOptions } from '../Voyager';
56
import RootSelector from './RootSelector';
67

78
interface SettingsProps {
8-
typeGraph: TypeGraph;
9+
typeGraph: TypeGraph | null;
910
options: VoyagerDisplayOptions;
1011
onChange: (options: VoyagerDisplayOptions) => void;
1112
}
1213

1314
export default function Settings(props: SettingsProps) {
1415
const { typeGraph, options, onChange } = props;
16+
if (typeGraph == null) {
17+
return null;
18+
}
1519

1620
return (
17-
<div className="menu-content">
21+
<Stack
22+
sx={(theme) => ({
23+
position: 'absolute',
24+
opacity: 1,
25+
overflow: 'hidden',
26+
background: theme.palette.background.default,
27+
margin: 2,
28+
border: 1,
29+
borderColor: theme.palette.shadowColor.main,
30+
boxShadow: 2,
31+
padding: 1,
32+
// left-bottom corner
33+
left: 0,
34+
bottom: 0,
35+
})}
36+
>
1837
<RootSelector
1938
typeGraph={typeGraph}
2039
onChange={(rootType) => onChange({ rootType })}
2140
/>
22-
<div className="setting-other-options">
41+
<Stack direction="row" className="setting-other-options">
2342
<Checkbox
2443
id="sort"
2544
checked={!!options.sortByAlphabet}
@@ -50,7 +69,7 @@ export default function Settings(props: SettingsProps) {
5069
}
5170
/>
5271
<label htmlFor="showLeafFields">Show leaf fields</label>
53-
</div>
54-
</div>
72+
</Stack>
73+
</Stack>
5574
);
5675
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)