|
| 1 | +import React from "react"; |
| 2 | +import myrReference from "../../myr/textureReference"; |
| 3 | + |
| 4 | +import * as layoutTypes from "../../constants/LayoutTypes"; |
| 5 | + |
| 6 | +import { |
| 7 | + Tabs, |
| 8 | + Tab, |
| 9 | + IconButton, |
| 10 | + Drawer, |
| 11 | + Icon, |
| 12 | + Table, |
| 13 | + TableBody, |
| 14 | + TableHead, |
| 15 | + TableRow, |
| 16 | + TableCell, |
| 17 | + Tooltip, |
| 18 | + Hidden |
| 19 | +} from "@material-ui/core"; |
| 20 | + |
| 21 | +const exitBtnStyle = { |
| 22 | + //paddingbottom: 100, |
| 23 | + position: "fixed", |
| 24 | + top: 0, |
| 25 | + right: 10, |
| 26 | +}; |
| 27 | +const newTabStyle = { |
| 28 | + position: "fixed", |
| 29 | + top: 0, |
| 30 | + right: 50, |
| 31 | +}; |
| 32 | +export default class TextureReference extends React.Component { |
| 33 | + |
| 34 | + constructor(props) { |
| 35 | + super(props); |
| 36 | + this.state = { |
| 37 | + value: "a", |
| 38 | + }; |
| 39 | + this.tableData = myrReference(); |
| 40 | + } |
| 41 | + |
| 42 | + handleChange = (event, value) => { |
| 43 | + this.setState({ value }); |
| 44 | + }; |
| 45 | + |
| 46 | + TableEx = (category) => { |
| 47 | + |
| 48 | + return ( |
| 49 | + <Table > |
| 50 | + <TableHead > |
| 51 | + <TableRow> |
| 52 | + <TableCell>Name</TableCell> |
| 53 | + <TableCell>Description</TableCell> |
| 54 | + <TableCell className='refExample'>Example</TableCell> |
| 55 | + </TableRow> |
| 56 | + </TableHead> |
| 57 | + <TableBody > |
| 58 | + {this.tableData[category].map((row, index) => ( |
| 59 | + <TableRow key={index}> |
| 60 | + <TableCell >{row.name}</TableCell> |
| 61 | + <TableCell >{row.description}</TableCell> |
| 62 | + <TableCell >{this.exampleHelper(row.example)}</TableCell> |
| 63 | + </TableRow> |
| 64 | + ))} |
| 65 | + </TableBody> |
| 66 | + </Table> |
| 67 | + ); |
| 68 | + }; |
| 69 | + |
| 70 | + render() { |
| 71 | + const style = { |
| 72 | + margin: 2, |
| 73 | + padding: 0, |
| 74 | + color: "#fff", |
| 75 | + }; |
| 76 | + const isDisabled = this.props.layoutType === layoutTypes.REFERENCE; |
| 77 | + return ( |
| 78 | + <div> |
| 79 | + {!isDisabled ? |
| 80 | + <React.Fragment> |
| 81 | + <Tooltip title="Reference" placement="bottom-start"> |
| 82 | + <IconButton |
| 83 | + id="ref-btn" |
| 84 | + className="header-btn d-none d-md-block" |
| 85 | + aria-haspopup="true" |
| 86 | + onClick={this.props.handleReferenceToggle} |
| 87 | + style={style}> |
| 88 | + <Icon style={{ color: "#fff" }} className="material-icons">help</Icon> |
| 89 | + </IconButton> |
| 90 | + </Tooltip> |
| 91 | + <Drawer |
| 92 | + style={{ position: "relative", zIndex: 100 }} |
| 93 | + anchor="right" |
| 94 | + id="reference-drawer" |
| 95 | + variant="persistent" |
| 96 | + className={!this.props.referenceOpen ? "d-none" : ""} |
| 97 | + open={this.props.referenceOpen}> |
| 98 | + |
| 99 | + <div> |
| 100 | + <h3 className="border-bottom" style={{ padding: 10, fontWeight: 400 }}>MYR API - Reference</h3> |
| 101 | + <IconButton |
| 102 | + color="default" |
| 103 | + style={exitBtnStyle} |
| 104 | + onClick={() => { |
| 105 | + this.props.handleReferenceToggle(); |
| 106 | + this.setState({ value: "a" }); |
| 107 | + }}> |
| 108 | + <Icon className="material-icons">close</Icon> |
| 109 | + </IconButton> |
| 110 | + <IconButton |
| 111 | + color="default" |
| 112 | + style={newTabStyle} |
| 113 | + onClick={this.handleOpen}> |
| 114 | + <Icon className="material-icons">open_in_new</Icon> |
| 115 | + </IconButton> |
| 116 | + </div> |
| 117 | + |
| 118 | + <div> |
| 119 | + <Tabs |
| 120 | + id="textureReference-tabs" |
| 121 | + fullWidth={true} |
| 122 | + value={this.state.value} |
| 123 | + onChange={this.handleChange} |
| 124 | + variant="scrollable"> |
| 125 | + <Tab |
| 126 | + icon={<Icon className="material-icons geometry">category</Icon>} |
| 127 | + label={ |
| 128 | + <Hidden xsDown> |
| 129 | + <div>GEOMETRY</div> |
| 130 | + </Hidden> |
| 131 | + } |
| 132 | + value='a' /> |
| 133 | + <Tab |
| 134 | + icon={<Icon className="material-icons color-change">bubble_chart</Icon>} |
| 135 | + label={ |
| 136 | + <Hidden xsDown> |
| 137 | + <div>TRANSFORMATIONS</div> |
| 138 | + </Hidden> |
| 139 | + } |
| 140 | + value='b' /> |
| 141 | + <Tab |
| 142 | + icon={<Icon className="material-icons animation-ref">zoom_out_map</Icon>} //swap_horiz control_camera category |
| 143 | + label={ |
| 144 | + <Hidden xsDown> |
| 145 | + <div>ANIMATIONS</div> |
| 146 | + </Hidden> |
| 147 | + } |
| 148 | + value='c' /> |
| 149 | + <Tab |
| 150 | + icon={<Icon className="material-icons geometry">widgets</Icon>} |
| 151 | + label={ |
| 152 | + <Hidden xsDown> |
| 153 | + <div>GROUPS</div> |
| 154 | + </Hidden> |
| 155 | + } |
| 156 | + value='d' /> |
| 157 | + {/*<Tab |
| 158 | + style={{ background: "green", color: "white" }} |
| 159 | + icon={<Icon className="material-icons">open_in_new</Icon>} |
| 160 | + label="OPEN IN NEW TAB" |
| 161 | + value='n' |
| 162 | + onClick={this.handleOpen} /> |
| 163 | + <Tab |
| 164 | + style={{ background: "red", color: "white" }} |
| 165 | + icon={<Icon className="material-icons">close</Icon>} |
| 166 | + label="CLOSE" |
| 167 | + value='x' |
| 168 | + onClick={() => { |
| 169 | + this.props.handleReferenceToggle(); |
| 170 | + this.setState({ value: "a" }); |
| 171 | + }} />*/} |
| 172 | + </Tabs> |
| 173 | + </div> |
| 174 | + |
| 175 | + {<div style={{ margin: 7, overflow: "hidden" }}> |
| 176 | + <p style={{ fontSize: "80%" }}> Key: <span className="array">array </span> |
| 177 | + <span className="bool">bool </span> |
| 178 | + <span className="number">number </span> |
| 179 | + <span className="string">string </span> |
| 180 | + <span className="group">group </span> |
| 181 | + <span className="data">data</span></p> |
| 182 | + </div>} |
| 183 | + {this.state.value === "a" && |
| 184 | + <div style={{ marginTop: 0, overflow: "scroll" }}> |
| 185 | + {this.TableEx("geometry")} |
| 186 | + </div>} |
| 187 | + {this.state.value === "b" && |
| 188 | + <div style={{ marginTop: 0, overflow: "scroll" }}> |
| 189 | + {this.TableEx("transformations")} |
| 190 | + </div>} |
| 191 | + {this.state.value === "c" && |
| 192 | + <div style={{ marginTop: 0, overflow: "scroll" }}> |
| 193 | + {this.TableEx("animations")} |
| 194 | + </div>} |
| 195 | + {this.state.value === "d" && |
| 196 | + <div style={{ marginTop: 0, overflow: "scroll" }}> |
| 197 | + {this.TableEx("groups")} |
| 198 | + </div>} |
| 199 | + </Drawer> |
| 200 | + </React.Fragment> : null} |
| 201 | + </div> |
| 202 | + ); |
| 203 | + } |
| 204 | +} |
0 commit comments