Skip to content

Commit 28e3812

Browse files
authored
Merge pull request #33 from M-DEV-1/M-DEV-1/add-instructions-modal
Add: Instructions Modal
2 parents f91221c + 23e4379 commit 28e3812

File tree

3 files changed

+90
-24
lines changed

3 files changed

+90
-24
lines changed

site/src/components/ShapeBuilder/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// /* global window */
22
import React, { useEffect, useRef, useState } from "react";
3-
import { Wrapper, Controls, CanvasContainer, OutputBox, StyledSVG } from "./shapeBuilder.styles";
4-
import { Button, Typography } from "@layer5/sistent";
3+
import { Wrapper, CanvasContainer, OutputBox, StyledSVG } from "./shapeBuilder.styles";
4+
import { Button, Typography, Box } from "@layer5/sistent";
55

66
// import { useTheme } from "@layer5/sistent/components/ThemeProvider";
77
// import { useMediaQuery } from "@layer5/sistent/components/MediaQuery";
@@ -182,10 +182,10 @@ const ShapeBuilder = () => {
182182
<rect className="grid" width="100%" height="100%" fill="url(#grid)" />
183183
</StyledSVG>
184184
{error && (
185-
<div style={{
186-
position: 'absolute',
187-
top: '50%',
188-
left: '50%',
185+
<div style={{
186+
position: 'absolute',
187+
top: '50%',
188+
left: '50%',
189189
transform: 'translate(-50%, -50%)',
190190
color: 'red',
191191
backgroundColor: 'white',
@@ -197,11 +197,11 @@ const ShapeBuilder = () => {
197197
)}
198198
</CanvasContainer>
199199

200-
<Controls>
200+
<Box sx={{ display: 'flex', justifyContent: 'center', gap: 2, mt: 3, mb: 3, flexWrap: 'wrap' }}>
201201
<Button variant="contained" onClick={clearShape}>Clear</Button>
202-
<Button variant="outlined" onClick={closeShape}>Close Shape</Button>
202+
<Button variant="contained" onClick={closeShape}>Close Shape</Button>
203203
<Button variant="contained" onClick={handleMaximize}>Maximize</Button>
204-
</Controls>
204+
</Box>
205205

206206
<OutputBox>
207207
<Typography variant="subtitle1" component="h6">
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from "react";
2+
import { Modal, ModalBody, Typography, List, ListItem, ListItemText, ModalFooter } from "@layer5/sistent";
3+
4+
const instructionPoints = [
5+
{
6+
primary: "Press CTRL + Enter to close the shape",
7+
secondary: "It won’t draw the last position of your cursor, don’t stress!"
8+
},
9+
{
10+
primary: "Hold CTRL to snap to grid",
11+
secondary: "Snap to Grid is default, CTRL allows you to freely draw with precision"
12+
},
13+
{
14+
primary: "CTRL + Z to undo",
15+
secondary: "Undo the last point you placed"
16+
},
17+
{
18+
primary: "Maximize for better visibility",
19+
secondary: "Without maximize, it may appear tiny"
20+
},
21+
];
22+
23+
const InstructionsModal = ({open, onClose}) => {
24+
25+
return (
26+
<Modal
27+
open={open}
28+
closeModal={onClose}
29+
title="ShapeBuilder Instructions"
30+
maxWidth="sm"
31+
>
32+
<ModalBody>
33+
<List>
34+
{instructionPoints.map(({ primary, secondary }, idx) => (
35+
<ListItem key={idx}>
36+
<ListItemText
37+
primary={<Typography fontWeight="bold" color="text.primary">{primary}</Typography>}
38+
secondary={<Typography variant="body2" color="text.secondary">{secondary}</Typography>}
39+
/>
40+
</ListItem>
41+
))}
42+
</List>
43+
</ModalBody>
44+
<ModalFooter variant="filled" helpText={"Refer to: https://docs.meshery.io/extensions/component-shape-guide"}>
45+
</ModalFooter>
46+
</Modal>
47+
);
48+
};
49+
50+
export default InstructionsModal;

site/src/pages/index.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import { ThemeProvider } from "styled-components";
33
import { GlobalStyle, Main, lightTheme, darkTheme } from "../styles/styles";
44
import { useDarkMode } from "../components/useDarkMode";
55
import Navigation from "../components/Navigation";
66
import Footer from "../components/Footer";
77
import ShapeBuilder from "../components/ShapeBuilder";
8+
import { Button, SistentThemeProviderWithoutBaseLine, Box } from "@layer5/sistent"
9+
import InstructionsModal from "../components/utils/instructionsModal";
810

911
const IndexPage = () => {
12+
// const themesistent = useTheme();
1013
const [theme, toggleTheme] = useDarkMode();
1114
const themeMode = theme === "light" ? lightTheme : darkTheme;
15+
const [open, setOpen] = useState(false);
1216

1317
return (
14-
<ThemeProvider theme={themeMode}>
15-
<GlobalStyle />
16-
<Navigation theme={theme} toggleTheme={toggleTheme} />
17-
<Main>
18-
<section className="hero">
19-
<h1>Shape Builder</h1>
20-
<p className="desc-text">
21-
Click on the grid to start creating a polygon. Each click adds a point.
22-
</p>
23-
</section>
24-
<ShapeBuilder />
25-
</Main>
26-
<Footer />
27-
</ThemeProvider>
18+
<SistentThemeProviderWithoutBaseLine>
19+
<ThemeProvider theme={themeMode}>
20+
<GlobalStyle />
21+
<Navigation theme={theme} toggleTheme={toggleTheme} />
22+
<Main>
23+
<section className="hero">
24+
<h1>Shape Builder</h1>
25+
<p className="desc-text">
26+
Click on the grid to start creating a polygon. Each click adds a point.
27+
</p>
28+
</section>
29+
<Box sx={{ display: "flex", justifyContent: "center", mt: 2 }}>
30+
<Button
31+
variant="contained"
32+
sx={{ minWidth: "fit-content" }}
33+
onClick={() => setOpen(true)}
34+
>
35+
Show Instructions
36+
</Button>
37+
</Box>
38+
<InstructionsModal open={open} onClose={() => setOpen(false)} />
39+
<ShapeBuilder />
40+
</Main>
41+
<Footer />
42+
</ThemeProvider>
43+
</SistentThemeProviderWithoutBaseLine>
2844
);
2945
};
3046

0 commit comments

Comments
 (0)