diff options
| author | Ben Woodward <ben@bdw.to> | 2021-07-13 08:17:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-13 08:17:21 -0700 |
| commit | 8c812c903f38ddffda0fd696bb32a0aa71db4fd6 (patch) | |
| tree | 1de95f2cb4e77bd3c33f20e196eda9284db3bbf1 /src | |
| parent | 4565540fa87d1726246044a9966e4b0aac6460fb (diff) | |
Hide password before printing (#42)
* feat: add possiblity to hide password fiel before priting
* HidePassword as a property of network and additional print styles
- Moves hidePassword into the network object
- Adds missing CSS for hiding password
Co-authored-by: orenaksakal <orenaksakal@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Card.js | 18 | ||||
| -rw-r--r-- | src/components/style.css | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/components/Card.js b/src/components/Card.js index 05fd09e..ffdd097 100644 --- a/src/components/Card.js +++ b/src/components/Card.js | |||
| @@ -8,6 +8,7 @@ export const Card = () => { | |||
| 8 | const [network, setNetwork] = useState({ | 8 | const [network, setNetwork] = useState({ |
| 9 | ssid: '', | 9 | ssid: '', |
| 10 | password: '', | 10 | password: '', |
| 11 | hidePassword: false, | ||
| 11 | }); | 12 | }); |
| 12 | const [portrait, setPortrait] = useState(false); | 13 | const [portrait, setPortrait] = useState(false); |
| 13 | 14 | ||
| @@ -78,7 +79,9 @@ export const Card = () => { | |||
| 78 | value={network.ssid} | 79 | value={network.ssid} |
| 79 | onChange={(e) => setNetwork({ ...network, ssid: e.target.value })} | 80 | onChange={(e) => setNetwork({ ...network, ssid: e.target.value })} |
| 80 | /> | 81 | /> |
| 81 | <label>Password</label> | 82 | <label className={network.hidePassword ? 'hide-password' : ''}> |
| 83 | Password | ||
| 84 | </label> | ||
| 82 | <textarea | 85 | <textarea |
| 83 | id="password" | 86 | id="password" |
| 84 | type="text" | 87 | type="text" |
| @@ -86,6 +89,7 @@ export const Card = () => { | |||
| 86 | height: | 89 | height: |
| 87 | portrait && network.password.length > 40 ? '5em' : 'auto', | 90 | portrait && network.password.length > 40 ? '5em' : 'auto', |
| 88 | }} | 91 | }} |
| 92 | className={network.hidePassword ? 'hide-password' : ''} | ||
| 89 | maxLength="63" | 93 | maxLength="63" |
| 90 | placeholder="Password" | 94 | placeholder="Password" |
| 91 | autoComplete="off" | 95 | autoComplete="off" |
| @@ -97,6 +101,18 @@ export const Card = () => { | |||
| 97 | setNetwork({ ...network, password: e.target.value }) | 101 | setNetwork({ ...network, password: e.target.value }) |
| 98 | } | 102 | } |
| 99 | /> | 103 | /> |
| 104 | |||
| 105 | <input | ||
| 106 | type="checkbox" | ||
| 107 | id="hide-password-checkbox" | ||
| 108 | className="hide-password" | ||
| 109 | onChange={() => | ||
| 110 | setNetwork({ ...network, hidePassword: !network.hidePassword }) | ||
| 111 | } | ||
| 112 | /> | ||
| 113 | <label for="hide-password-checkbox" className="hide-password"> | ||
| 114 | Hide password field before printing | ||
| 115 | </label> | ||
| 100 | </div> | 116 | </div> |
| 101 | </div> | 117 | </div> |
| 102 | 118 | ||
diff --git a/src/components/style.css b/src/components/style.css index c1b78be..6887d59 100644 --- a/src/components/style.css +++ b/src/components/style.css | |||
| @@ -56,6 +56,9 @@ button#rotate { | |||
| 56 | #print-area textarea { | 56 | #print-area textarea { |
| 57 | border: none; | 57 | border: none; |
| 58 | } | 58 | } |
| 59 | .hide-password { | ||
| 60 | display: none; | ||
| 61 | } | ||
| 59 | #print-area { | 62 | #print-area { |
| 60 | position: absolute; | 63 | position: absolute; |
| 61 | left: 0; | 64 | left: 0; |
