From 52ff61635b1cbd4b024ae882b606cfb64d6cc897 Mon Sep 17 00:00:00 2001 From: Ben Woodward Date: Sun, 4 Jul 2021 16:48:10 -0700 Subject: Prettier formatting (#33) * Add prettier * Format code --- src/App.js | 20 ++++++++++------- src/components/Card.js | 56 ++++++++++++++++++++++++++++++++---------------- src/components/style.css | 5 +++-- 3 files changed, 53 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/App.js b/src/App.js index ef4859c..0895668 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,29 @@ import React from 'react'; -import Card from './components/Card'; +import { Card } from './components/Card'; import './style.css'; function App() { return (
- -

πŸ“Ά  WiFi Card

+

+ + πŸ“Ά + +   WiFi Card +

- Print a simple card with your WiFi login details. Tape it to the fridge, keep it in your wallet, etc. + Print a simple card with your WiFi login details. Tape it to the fridge, + keep it in your wallet, etc.

- Your WiFi information is never sent to the server. - No tracking, analytics, or fingerprinting are used on this website. - View the source code. + Your WiFi information is never sent to the server. No tracking, + analytics, or fingerprinting are used on this website. View the{' '} + source code.

-
); } diff --git a/src/components/Card.js b/src/components/Card.js index 6c2c745..16f94a4 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -2,14 +2,16 @@ import React, { useState, useEffect } from 'react'; import QRCode from 'qrcode.react'; import './style.css'; -const Card = () => { - const [ssid, setSsid] = useState(''); - const [password, setPassword] = useState(''); +export const Card = () => { + const [network, setNetwork] = useState({ + ssid: '', + password: '', + }); const [qrvalue, setQrvalue] = useState(''); const escape = (v) => { const needsEscape = ['"', ';', ',', ':', '\\']; - + let escaped = ''; for (let i = 0; i < v.length; i++) { let c = v[i]; @@ -20,14 +22,13 @@ const Card = () => { } return escaped; - } + }; useEffect(() => { - let _ssid = escape(ssid), - _password = escape(password); - - setQrvalue(`WIFI:T:WPA;S:${_ssid};P:${_password};;`); - }, [ssid, password]); + const ssid = escape(network.ssid); + const password = escape(network.password); + setQrvalue(`WIFI:T:WPA;S:${ssid};P:${password};;`); + }, [network]); return (
@@ -35,26 +36,45 @@ const Card = () => {

WiFi Login

-
+
- setSsid(event.target.value)} /> + setNetwork({ ...network, ssid: e.target.value })} + /> - setPassword(event.target.value)} /> + + setNetwork({ ...network, password: e.target.value }) + } + />
-

πŸ“ΈπŸ“±Point your phone's camera at the QR Code to connect automatically

+

+ + πŸ“ΈπŸ“± + + Point your phone's camera at the QR Code to connect automatically +

- ) -} - -export default Card; + ); +}; diff --git a/src/components/style.css b/src/components/style.css index 0f98052..d1440e2 100644 --- a/src/components/style.css +++ b/src/components/style.css @@ -8,7 +8,7 @@ display: flex; padding: 1em; } -.details .text{ +.details .text { margin: 0; } .details .text * { @@ -36,7 +36,8 @@ body * { visibility: hidden; } - #print-area, #print-area * { + #print-area, + #print-area * { visibility: visible; } #print-area input { -- cgit v1.2.3