Skip to content

Commit 0394964

Browse files
Add default CSS modules solution
1 parent ed8bec9 commit 0394964

File tree

15 files changed

+145
-232
lines changed

15 files changed

+145
-232
lines changed

README.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1+
This is a [Next.js](https://nextjs.org/) project.
22

33
## Getting Started
44

55
First, run the development server:
66

77
```bash
8-
npm run dev
9-
# or
108
yarn dev
119
```
12-
13-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14-
15-
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16-
17-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
18-
19-
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20-
21-
## Learn More
22-
23-
To learn more about Next.js, take a look at the following resources:
24-
25-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27-
28-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29-
30-
## Deploy on Vercel
31-
32-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33-
34-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

components/button.module.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.button {
2+
color: dodgerblue;
3+
border: 0;
4+
height: 3em;
5+
padding: 0 2em;
6+
border-radius: 1.5em;
7+
cursor: pointer;
8+
font-weight: bold;
9+
width: 100vw;
10+
display: block;
11+
outline: 0;
12+
background-color: currentColor;
13+
margin: 1em auto;
14+
}
15+
16+
.button span {
17+
color: white;
18+
}
19+
20+
.button:hover {
21+
animation-name: button-animation;
22+
animation-fill-mode: forwards;
23+
animation-duration: 0.5s;
24+
}
25+
26+
@media only screen and (min-width: 640px) {
27+
.button {
28+
width: 100%;
29+
}
30+
}
31+
32+
@keyframes button-animation {
33+
from {
34+
transform: translateY(0);
35+
box-shadow: none;
36+
}
37+
to {
38+
transform: translateY(-0.5em);
39+
box-shadow: 0 0.5em 0 0 #ddd;
40+
}
41+
}

components/button.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import styles from "./button.module.css";
2+
3+
type Props = {
4+
children: string;
5+
color?: string;
6+
};
7+
8+
export function Button(props: Props) {
9+
const { children, color = "dodgerblue" } = props;
10+
11+
return (
12+
<button className={styles.button} style={{ color }}>
13+
<span>{children}</span>
14+
</button>
15+
);
16+
}

next-env.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
"next": "10.0.5",
1212
"react": "17.0.1",
1313
"react-dom": "17.0.1"
14+
},
15+
"devDependencies": {
16+
"@types/node": "^14.14.20",
17+
"@types/react": "^17.0.0",
18+
"typescript": "^4.1.3"
1419
}
1520
}

pages/_app.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

pages/_app.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { AppProps /*, AppContext */ } from "next/app";
2+
3+
import "../styles/globals.css";
4+
5+
function MyApp({ Component, pageProps }: AppProps) {
6+
return <Component {...pageProps} />;
7+
}
8+
9+
export default MyApp;

pages/api/hello.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

pages/index.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

pages/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Button } from "../components/button";
2+
3+
export default function Home() {
4+
return (
5+
<main>
6+
<Button>Default color</Button>
7+
<Button color="#e3b307">Yellow color</Button>
8+
<Button color="#57b004">Green color</Button>
9+
</main>
10+
);
11+
}

0 commit comments

Comments
 (0)