File tree Expand file tree Collapse file tree 6 files changed +34
-32
lines changed
examples/simple-auth/src/components Expand file tree Collapse file tree 6 files changed +34
-32
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react"
2
- import styles from "./form.module.css"
2
+ import { form , form__label , form__input , form__button } from "./form.module.css"
3
3
import { navigate } from "@reach/router"
4
4
5
5
export default ( { handleSubmit, handleUpdate } ) => (
6
6
< form
7
- className = { styles . form }
7
+ className = { form }
8
8
method = "post"
9
9
onSubmit = { event => {
10
10
handleSubmit ( event )
11
11
navigate ( `/app/profile` )
12
12
} }
13
13
>
14
- < p className = { styles [ `form__instructions` ] } >
14
+ < p >
15
15
For this demo, please log in with the username < code > gatsby</ code > and the
16
16
password < code > demo</ code > .
17
17
</ p >
18
- < label className = { styles [ ` form__label` ] } >
18
+ < label className = { form__label } >
19
19
Username
20
20
< input
21
- className = { styles [ ` form__input` ] }
21
+ className = { form__input }
22
22
type = "text"
23
23
name = "username"
24
24
onChange = { handleUpdate }
25
25
/>
26
26
</ label >
27
- < label className = { styles [ ` form__label` ] } >
27
+ < label className = { form__label } >
28
28
Password
29
29
< input
30
- className = { styles [ ` form__input` ] }
30
+ className = { form__input }
31
31
type = "password"
32
32
name = "password"
33
33
onChange = { handleUpdate }
34
34
/>
35
35
</ label >
36
- < input className = { styles [ ` form__button` ] } type = "submit" value = "Log In" />
36
+ < input className = { form__button } type = "submit" value = "Log In" />
37
37
</ form >
38
38
)
Original file line number Diff line number Diff line change 31
31
text-decoration : none;
32
32
}
33
33
34
- .header__link--home {
34
+ .header__linkHome {
35
35
font-size : 2rem ;
36
36
margin-left : -0.25rem ;
37
37
}
Original file line number Diff line number Diff line change 1
1
import React from "react"
2
2
import { Link } from "gatsby"
3
- import styles from "./header.module.css"
3
+ import {
4
+ header ,
5
+ header__wrap ,
6
+ header__heading ,
7
+ header__nav ,
8
+ header__link ,
9
+ header__linkHome ,
10
+ } from "./header.module.css"
4
11
5
12
const Header = ( ) => (
6
- < header className = { styles . header } >
7
- < div className = { styles [ `header__wrap` ] } >
8
- < h1 className = { styles [ `header__heading` ] } >
9
- < Link
10
- to = "/"
11
- className = { `${ styles [ `header__link` ] } ${
12
- styles [ `header__link--home` ]
13
- } `}
14
- >
13
+ < header className = { header } >
14
+ < div className = { header__wrap } >
15
+ < h1 className = { header__heading } >
16
+ < Link to = "/" className = { `${ header__link } ${ header__linkHome } ` } >
15
17
Gatsby Auth
16
18
</ Link >
17
19
</ h1 >
18
- < nav role = "main" className = { styles [ ` header__nav` ] } >
19
- < Link to = "/" className = { styles [ ` header__link` ] } >
20
+ < nav role = "main" className = { header__nav } >
21
+ < Link to = "/" className = { header__link } >
20
22
Home
21
23
</ Link >
22
- < Link to = "/app/profile" className = { styles [ ` header__link` ] } >
24
+ < Link to = "/app/profile" className = { header__link } >
23
25
Profile
24
26
</ Link >
25
- < Link to = "/app/details" className = { styles [ ` header__link` ] } >
27
+ < Link to = "/app/details" className = { header__link } >
26
28
Details
27
29
</ Link >
28
30
</ nav >
Original file line number Diff line number Diff line change @@ -5,13 +5,13 @@ import Header from "../Header"
5
5
6
6
// Global styles and component-specific styles.
7
7
import "./global.css"
8
- import styles from "./main.module.css"
8
+ import { main } from "./main.module.css"
9
9
10
10
const Layout = ( { children } ) => (
11
11
< div >
12
12
< Helmet title = "Simple Authentication With Gatsby" />
13
13
< Header />
14
- < main className = { styles . main } > { children } </ main >
14
+ < main className = { main } > { children } </ main >
15
15
</ div >
16
16
)
17
17
Original file line number Diff line number Diff line change 1
1
import React from "react"
2
2
import { Link , navigate } from "@reach/router"
3
3
import { getCurrentUser , isLoggedIn , logout } from "../../utils/auth"
4
- import styles from "./status.module.css"
4
+ import { status , status__text } from "./status.module.css"
5
5
6
6
export default ( ) => {
7
7
let details
8
8
if ( ! isLoggedIn ( ) ) {
9
9
details = (
10
- < p className = { styles [ ` status__text` ] } >
10
+ < p className = { status__text } >
11
11
To get the full app experience, you’ll need to
12
12
{ ` ` }
13
13
< Link to = "/app/login" > log in</ Link > .
@@ -17,7 +17,7 @@ export default () => {
17
17
const { name, email } = getCurrentUser ( )
18
18
19
19
details = (
20
- < p className = { styles [ ` status__text` ] } >
20
+ < p className = { status__text } >
21
21
Logged in as { name } ({ email }
22
22
)!
23
23
{ ` ` }
@@ -34,5 +34,5 @@ export default () => {
34
34
)
35
35
}
36
36
37
- return < div className = { styles . status } > { details } </ div >
37
+ return < div className = { status } > { details } </ div >
38
38
}
Original file line number Diff line number Diff line change 1
1
import React from "react"
2
2
import PropTypes from "prop-types"
3
- import styles from "./view.module.css"
3
+ import { view } from "./view.module.css"
4
4
5
5
const View = ( { title, children } ) => (
6
- < section className = { styles . view } >
7
- < h1 className = { styles [ `view__heading` ] } > { title } </ h1 >
6
+ < section className = { view } >
7
+ < h1 > { title } </ h1 >
8
8
{ children }
9
9
</ section >
10
10
)
You can’t perform that action at this time.
0 commit comments