Skip to content

Commit 1ea77ab

Browse files
committed
feat: replace instruction modal with persistent keyboard shortcuts
Signed-off-by: PARTHIV PRATIM SAIKIA <parthivsaikia985@gmail.com>
1 parent 30e22db commit 1ea77ab

File tree

1 file changed

+78
-19
lines changed

1 file changed

+78
-19
lines changed

site/src/pages/index.js

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
1-
import React, { useState } from "react";
1+
import React from "react";
2+
import styled from "styled-components"; // Ensure you have styled imported
23
import { ThemeProvider } from "styled-components";
34
import { GlobalStyle, Main, lightTheme, darkTheme } from "../styles/styles";
45
import { useDarkMode } from "../components/useDarkMode";
56
import Navigation from "../components/Navigation";
67
import Footer from "../components/Footer";
78
import ShapeBuilder from "../components/ShapeBuilder";
8-
import { Button, SistentThemeProviderWithoutBaseLine, Box } from "@sistent/sistent";
9-
import InstructionsModal from "../components/utils/instructionsModal";
9+
import { SistentThemeProviderWithoutBaseLine, Box } from "@sistent/sistent";
10+
11+
const Kbd = styled.kbd`
12+
background-color: ${({ theme }) =>
13+
theme === lightTheme ? "#f4f4f4" : "#2b2b2b"};
14+
border: 1px solid
15+
${({ theme }) => (theme === lightTheme ? "#d1d5da" : "#444")};
16+
border-bottom-color: ${({ theme }) =>
17+
theme === lightTheme ? "#c6cbd1" : "#444"};
18+
border-radius: 3px;
19+
box-shadow: inset 0 -1px 0
20+
${({ theme }) => (theme === lightTheme ? "#c6cbd1" : "#444")};
21+
color: ${({ theme }) => (theme === lightTheme ? "#444" : "#e6e6e6")};
22+
display: inline-block;
23+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
24+
font-size: 11px;
25+
font-weight: 600;
26+
line-height: 1;
27+
padding: 3px 6px;
28+
margin-right: 6px;
29+
vertical-align: middle;
30+
`;
31+
32+
const InstructionsContainer = styled.div`
33+
display: flex;
34+
justify-content: center;
35+
align-items: center;
36+
flex-wrap: wrap;
37+
gap: 24px;
38+
margin-top: 16px;
39+
font-size: 0.9rem;
40+
color: ${({ theme }) => (theme === lightTheme ? "#666" : "#aaa")};
41+
42+
span {
43+
display: flex;
44+
align-items: center;
45+
}
46+
`;
1047

1148
const IndexPage = () => {
12-
// const themesistent = useTheme();
1349
const [theme, toggleTheme] = useDarkMode();
1450
const themeMode = theme === "light" ? lightTheme : darkTheme;
15-
const [open, setOpen] = useState(false);
1651

1752
return (
1853
<SistentThemeProviderWithoutBaseLine>
@@ -21,21 +56,45 @@ const IndexPage = () => {
2156
<Navigation theme={theme} toggleTheme={toggleTheme} />
2257
<Main>
2358
<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)}
59+
<Box
60+
sx={{
61+
display: "flex",
62+
flexDirection: "column", // Changed to column to stack title and text
63+
alignItems: "center",
64+
justifyContent: "center",
65+
gap: 2,
66+
mb: 4,
67+
}}
3468
>
35-
Show Instructions
36-
</Button>
37-
</Box>
38-
<InstructionsModal open={open} onClose={() => setOpen(false)} />
69+
<h1>Shape Builder</h1>
70+
71+
<p className="desc-text" style={{ margin: 0 }}>
72+
Click on the grid to start creating a polygon. Each click adds a
73+
point.
74+
</p>
75+
76+
<InstructionsContainer theme={themeMode}>
77+
<span>
78+
<Kbd theme={themeMode}>ENTER</Kbd>
79+
Close shape
80+
</span>
81+
82+
<span>
83+
<Kbd theme={themeMode}>CTRL</Kbd> Snap to grid
84+
</span>
85+
86+
<span>
87+
<Kbd theme={themeMode}>CTRL</Kbd> +{" "}
88+
<Kbd theme={themeMode}>Z</Kbd> Undo
89+
</span>
90+
91+
<span>
92+
<Kbd theme={themeMode}>Maximize</Kbd> Visibility
93+
</span>
94+
</InstructionsContainer>
95+
</Box>
96+
</section>
97+
3998
<ShapeBuilder />
4099
</Main>
41100
<Footer />

0 commit comments

Comments
 (0)