Skip to content

Commit

Permalink
Inline CSS for Settings component (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Oct 19, 2024
1 parent f63c5a4 commit 9b83aeb
Show file tree
Hide file tree
Showing 28 changed files with 60 additions and 71 deletions.
18 changes: 2 additions & 16 deletions src/components/GraphViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,7 @@ export default class GraphViewport extends Component<
const isLoading = this.state.svgViewport == null;
const { svgViewport } = this.state;
return (
<Box
sx={(theme) => ({
flex: 1,
position: 'relative',
display: 'inline-block',
width: '100%',
height: '100%',
maxHeight: '100%',

[theme.breakpoints.down('md')]: {
height: '50%',
maxWidth: 'none',
},
})}
>
<>
<Box
role="img"
aria-label="Visual representation of the GraphQL schema"
Expand Down Expand Up @@ -189,7 +175,7 @@ export default class GraphViewport extends Component<
</Stack>
)}
{isLoading && <LoadingAnimation />}
</Box>
</>
);
}

Expand Down
27 changes: 0 additions & 27 deletions src/components/Voyager.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,4 @@
max-width: none;
}
}

& > .menu-content {
position: absolute;
z-index: 5;
bottom: var(--panel-spacing);
left: calc(var(--doc-panel-width) + var(--panel-spacing));
background: var(--doc-panel-bg-color);
box-shadow: 0 4px 4px -2px var(--shadow-color);
border: 1px solid var(--shadow-color);
padding: var(--spacing-unit);

& > .setting-other-options {
display: flex;

& > label:first-of-type {
padding-right: var(--spacing-unit);
}

& > label {
margin-bottom: calc(var(--panel-spacing) - var(--spacing-unit));
}
}

@media (--small-viewport) {
left: 10px;
}
}
}
57 changes: 34 additions & 23 deletions src/components/Voyager.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './Voyager.css';
import './viewport.css';

import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
import { ThemeProvider } from '@mui/material/styles';
Expand Down Expand Up @@ -127,7 +128,6 @@ export default function Voyager(props: VoyagerProps) {
<ThemeProvider theme={theme}>
<div className="graphql-voyager">
{!hideDocs && renderPanel()}
{!hideSettings && renderSettings()}
{renderGraphViewport()}
{allowToChangeSchema && renderIntrospectionModal()}
</div>
Expand Down Expand Up @@ -190,30 +190,41 @@ export default function Voyager(props: VoyagerProps) {
);
}

function renderSettings() {
if (typeGraph == null) return null;

return (
<Settings
options={displayOptions}
typeGraph={typeGraph}
onChange={(options) =>
setDisplayOptions((oldOptions) => ({ ...oldOptions, ...options }))
}
/>
);
}

function renderGraphViewport() {
return (
<GraphViewport
typeGraph={typeGraph}
selectedTypeID={selected.typeID}
selectedEdgeID={selected.edgeID}
onSelectNode={handleSelectNode}
onSelectEdge={handleSelectEdge}
ref={viewportRef}
/>
<Box
sx={(theme) => ({
flex: 1,
position: 'relative',
display: 'inline-block',
width: '100%',
height: '100%',
maxHeight: '100%',

[theme.breakpoints.down('md')]: {
height: '50%',
maxWidth: 'none',
},
})}
>
{!hideSettings && (
<Settings
options={displayOptions}
typeGraph={typeGraph}
onChange={(options) =>
setDisplayOptions((oldOptions) => ({ ...oldOptions, ...options }))
}
/>
)}
<GraphViewport
typeGraph={typeGraph}
selectedTypeID={selected.typeID}
selectedEdgeID={selected.edgeID}
onSelectNode={handleSelectNode}
onSelectEdge={handleSelectEdge}
ref={viewportRef}
/>
</Box>
);
}

Expand Down
29 changes: 24 additions & 5 deletions src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
import Checkbox from '@mui/material/Checkbox';
import Stack from '@mui/material/Stack';

import { TypeGraph } from '../../graph/type-graph';
import { VoyagerDisplayOptions } from '../Voyager';
import RootSelector from './RootSelector';

interface SettingsProps {
typeGraph: TypeGraph;
typeGraph: TypeGraph | null;
options: VoyagerDisplayOptions;
onChange: (options: VoyagerDisplayOptions) => void;
}

export default function Settings(props: SettingsProps) {
const { typeGraph, options, onChange } = props;
if (typeGraph == null) {
return null;
}

return (
<div className="menu-content">
<Stack
sx={(theme) => ({
position: 'absolute',
opacity: 1,
overflow: 'hidden',
background: theme.palette.background.default,
margin: 2,
border: 1,
borderColor: theme.palette.shadowColor.main,
boxShadow: 2,
padding: 1,
// left-bottom corner
left: 0,
bottom: 0,
})}
>
<RootSelector
typeGraph={typeGraph}
onChange={(rootType) => onChange({ rootType })}
/>
<div className="setting-other-options">
<Stack direction="row" className="setting-other-options">
<Checkbox
id="sort"
checked={!!options.sortByAlphabet}
Expand Down Expand Up @@ -50,7 +69,7 @@ export default function Settings(props: SettingsProps) {
}
/>
<label htmlFor="showLeafFields">Show leaf fields</label>
</div>
</div>
</Stack>
</Stack>
);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/choose-yelp-preset-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/demo-after-resize-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/demo-before-resize-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/display-introspection-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/display-schema-from-url-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/display-sdl-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/fill-introspection-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/fill-sdl-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/loaded-demo-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/open-dialog-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/show-github-preset-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/show-star-wars-preset-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/show-yelp-preset-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/demo.spec.ts-snapshots/switch-to-sdl-tab-Demo-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9b83aeb

Please sign in to comment.