Add components

+ Finished card
+ Button
This commit is contained in:
Stephan
2022-09-29 22:05:18 +02:00
parent a43e64f200
commit c48001f2d5
10 changed files with 120 additions and 0 deletions
+1
View File
@@ -27,6 +27,7 @@
"@types/react-dom": "^18.0.6", "@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0", "@vitejs/plugin-react": "^2.1.0",
"babel-loader": "^8.2.5", "babel-loader": "^8.2.5",
"sass": "^1.55.0",
"typescript": "^4.6.4", "typescript": "^4.6.4",
"vite": "^3.1.0" "vite": "^3.1.0"
} }
+43
View File
@@ -0,0 +1,43 @@
@import "../../styles/colors";
@mixin fullInset {
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.button {
outline: none;
border: none;
cursor: pointer;
font-size: 1.05rem;
color: white;
background: transparent;
padding: 0.4rem 2rem;
position: relative;
&:hover .background {
transform: scale(1.1);
}
}
.background {
border-radius: 1rem;
background: $accent;
position: absolute;
@include fullInset();
transition: transform 100ms ease-in-out;
}
.children {
position: relative;
top: 50%;
left: 50%;
transform: translateX(-50%);
}
+13
View File
@@ -0,0 +1,13 @@
import React from "react";
import styles from "./Button.module.scss";
const Button: React.FC<{ children: any }> = ({ children }) => {
return (
<button className={styles.button}>
<div className={styles.background}></div>
<div className={styles.children}>{children}</div>
</button>
);
};
export default Button;
+3
View File
@@ -0,0 +1,3 @@
import Button from "./Button";
export default Button;
+15
View File
@@ -0,0 +1,15 @@
.test {
background: white;
width: min(80%, 60rem);
padding: 1rem 0;
display: flex;
justify-content: center;
@media only screen and (min-width: 900px) {
border-radius: 32px;
box-shadow: 0 6px 13px rgba($color: #000000, $alpha: 0.25);
padding: 32px;
}
}
+11
View File
@@ -0,0 +1,11 @@
import styles from "./Card.module.scss";
const Card: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({ children, ...props }) => {
return (
<div className={styles.test} {...props}>
{children}
</div>
);
};
export default Card;
+3
View File
@@ -0,0 +1,3 @@
import Card from "./Card";
export default Card;
+15
View File
@@ -0,0 +1,15 @@
import React from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";
import Button from "../components/button";
export default { title: "Button", component: Button } as ComponentMeta<typeof Button>;
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
export const defaultButton = Template.bind({});
defaultButton.args = {
children: "Test",
};
+15
View File
@@ -0,0 +1,15 @@
import React from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";
import Card from "../components/card";
export default { title: "Card", component: Card } as ComponentMeta<typeof Card>;
const Template: ComponentStory<typeof Card> = (args) => <Card {...args} />;
export const DefaultCard = Template.bind({});
DefaultCard.args = {
children: "Test",
};
+1
View File
@@ -0,0 +1 @@
$accent: #ff6565;