Skip to content

Commit 3bb3586

Browse files
authored
Merge branch 'main' into forman-no_local_ui_state
2 parents b75c3d8 + e558ea4 commit 3bb3586

File tree

11 files changed

+83
-35
lines changed

11 files changed

+83
-35
lines changed

dashi/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashi/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dependencies": {
1515
"@emotion/react": "^11.13.3",
1616
"@emotion/styled": "^11.13.0",
17+
"@fontsource/roboto": "^5.1.0",
1718
"@mui/material": "^6.1.1",
1819
"immer": "^10.1.1",
1920
"plotly.js": "^2.35.2",

dashi/src/app/App.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1+
import {
2+
CssBaseline,
3+
ThemeProvider,
4+
createTheme,
5+
Typography,
6+
} from "@mui/material";
7+
18
import ExtensionsInfo from "./ExtensionInfo";
29
import PanelsControl from "./PanelsControl";
310
import PanelsRow from "./PanelsRow";
411
import { initAppStore } from "../actions/initAppStore";
512

613
initAppStore();
714

15+
// MUI's default font family
16+
const fontFamily = "Roboto, Arial, sans-serif";
17+
18+
const theme = createTheme({
19+
typography: { fontFamily },
20+
components: {
21+
MuiCssBaseline: {
22+
styleOverrides: {
23+
"*": { fontFamily },
24+
},
25+
},
26+
},
27+
});
28+
829
function App() {
930
return (
10-
<>
11-
<div style={{ fontSize: 48, paddingBottom: 10 }}>Dashi Demo</div>
31+
<ThemeProvider theme={theme}>
32+
<CssBaseline />
33+
<Typography fontSize="3em" fontWeight="bold">
34+
Dashi Demo
35+
</Typography>
1236
<ExtensionsInfo />
1337
<PanelsControl />
1438
<PanelsRow />
15-
</>
39+
</ThemeProvider>
1640
);
1741
}
1842

dashi/src/app/ExtensionInfo.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import useAppStore from "../store/appStore";
2+
import { Typography } from "@mui/material";
23

34
function ExtensionsInfo() {
45
const appState = useAppStore();
@@ -9,10 +10,11 @@ function ExtensionsInfo() {
910
{extensionsResult.data.map((extension, extIndex) => {
1011
const id = `extensions.${extIndex}`;
1112
return (
12-
<span
13+
<Typography
1314
key={id}
14-
style={{ padding: 5 }}
15-
>{`${extension.name}/${extension.version}`}</span>
15+
style={{ padding: 4 }}
16+
fontSize="small"
17+
>{`${extension.name}/${extension.version}`}</Typography>
1618
);
1719
})}
1820
</div>

dashi/src/app/Panel.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {CSSProperties, ReactElement} from "react";
1+
import { CSSProperties, ReactElement } from "react";
22

33
import { Contribution } from "../model/contribution";
44
import { PropertyChangeHandler } from "../model/component";
55
import DashiComponent from "../components/DashiComponent";
66
import { ContributionState } from "../store/appStore";
7-
import {CircularProgress} from "@mui/material";
7+
import { CircularProgress } from "@mui/material";
88

99
const panelContainerStyle: CSSProperties = {
1010
display: "flex",
1111
flexDirection: "column",
1212
width: 400,
13-
height: 300,
13+
height: 400,
1414
padding: 5,
1515
border: "1px gray solid",
1616
};
@@ -41,7 +41,12 @@ function Panel({ panelModel, panelState, onPropertyChange }: PanelProps) {
4141
</span>
4242
);
4343
} else if (componentModelResult.status === "pending") {
44-
panelElement = <span><CircularProgress size={30} color="secondary" /> Loading {panelModel.name}...</span>;
44+
panelElement = (
45+
<span>
46+
<CircularProgress size={30} color="secondary" /> Loading{" "}
47+
{panelModel.name}...
48+
</span>
49+
);
4550
}
4651
return <div style={panelContainerStyle}>{panelElement}</div>;
4752
}

dashi/src/app/PanelsControl.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import useAppStore, { ContribPoint } from "../store/appStore";
22
import { hidePanel } from "../actions/hidePanel";
33
import { showPanel } from "../actions/showPanel";
4-
import {Checkbox} from "@mui/material";
4+
import { Checkbox, FormControlLabel, FormGroup } from "@mui/material";
55

66
const contribPoint: ContribPoint = "panels";
77

@@ -23,29 +23,32 @@ function PanelsControl() {
2323
throw Error("internal state error");
2424
}
2525
return (
26-
<div style={{ padding: 5 }}>
26+
<FormGroup>
2727
{panelStates.map((panelState, panelIndex) => {
2828
const id = `panels.${panelIndex}`;
2929
return (
30-
<div key={id}>
31-
<Checkbox
32-
color="secondary"
33-
id={id}
34-
checked={panelState.visible || false}
35-
value={panelIndex}
36-
onChange={(e) => {
37-
if (e.currentTarget.checked) {
38-
showPanel(panelIndex);
39-
} else {
40-
hidePanel(panelIndex);
41-
}
42-
}}
43-
/>
44-
<label htmlFor={id}>{panelModels[panelIndex].name}</label>
45-
</div>
30+
<FormControlLabel
31+
key={panelIndex}
32+
label={panelModels[panelIndex].name}
33+
control={
34+
<Checkbox
35+
color="secondary"
36+
id={id}
37+
checked={panelState.visible || false}
38+
value={panelIndex}
39+
onChange={(e) => {
40+
if (e.currentTarget.checked) {
41+
showPanel(panelIndex);
42+
} else {
43+
hidePanel(panelIndex);
44+
}
45+
}}
46+
/>
47+
}
48+
/>
4649
);
4750
})}
48-
</div>
51+
</FormGroup>
4952
);
5053
}
5154

dashi/src/components/DashiDropdown.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ function DashiDropdown({
4040
});
4141
};
4242
return (
43-
<FormControl>
44-
{label && <InputLabel>{label}</InputLabel>}
43+
<FormControl variant="filled" size="small" style={style}>
44+
{label && <InputLabel id={`${id}-label`}>{label}</InputLabel>}
4545
<Select
46+
labelId={`${id}-label`}
4647
id={id}
4748
name={name}
48-
style={style}
4949
value={`${value}`}
5050
disabled={disabled}
5151
onChange={handleChange}
52-
variant={"filled"}
5352
>
5453
{options.map(([text, value], index) => (
5554
<MenuItem key={index} value={value}>

dashi/src/main.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import React from "react";
22
import ReactDOM from "react-dom/client";
33
import App from "./app/App";
44

5+
import "@fontsource/roboto/300.css";
6+
import "@fontsource/roboto/400.css";
7+
import "@fontsource/roboto/500.css";
8+
import "@fontsource/roboto/700.css";
59
import "./index.css";
610

711
ReactDOM.createRoot(document.getElementById("root")!).render(

dashipy/dashipy/components/dropdown.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
@dataclass(frozen=True)
77
class Dropdown(Component):
8+
label: str | None = None
89
options: list[tuple[str, str | int | float]] = field(default_factory=list)

dashipy/my_extension/my_panel_1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def render_panel(ctx: Context) -> Component:
1919
dropdown = Dropdown(
2020
id="selected_dataset",
2121
value=selected_dataset,
22+
label="Dataset",
2223
options=[(f"DS #{i + 1}", i) for i in range(len(ctx.datasets))],
23-
style={"flexGrow": 0},
24+
style={"flexGrow": 0, "minWidth": 120},
2425
)
2526
control_group = Box(
2627
style={

0 commit comments

Comments
 (0)