Skip to content

Commit fe9a12b

Browse files
committed
laying framework
0 parents  commit fe9a12b

5 files changed

Lines changed: 144 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React, {Component} from 'react';
2+
import {Strategy, changeRed} from '../Strategy/Strategy';
3+
import {BuildTrigger} from '../../modals/buttons/buildbutton/BuildTrigger';
4+
import {BuildForm} from '../../modals/form/BuildForm';
5+
import ModalTriggerButton from '../../modals/buttons/modaltrigger/ModalTriggerButton';
6+
7+
8+
9+
export class Container extends Component {
10+
state = {isShown: false};
11+
12+
showModal = () => {
13+
this.setState({isShown: true}, () => {
14+
this.closeModal = this.closeModal.bind(this);
15+
this.closeButton.focus();
16+
});
17+
this.toggleScrollLock();
18+
};
19+
20+
onCloseModal = () => {
21+
this.setState({isShown: false});
22+
this.toggleScrollLock();
23+
24+
}
25+
26+
onClickOutside = (e) => {
27+
if (this.modalRef && !this.modalRef.contains(e.target)) {
28+
this.onCloseModal();
29+
}
30+
}
31+
32+
onKeyDown = (e) => {
33+
if (e.key === 'Escape') {
34+
this.onCloseModal();
35+
}
36+
37+
else {
38+
switch (e.key) {
39+
case 'Enter': {
40+
41+
break;
42+
}
43+
case 'ArrowUp': {
44+
45+
break;
46+
}
47+
case 'ArrowDown': {
48+
49+
break;
50+
}
51+
default:
52+
break;
53+
}
54+
}
55+
}
56+
57+
toggleScrollLock = () => {
58+
document.querySelector('html').classList.toggle('scroll-lock');
59+
}
60+
61+
62+
render() {
63+
return (
64+
<React.Fragment>
65+
<BuildTrigger triggerID = "bar" buttonRef = {this.buttonRef} showModal = {this.showModal} onSubmit = {this.onSubmit}/>
66+
{this.state.isShown ? (
67+
<BuildForm
68+
onSubmit = {this.onSubmit}
69+
onCloseModal = {this.onCloseModal}
70+
onClickOutside = {this.onClickOutside}
71+
onKeyDown = {this.onKeyDown}
72+
/>
73+
) : null}
74+
</React.Fragment>
75+
)
76+
}
77+
}
78+
79+
80+
81+
export default Container;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
4+
5+
export const BuildTrigger = ({triggerID, buttonRef, showModal, onSubmit}) => {
6+
return (
7+
<button
8+
className = {'btn btn-lg btn-danger right modal-button'}
9+
type = {"button"}
10+
ref = {buttonRef}
11+
onClick = {showModal}
12+
>
13+
Build
14+
</button>
15+
);
16+
};
17+
18+
export default BuildTrigger;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
export const ModalTriggerButton = ({triggerID, buttonRef, showModal, onSubmit}) => {
4+
return (
5+
<button
6+
className = {'btn btn-lg btn-danger right modal-button'}
7+
type = {"button"}
8+
ref = {buttonRef}
9+
onClick = {showModal}
10+
>
11+
Build
12+
</button>
13+
);
14+
}
15+
16+
export default ModalTriggerButton;

‎src/modals/cube/cube.gltf‎

Whitespace-only changes.

‎src/modals/form/BuildForm.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
3+
4+
5+
export const BuildForm = ({onSubmit}) => {
6+
return (
7+
<form onSubmit = {onSubmit}>
8+
<div className = "flex flex-col">
9+
<div className = "form-group">
10+
<label htmlFor = "name">Name</label>
11+
<input type = "text" className = "form-control" id = "name" placeholder = "Enter name"/>
12+
</div>
13+
<div className = "form-group">
14+
<label htmlFor = "dataType">Data Type</label>
15+
<select className = "form-control" id = "dataType">
16+
<option>String</option>
17+
<option>Number</option>
18+
<option>Boolean</option>
19+
</select>
20+
</div>
21+
<div className = "form-group">
22+
<button className = {'form-control btn btn-primary'} type = {"submit"}>Build</button>
23+
</div>
24+
</div>
25+
</form>
26+
);
27+
}
28+
29+
export default BuildForm;

0 commit comments

Comments
 (0)