Skip to content

Commit 3ac9e43

Browse files
committed
feat: switched dropdown menu to a ToggleButton in ShapeForm for consistency
1 parent fa8d0bb commit 3ac9e43

3 files changed

Lines changed: 30 additions & 18 deletions

File tree

components/core/CreateShape.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ const CreateShape = (props) => {
5555
});
5656

5757
// Changes shapeInformation when something in ShapeForm or ShapePreview is altered
58-
function handleChange(event, data, number) {
58+
const handleChange = (event, data, number) => {
59+
60+
// console.log(event, data);
61+
5962
const name = event.target.name || event.type;
6063
const value = event.target.type === "checkbox" ? event.target.checked : event.target.value;
6164

62-
console.log(event, data);
63-
6465
// If Clip-Path formula value is changed, it makes sure that the parentheses stay there and also alters the verticeCoordinates value
6566
if (name === "name") {
6667
setShapeInformation({
@@ -191,7 +192,7 @@ const CreateShape = (props) => {
191192
// Called when there is a change in the textbox for formula in the form
192193
// Adjusts verticeCoordinates, vertices, and edges accordingly
193194
// Ensures that the parentheses remain
194-
function handleFormulaChange(formula, edgeVerticeNumber, clipPathType) {
195+
const handleFormulaChange = (formula, edgeVerticeNumber, clipPathType) => {
195196
let newVerticeCoordinates = [];
196197

197198
if (clipPathType === "polygon") {
@@ -219,7 +220,7 @@ const CreateShape = (props) => {
219220
}
220221

221222
// Returns an array that has a new verticeCoordinate
222-
function addNewVerticeCoordinates(x ,y, number) {
223+
const addNewVerticeCoordinates = (x ,y, number) => {
223224
const xPercentage = Math.round((x / 280.0) * 100.0);
224225
const yPercentage = Math.round((y / 280.0) * 100.0);
225226

@@ -233,7 +234,7 @@ const CreateShape = (props) => {
233234
}
234235

235236
// Returns a generated formula string from a verticeCoordinate array
236-
function generateNewFormula(newVerticeCoordinates) {
237+
const generateNewFormula = (newVerticeCoordinates) => {
237238

238239
let newFormula = shapeInformation.clipPathType + "(";
239240

components/utils/DraggableVertice.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ const DraggableVertice = (props) => {
3030
const show = props.focusNumber === props.number;
3131
const target = useRef(null);
3232

33-
function handleDrag(e, data) {
33+
const handleDrag = (e, data) => {
3434
props.handleChange(e, data, props.number);
3535
}
3636

37-
function handleDelete(e) {
37+
const handleDelete = (e) => {
3838
props.handleChange(e, null, props.number);
3939
props.setFocusNumber(-1);
4040
}

components/utils/ShapeForm.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import styled from "styled-components";
55

66
// Bootstrap
77
import Form from "react-bootstrap/Form";
8+
import ToggleButton from "react-bootstrap/ToggleButton";
9+
import ToggleButtonGroup from "react-bootstrap/ToggleButtonGroup";
810

911
const ColorPicker = styled.input`
1012
border-color: lightgray;
@@ -30,20 +32,29 @@ const ShapeForm = (props) => {
3032

3133
<Form.Group>
3234
<Form.Label>Type</Form.Label>
33-
<Form.Control
34-
as="select"
35-
name="clipPathType"
36-
value={props.shapeInformation.clipPathType}
37-
onChange={props.handleChange}
38-
>
39-
<option value="polygon">Polygon</option>
40-
<option value="circle">Circle</option>
41-
<option value="ellipse">Ellipse</option>
42-
</Form.Control>
35+
<div>
36+
<ToggleButtonGroup
37+
type="radio"
38+
name="clipPathType"
39+
value={props.shapeInformation.clipPathType}
40+
size="sm"
41+
>
42+
<ToggleButton value="polygon" variant="outline-dark" onChange={props.handleChange}>
43+
Polygon
44+
</ToggleButton>
45+
<ToggleButton value="circle" variant="outline-dark" onChange={props.handleChange}>
46+
Circle
47+
</ToggleButton>
48+
<ToggleButton value="ellipse" variant="outline-dark" onChange={props.handleChange}>
49+
Ellipse
50+
</ToggleButton>
51+
</ToggleButtonGroup>
52+
</div>
4353
</Form.Group>
4454

4555
<Form.Group>
4656
<Form.Label>Color picker</Form.Label>
57+
<br />
4758
<ColorPicker
4859
type="color"
4960
name="backgroundColor"

0 commit comments

Comments
 (0)