Skip to content

Commit 92e9f64

Browse files
committed
feat: CreateShape now implemented with button
1 parent 05f9f3e commit 92e9f64

3 files changed

Lines changed: 44 additions & 26 deletions

File tree

components/core/CreateShape.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React, { useState } from "react";
22
import Container from "react-bootstrap/Container";
33
import Row from "react-bootstrap/Row";
44
import Col from "react-bootstrap/Col";
5+
import Modal from "react-bootstrap/Modal";
6+
import Button from "react-bootstrap/Button";
57

6-
import { Header, ShapeForm, ShapePreview } from "..";
8+
import { ShapeForm, ShapePreview } from "..";
79

810
const CreateShape = (props) => {
911
const [shapeInformation, setShapeInformation] = useState({
@@ -227,17 +229,34 @@ const CreateShape = (props) => {
227229

228230
return(
229231
<>
230-
<Header {...props} />
231-
<Container fluid>
232-
<Row lg={2} md={1} sm={1} xs={1}>
233-
<Col>
234-
<ShapePreview shapeInformation={shapeInformation} handleChange={handlePreviewChange} />
235-
</Col>
236-
<Col>
237-
<ShapeForm shapeInformation={shapeInformation} handleChange={handleFormChange} handleSubmit={handleSubmit} validated={validated} />
238-
</Col>
239-
</Row>
240-
</Container>
232+
<Modal
233+
show={props.show}
234+
centered
235+
size="xl"
236+
onHide={props.handleClose}
237+
backdrop="static"
238+
>
239+
<Modal.Header>
240+
<Modal.Title>Create Shape</Modal.Title>
241+
</Modal.Header>
242+
<Modal.Body>
243+
<Container fluid>
244+
<Row lg={2} md={1} sm={1} xs={1}>
245+
<Col>
246+
<ShapeForm shapeInformation={shapeInformation} handleChange={handleFormChange} handleSubmit={handleSubmit} validated={validated} />
247+
</Col>
248+
<Col>
249+
<ShapePreview shapeInformation={shapeInformation} handleChange={handlePreviewChange} />
250+
</Col>
251+
</Row>
252+
</Container>
253+
</Modal.Body>
254+
<Modal.Footer>
255+
<Button onClick={() => props.handleClose()}>
256+
Close
257+
</Button>
258+
</Modal.Footer>
259+
</Modal>
241260
</>
242261
);
243262
}

components/utils/Header.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import { FiSearch, FiPlus } from "react-icons/fi";
2525
// Styled Component
2626
import styled from "styled-components";
2727

28+
// CreateShape Component
29+
import { CreateShape } from "..";
30+
2831
const AppHeader = styled.div`
2932
position: fixed;
3033
z-index: 1;
@@ -127,6 +130,14 @@ const LoginBar = styled.div`
127130

128131

129132
const Header = ({ setOpen, user, setUser }) => {
133+
134+
// Controls when CreateShape Modal Shows
135+
const [showCreateShape, setShowCreateShape] = useState(false);
136+
137+
const closeModal = () => {
138+
setShowCreateShape(false);
139+
}
140+
130141
// console.log(user);
131142
// sign out function
132143
const signOut = () => {
@@ -168,7 +179,7 @@ const Header = ({ setOpen, user, setUser }) => {
168179
{(user.email || user.displayName) ? (
169180
<>
170181
<LoginBar>
171-
<Button variant="primary" size="sm" className="mr-3">
182+
<Button variant="primary" size="sm" className="mr-3" onClick={() => setShowCreateShape(true)}>
172183
<FiPlus />
173184
Add Shape
174185
</Button>
@@ -194,6 +205,7 @@ const Header = ({ setOpen, user, setUser }) => {
194205
<div>Sign In</div>
195206
</Button>
196207
)}
208+
<CreateShape show={showCreateShape} handleClose={closeModal} />
197209
</AppHeader>
198210
);
199211
};

pages/new.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)