Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f979565

Browse files
authored
fix(example): import styles as ESModules in simple-auth (#29823)
1 parent 55778eb commit f979565

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
import React from "react"
2-
import styles from "./form.module.css"
2+
import { form, form__label, form__input, form__button } from "./form.module.css"
33
import { navigate } from "@reach/router"
44

55
export default ({ handleSubmit, handleUpdate }) => (
66
<form
7-
className={styles.form}
7+
className={form}
88
method="post"
99
onSubmit={event => {
1010
handleSubmit(event)
1111
navigate(`/app/profile`)
1212
}}
1313
>
14-
<p className={styles[`form__instructions`]}>
14+
<p>
1515
For this demo, please log in with the username <code>gatsby</code> and the
1616
password <code>demo</code>.
1717
</p>
18-
<label className={styles[`form__label`]}>
18+
<label className={form__label}>
1919
Username
2020
<input
21-
className={styles[`form__input`]}
21+
className={form__input}
2222
type="text"
2323
name="username"
2424
onChange={handleUpdate}
2525
/>
2626
</label>
27-
<label className={styles[`form__label`]}>
27+
<label className={form__label}>
2828
Password
2929
<input
30-
className={styles[`form__input`]}
30+
className={form__input}
3131
type="password"
3232
name="password"
3333
onChange={handleUpdate}
3434
/>
3535
</label>
36-
<input className={styles[`form__button`]} type="submit" value="Log In" />
36+
<input className={form__button} type="submit" value="Log In" />
3737
</form>
3838
)

examples/simple-auth/src/components/Header/header.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
text-decoration: none;
3232
}
3333

34-
.header__link--home {
34+
.header__linkHome {
3535
font-size: 2rem;
3636
margin-left: -0.25rem;
3737
}

examples/simple-auth/src/components/Header/index.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import React from "react"
22
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"
411

512
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}`}>
1517
Gatsby Auth
1618
</Link>
1719
</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}>
2022
Home
2123
</Link>
22-
<Link to="/app/profile" className={styles[`header__link`]}>
24+
<Link to="/app/profile" className={header__link}>
2325
Profile
2426
</Link>
25-
<Link to="/app/details" className={styles[`header__link`]}>
27+
<Link to="/app/details" className={header__link}>
2628
Details
2729
</Link>
2830
</nav>

examples/simple-auth/src/components/Layout/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import Header from "../Header"
55

66
// Global styles and component-specific styles.
77
import "./global.css"
8-
import styles from "./main.module.css"
8+
import { main } from "./main.module.css"
99

1010
const Layout = ({ children }) => (
1111
<div>
1212
<Helmet title="Simple Authentication With Gatsby" />
1313
<Header />
14-
<main className={styles.main}>{children}</main>
14+
<main className={main}>{children}</main>
1515
</div>
1616
)
1717

examples/simple-auth/src/components/Status/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from "react"
22
import { Link, navigate } from "@reach/router"
33
import { getCurrentUser, isLoggedIn, logout } from "../../utils/auth"
4-
import styles from "./status.module.css"
4+
import { status, status__text } from "./status.module.css"
55

66
export default () => {
77
let details
88
if (!isLoggedIn()) {
99
details = (
10-
<p className={styles[`status__text`]}>
10+
<p className={status__text}>
1111
To get the full app experience, you’ll need to
1212
{` `}
1313
<Link to="/app/login">log in</Link>.
@@ -17,7 +17,7 @@ export default () => {
1717
const { name, email } = getCurrentUser()
1818

1919
details = (
20-
<p className={styles[`status__text`]}>
20+
<p className={status__text}>
2121
Logged in as {name} ({email}
2222
)!
2323
{` `}
@@ -34,5 +34,5 @@ export default () => {
3434
)
3535
}
3636

37-
return <div className={styles.status}>{details}</div>
37+
return <div className={status}>{details}</div>
3838
}

examples/simple-auth/src/components/View/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react"
22
import PropTypes from "prop-types"
3-
import styles from "./view.module.css"
3+
import { view } from "./view.module.css"
44

55
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>
88
{children}
99
</section>
1010
)

0 commit comments

Comments
 (0)