Skip to content

Commit ea50af5

Browse files
committed
feat: clean up defaults and allow +1 gh handle
1 parent 8944151 commit ea50af5

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

src/components/Info/Form.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ import createRecord from '../../helpers/airtable'
33
import { Button, Form } from './elements'
44

55
export default ({ onSubmit, city }) => {
6-
const [plus, setPlus] = useState(false)
7-
const [plusOneName, setPlusOneName] = useState('')
86
const [name, setName] = useState('')
97
const [gh, setGH] = useState('')
8+
const [plusOne, setPlusOne] = useState(false)
9+
const [plusOneName, setPlusOneName] = useState('')
10+
const [plusOneGH, setPlusOneGH] = useState('')
1011

1112
const createUser = () => {
1213
if (name && gh) {
13-
if (plus && !plusOneName) return
14+
if (plusOne && !plusOneName) return
1415

1516
createRecord({
1617
city: city,
1718
name: name,
18-
ghLink: gh
19+
ghLink: gh || 'QueerJS'
1920
})
2021

21-
if (plus) {
22+
if (plusOne) {
2223
createRecord({
2324
city: city,
2425
name: plusOneName,
25-
ghLink: 'queerjs'
26+
ghLink: plusOneGH || 'QueerJS'
2627
})
2728
}
2829
}
@@ -37,8 +38,8 @@ export default ({ onSubmit, city }) => {
3738
}}
3839
>
3940
<p>
40-
If you're not comfortable showing your photo and link please put `QueerJS` in the `Github
41-
Username` input field.
41+
If you're not comfortable showing your photo and link, you may leave the `GitHub Handle` field blank and it will default
42+
to `QueerJS`.
4243
</p>
4344
<label htmlFor="name">
4445
Your Name
@@ -53,15 +54,14 @@ export default ({ onSubmit, city }) => {
5354
/>
5455
</label>
5556
<label htmlFor="gh">
56-
Github Username
57+
Github Handle
5758
<input
58-
required
5959
id="gh"
6060
type="text"
6161
placeholder="QueerJS"
6262
pattern="[A-Za-z0-9-]{1,30}"
6363
value={gh}
64-
onInvalid={e => e.target.setCustomValidity(`Your username, e.g. 'QueerJS' for 'https://github.com/queerjs'`)}
64+
onInvalid={e => e.target.setCustomValidity(`A GitHub handle, e.g. 'QueerJS' for 'https://github.com/queerjs'`)}
6565
onChange={e => setGH(e.target.value.trim())}
6666
/>
6767
</label>
@@ -75,16 +75,16 @@ export default ({ onSubmit, city }) => {
7575
id="plus-one"
7676
type="checkbox"
7777
pattern="[a-zA-Z0-9]+"
78-
value={plus}
78+
value={plusOne}
7979
css={`
8080
width: auto !important;
8181
margin-right: 12px !important;
8282
`}
83-
onChange={e => setPlus(e.target.checked)}
83+
onChange={e => setPlusOne(e.target.checked)}
8484
/>
8585
<span>I am taking a plus one</span>
8686
</label>
87-
{plus && (
87+
{plusOne && (
8888
<label htmlFor="plus-one-name">
8989
+1 Name
9090
<input
@@ -96,6 +96,20 @@ export default ({ onSubmit, city }) => {
9696
/>
9797
</label>
9898
)}
99+
{plusOne && (
100+
<label htmlFor="plus-one-gh">
101+
+1 Github Handle
102+
<input
103+
id="plus-one-gh"
104+
type="text"
105+
placeholder="QueerJS"
106+
pattern="[A-Za-z0-9-]{1,30}"
107+
value={plusOneGH}
108+
onInvalid={e => e.target.setCustomValidity(`A GitHub handle, e.g. 'QueerJS' for 'https://github.com/queerjs'`)}
109+
onChange={e => setPlusOneGH(e.target.value.trim())}
110+
/>
111+
</label>
112+
)}
99113

100114
<Button>
101115
I AM IN{' '}

0 commit comments

Comments
 (0)