diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Card.js | 56 | ||||
| -rw-r--r-- | src/components/style.css | 47 |
2 files changed, 103 insertions, 0 deletions
diff --git a/src/components/Card.js b/src/components/Card.js new file mode 100644 index 0000000..c555a25 --- /dev/null +++ b/src/components/Card.js | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | import React from 'react'; | ||
| 2 | import QRCode from 'qrcode.react'; | ||
| 3 | import './style.css'; | ||
| 4 | |||
| 5 | class Card extends React.Component { | ||
| 6 | constructor(props) { | ||
| 7 | super(props); | ||
| 8 | this.state = {ssid: '', password: '', qrvalue: ''}; | ||
| 9 | this.handleSSIDChange = this.handleSSIDChange.bind(this); | ||
| 10 | this.handlePasswordChange= this.handlePasswordChange.bind(this); | ||
| 11 | } | ||
| 12 | |||
| 13 | handleSSIDChange(event) { | ||
| 14 | this.setState({ssid: event.target.value}, () => this.generateqr()); | ||
| 15 | } | ||
| 16 | |||
| 17 | handlePasswordChange(event) { | ||
| 18 | this.setState({password: event.target.value}, () => this.generateqr()); | ||
| 19 | } | ||
| 20 | |||
| 21 | generateqr() { | ||
| 22 | const qrcode = `WIFI:T:WPA;S:${this.state.ssid};P:${this.state.password};;` | ||
| 23 | this.setState({qrvalue: qrcode}); | ||
| 24 | } | ||
| 25 | |||
| 26 | render() { | ||
| 27 | return ( | ||
| 28 | <div> | ||
| 29 | <fieldset id="print-area"> | ||
| 30 | <legend></legend> | ||
| 31 | |||
| 32 | <h1>WiFi Login</h1> | ||
| 33 | <hr/> | ||
| 34 | |||
| 35 | <div className="details"> | ||
| 36 | <QRCode className="qrcode" value={this.state.qrvalue} size={175} /> | ||
| 37 | |||
| 38 | <div className="text"> | ||
| 39 | <label>Network name</label> | ||
| 40 | <input id="ssid" type="text" placeholder="Enter your WiFi Network" value={this.state.ssid} onChange={this.handleSSIDChange}/> | ||
| 41 | <label>Password</label> | ||
| 42 | <input id="password" type="text" placeholder="password" value={this.state.password} onChange={this.handlePasswordChange}/> | ||
| 43 | </div> | ||
| 44 | </div> | ||
| 45 | |||
| 46 | <p><span role="img" aria-label="mobile-phone">πΈπ±</span>Point your phone's camera at the QR Code to connect automatically</p> | ||
| 47 | </fieldset> | ||
| 48 | <div className="print-btn"> | ||
| 49 | <button onClick={window.print}>Print</button> | ||
| 50 | </div> | ||
| 51 | </div> | ||
| 52 | ) | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | export default Card; | ||
diff --git a/src/components/style.css b/src/components/style.css new file mode 100644 index 0000000..e5b01e3 --- /dev/null +++ b/src/components/style.css | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | #print-area { | ||
| 2 | margin-top: 2em; | ||
| 3 | padding: 1em; | ||
| 4 | } | ||
| 5 | .details { | ||
| 6 | display: flex; | ||
| 7 | padding: 1em; | ||
| 8 | } | ||
| 9 | .details .text{ | ||
| 10 | margin: 0; | ||
| 11 | } | ||
| 12 | .details .text * { | ||
| 13 | margin: 0 1em; | ||
| 14 | } | ||
| 15 | .details .text input { | ||
| 16 | background-color: #fff; | ||
| 17 | border: solid 1px #ddd; | ||
| 18 | font-size: 1.4em; | ||
| 19 | font-weight: bold; | ||
| 20 | line-height: 2; | ||
| 21 | } | ||
| 22 | .print-btn { | ||
| 23 | padding-top: 2em; | ||
| 24 | } | ||
| 25 | .print-btn button { | ||
| 26 | color: #fff; | ||
| 27 | height: 50px; | ||
| 28 | width: 180px; | ||
| 29 | background-color: #0074d9; | ||
| 30 | } | ||
| 31 | |||
| 32 | @media print { | ||
| 33 | body * { | ||
| 34 | visibility: hidden; | ||
| 35 | } | ||
| 36 | #print-area, #print-area * { | ||
| 37 | visibility: visible; | ||
| 38 | } | ||
| 39 | #print-area input { | ||
| 40 | border: none; | ||
| 41 | } | ||
| 42 | #print-area { | ||
| 43 | position: absolute; | ||
| 44 | left: 0; | ||
| 45 | top: 0; | ||
| 46 | } | ||
| 47 | } | ||
