5.4. Create RampBox
Now the dashboard itself. Start with a box for one ramp. Of course we need styles too, and they're already waiting in Ramp.scss:
src/components/RampBox.tsx
import { Card, Elevation } from "@blueprintjs/core";
import { observer } from "mobx-react-lite";
import "./Ramp.scss";
export const RampBox = observer(() => {
return <Card className="Ramp" elevation={Elevation.ONE}>
<header>Title</header>
<main>
Value
</main>
</Card>;
});
And use this box in Content, in place of "Ramps":
src/components/Content.tsx
import { RampBox } from "./RampBox";
// ...
return <div className="Content">
<RampBox/>
</div>;
You get one striped box. Now let's use the ramps we have in the store. RampBox gets a ramp and shows its description:
src/components/RampBox.tsx
import { Card, Elevation } from "@blueprintjs/core";
import { observer } from "mobx-react-lite";
import { Ramp } from "../store/Ramp";
import "./Ramp.scss";
export const RampBox = observer(({ ramp }: { ramp: Ramp }) => {
return <Card className="Ramp" elevation={Elevation.ONE}>
<header>{ramp.description}</header>
<main>
Value
</main>
</Card>;
});
And Content passes every ramp from the store:
src/components/Content.tsx
export const Content = observer(() => {
const { ui, ramps } = store;
if (ui.isLoadingsOpen) {
return <LoadingsTable/>;
}
return <div className="Content">
{ramps.map(ramp => <RampBox key={ramp.id} ramp={ramp} />)}
</div>;
});
Now the dashboard has seven boxes, A to G.
