Skip to content

Commit 2dbb679

Browse files
committed
Add new emotion
1 parent 206a2f4 commit 2dbb679

11 files changed

+585
-66
lines changed

components/Button.tsx

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
import React, { ButtonHTMLAttributes, PropsWithChildren } from 'react'
2-
import classes from '../styles/Button.module.scss';
1+
import React, { PropsWithChildren } from "react";
2+
import classes from "../styles/Button.module.scss";
33

4-
type ButtonProps = PropsWithChildren<React.HTMLAttributes<HTMLButtonElement> & {
5-
variant?: 'primary' | 'secondary'
6-
size?: 'small' | 'normal' | 'large'
7-
}>
4+
type ButtonProps = PropsWithChildren<
5+
React.HTMLAttributes<HTMLButtonElement> & {
6+
variant?: "primary" | "secondary";
7+
size?: "small" | "normal" | "large";
8+
}
9+
>;
810

9-
export default function Button({variant, className, size, ...props}: ButtonProps) {
10-
var currentClass = className ?? '';
11-
currentClass += ' ' + classes.btn;
11+
export default function Button({
12+
variant,
13+
className,
14+
size,
15+
...props
16+
}: ButtonProps) {
17+
var currentClass = className ?? "";
18+
currentClass += " " + classes.btn;
19+
switch (variant) {
20+
case "secondary":
21+
currentClass += " " + classes.btnSecondary;
22+
break;
23+
default:
24+
currentClass += " " + classes.btnPrimary;
25+
break;
26+
}
1227
switch (size) {
13-
case 'small':
14-
currentClass += ' ' + classes.btnSmall;
28+
case "small":
29+
currentClass += " " + classes.btnSmall;
1530
break;
16-
case 'large':
17-
currentClass += ' ' + classes.btnLarge;
31+
case "large":
32+
currentClass += " " + classes.btnLarge;
1833
break;
1934
}
20-
21-
return (
22-
<button className={currentClass} {...props} />
23-
)
24-
}
35+
36+
return <button className={currentClass} {...props} />;
37+
}

components/Icon.tsx

+17-7
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@ type IconProps = PropsWithChildren<
99
}
1010
>;
1111

12-
export default function Icon({ className, ...props }: IconProps) {
12+
export default function Icon({ className, children, ...props }: IconProps) {
1313
return (
1414
<span
15-
className={`material-symbols-outlined ${classes.icon} ${className ?? ""}`}
16-
style={{
17-
fontSize: props.size ?? 24,
18-
color: props.color === "primary" ? variables.primaryColor : "inherit",
19-
}}
15+
className={`material-symbols-outlined ${className ?? ""}}`}
2016
{...props}
21-
/>
17+
>
18+
<style jsx>
19+
{`
20+
span {
21+
font-size: ${props.size ?? 24}px;
22+
user-select: none;
23+
}
24+
span:hover {
25+
cursor: pointer;
26+
color: green;
27+
}
28+
`}
29+
</style>
30+
{children}
31+
</span>
2232
);
2333
}

components/Link.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ type LinkProps = PropsWithChildren<React.AnchorHTMLAttributes<HTMLAnchorElement>
99
export default function Link({variant, className, size, ...props}: LinkProps) {
1010
var currentClass = className ?? '';
1111
currentClass += ' ' + classes.btn;
12+
switch (variant) {
13+
case "secondary":
14+
currentClass += " " + classes.btnSecondary;
15+
break;
16+
default:
17+
currentClass += " " + classes.btnPrimary;
18+
break;
19+
}
1220
switch (size) {
1321
case 'small':
1422
currentClass += ' ' + classes.btnSmall;

components/NewButton.tsx

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import styled from '@emotion/styled'
2+
3+
type ButtonProps = {
4+
variant?: "primary" | "secondary";
5+
size?: "small" | "normal" | "large";
6+
};
7+
8+
9+
const Button = styled.button<ButtonProps>`
10+
padding: 0.5rem 4rem;
11+
border-radius: 0.8rem;
12+
border: 0;
13+
cursor: pointer;
14+
font-weight: 500;
15+
font-size: 1.5rem;
16+
margin: 0.5rem;
17+
text-decoration: none;
18+
transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
19+
${({ variant }) => {
20+
switch (variant) {
21+
case "secondary":
22+
return `
23+
background: #fff;
24+
color: #000;
25+
`;
26+
default:
27+
return `
28+
background: #000;
29+
color: #fff;
30+
`;
31+
}
32+
}}
33+
`;
34+
35+
export default Button;

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@emotion/react": "^11.10.4",
13+
"@emotion/styled": "^11.10.4",
1214
"material-symbols": "^0.2.13",
1315
"next": "12.3.1",
1416
"react": "18.2.0",

pages/blog/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Blog() {
2222
diam nonumy eirmod tempor invidunt ut labore et dolore magna
2323
aliquyam erat, sed diam voluptua. At vero eos et accusam et
2424
</p>
25-
<div><Icon>java</Icon> Java</div>
25+
<Flex alignItems="center"><Icon>coffee</Icon> Java</Flex>
2626
<Link size="small" href="#">
2727
Read more
2828
</Link>

pages/index.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextPage } from "next";
22
import Head from "next/head";
33
import Image from "next/image";
4-
import Button from "../components/Button";
4+
import Button from "../components/NewButton";
55
import Icon from "../components/Icon";
66
import Card from "../components/layouts/Card";
77
import Container from "../components/layouts/Container";
@@ -27,14 +27,18 @@ const Home: NextPage = () => {
2727
<Text variant="caption">
2828
Dem größten Programmier-Discord im deutschsprachigen Raum!
2929
</Text>
30-
<Link href="https://invite.programm-chest.dev" variant="primary">Join</Link>
30+
<Button variant="primary">Join</Button>
31+
<Flex>
32+
<Link href="https://invite.programm-chest.dev" variant="primary">Join</Link>
33+
<Link href="https://invite.programm-chest.dev" variant="secondary">Erkunden</Link>
34+
</Flex>
3135
</Container>
3236

3337
<Flex alignItems="stretch" flexWrap="wrap" justifyContent="center" gap={12}>
3438
<Card title="Hilfsbereite Community" icon="live_help">
3539
Da wir viele Programmierer aus den unterschiedlichsten Bereichen und Themengebieten bei uns versammeln, wird sich sicherlich jemand finden, der die passende Lösung für dein Problem bereithält
3640
</Card>
37-
41+
3842
<Card title="Erfahrung" icon="schedule">
3943
Seit nun mehr als 3 Jahren kümmert sich unser Team gemeinsam mit unserer Community um Anliegen anderer Mitglieder.
4044
</Card>

styles/Button.module.scss

+34-26
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
@use "colors";
22

3-
$button-color: (
4-
"primary": colors.$primary,
5-
"secondary": transparent
6-
);
7-
83
.btn {
9-
padding: 0.5rem 4rem;
10-
border-radius: 0.8rem;
11-
border: 0;
4+
padding: 0.5rem 4rem;
5+
border-radius: 0.8rem;
6+
border: 0;
7+
cursor: pointer;
8+
font-weight: 500;
9+
font-size: 1.5rem;
10+
margin: 0.5rem;
11+
text-decoration: none;
12+
transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
13+
}
14+
15+
.btnPrimary {
16+
color: colors.$text;
17+
background: colors.$primary;
18+
border: 4px solid colors.$primary;
19+
&:hover {
20+
background: colors.$text;
1221
color: colors.$primary;
13-
background: transparent;
14-
cursor: pointer;
15-
border: 4px solid colors.$primary;
16-
font-weight: 500;
17-
font-size: 1.5rem;
18-
margin: 0.5rem;
19-
text-decoration: none;
20-
transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
21-
&:hover {
22-
background: colors.$primary;
23-
color: colors.$text;
24-
}
22+
}
23+
}
24+
25+
.btnSecondary {
26+
color: colors.$primary;
27+
background: transparent;
28+
border: 4px solid colors.$primary;
29+
&:hover {
30+
background: colors.$primary;
31+
color: colors.$text;
32+
}
2533
}
2634

2735
.btnSmall {
28-
padding: 0.5rem 2rem;
29-
font-size: 1rem;
30-
border-width: 2px;
36+
padding: 0.5rem 2rem;
37+
font-size: 1rem;
38+
border-width: 2px;
3139
}
3240

3341
.btnLarge {
34-
padding: 0.5rem 6rem;
35-
font-size: 2rem;
36-
border-width: 6px;
42+
padding: 0.5rem 6rem;
43+
font-size: 2rem;
44+
border-width: 6px;
3745
}

styles/Navbar.module.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,20 @@
2424
color: colors.$text;
2525
text-decoration: none;
2626
font-weight: 600;
27-
padding-bottom: 0.1rem;
27+
padding-bottom: 0.2rem;
28+
&:hover {
29+
border-bottom: 0.2rem solid colors.$text;
30+
padding-bottom: 0;
31+
}
2832
}
2933
.navbarCurrentLink {
3034
color: colors.$primary;
3135
text-decoration: none;
32-
border-bottom: 0.1rem solid colors.$primary;
36+
border-bottom: 0.2rem solid colors.$primary;
3337
padding-bottom: 0;
38+
&:hover {
39+
border-bottom: 0.2rem solid colors.$primary;
40+
}
3441
}
3542

3643
.navbarMenu {

tsconfig.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"lib": ["dom", "dom.iterable", "esnext"],
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
59
"allowJs": true,
610
"skipLibCheck": true,
711
"strict": true,
@@ -12,9 +16,16 @@
1216
"moduleResolution": "node",
1317
"resolveJsonModule": true,
1418
"isolatedModules": true,
19+
"incremental": true,
1520
"jsx": "preserve",
16-
"incremental": true
21+
"jsxImportSource": "@emotion/react"
1722
},
18-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19-
"exclude": ["node_modules"]
23+
"include": [
24+
"next-env.d.ts",
25+
"**/*.ts",
26+
"**/*.tsx"
27+
],
28+
"exclude": [
29+
"node_modules"
30+
]
2031
}

0 commit comments

Comments
 (0)