Skip to content

Commit cae7e8e

Browse files
committed
Add ButtonType component
1 parent 6fca1aa commit cae7e8e

File tree

9 files changed

+112
-61
lines changed

9 files changed

+112
-61
lines changed

package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@testing-library/jest-dom": "^5.16.4",
88
"@testing-library/react": "^13.1.1",
99
"@testing-library/user-event": "^13.5.0",
10+
"nanoid": "^3.3.4",
1011
"react": "^18.0.0",
1112
"react-dom": "^18.0.0",
1213
"react-scripts": "5.0.1",

src/App.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import Page from "./Page";
1+
import Page from "./components/Page";
22
import "./App.css";
33

44
const App = () => {
5-
console.log("App");
65
return (
76
<div className="App">
87
<Page />
98
<center>
109
<strong>
11-
Created By: <a href="https://github.com/Gameonn">Gameonn</a>{" "}
10+
Created By: <a href="https://github.com/Gameonn">Gameonn</a>
1211
</strong>
1312
- devChallenges.io
1413
</center>

src/Button.js

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

src/components/Button.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import styles from "./Button.module.css";
2+
3+
const Button = (...props) => {
4+
console.log(props, "Button");
5+
return <p>Hey</p>;
6+
};
7+
8+
// const Button = ({
9+
// variant,
10+
// text,
11+
// disableShadow,
12+
// states,
13+
// disabled,
14+
// size,
15+
// color,
16+
// startIcon,
17+
// endIcon,
18+
// children
19+
// }) => {
20+
// return (
21+
// <button
22+
// className={`
23+
// ${styles.button}
24+
// ${color ? styles[color] : styles["default"]}
25+
// ${styles[variant]}
26+
// ${disableShadow ? styles.disableShadow : undefined}
27+
// ${styles[size]}`}
28+
// disabled={disabled ? "disabled" : ""}
29+
// >
30+
// {startIcon && <span className="material-icons">{startIcon}</span>}
31+
// {/* {variant && <span className={styles["caps"]}> {variant}</span>}
32+
// {color && <span className={styles["caps"]}> {color}</span>} */}
33+
// <span className={styles["caps"]}> Default </span>
34+
// {endIcon && <span className="material-icons">{endIcon}</span>}
35+
// </button>
36+
// );
37+
// };
38+
39+
export default Button;

src/components/ButtonType.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Button from "./Button";
2+
import { FlexboxGrid, Divider } from "rsuite";
3+
import { nanoid } from "nanoid";
4+
5+
let styleObj = {
6+
display: "block",
7+
height: "40px"
8+
};
9+
10+
const ButtonType = ({ title, types, set }) => {
11+
// console.log(types, "types");
12+
let item = {};
13+
let selectedTypes = Object.fromEntries(
14+
Object.keys(types).filter(([key]) => key.includes(set))
15+
)[set];
16+
// console.log(selectedTypes);
17+
return (
18+
<div>
19+
<b> {title} </b>
20+
<FlexboxGrid justify="space-around">
21+
{selectedTypes &&
22+
selectedTypes.map(type => {
23+
item[set] = type;
24+
return (
25+
<FlexboxGrid.Item colspan={6} key={nanoid()}>
26+
<small style={styleObj}> {`<Button />`} </small>
27+
<Button {...item} />
28+
</FlexboxGrid.Item>
29+
);
30+
})}
31+
</FlexboxGrid>
32+
33+
<Divider />
34+
</div>
35+
);
36+
};
37+
38+
export default ButtonType;

src/Main.js renamed to src/components/Main.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
import Button from "./Button";
2+
import ButtonType from "./ButtonType";
23
import { FlexboxGrid, Divider } from "rsuite";
34

45
let styleObj = {
56
display: "block",
67
height: "40px"
78
};
89

10+
const variantTypes = ["", "outline", "text"];
11+
const colorTypes = ["default", "primary", "danger", "secondary"];
12+
const sizeTypes = ["xs", "sm", "md", "lg"];
13+
const startIconTypes = ["home", "bookmarks", "bolt", "book"];
14+
const endIconTypes = ["toys", "whatshot", "weekend", "vignette"];
15+
16+
const types = {
17+
color: ["default", "primary", "danger", "secondary"],
18+
size: ["xs", "sm", "md", "lg"],
19+
variant: ["", "outline", "text"],
20+
startIcon: ["home", "bookmarks", "bolt", "book"],
21+
endIcon: ["toys", "whatshot", "weekend", "vignette"]
22+
};
23+
924
const Main = () => {
10-
console.log("Main");
1125
return (
1226
<div>
1327
<h4>Buttons</h4> <br />
1428
<div className="show-grid">
15-
<b> Normal </b>
16-
<FlexboxGrid justify="space-around">
17-
<FlexboxGrid.Item colspan={6}>
18-
<small style={styleObj}> {`<Button />`} </small>
19-
<Button />
20-
</FlexboxGrid.Item>
21-
<FlexboxGrid.Item colspan={6}>
22-
<small style={styleObj}>{`<Button variant="outline" />`}</small>
23-
<Button variant="outline" />
24-
</FlexboxGrid.Item>
25-
<FlexboxGrid.Item colspan={6}>
26-
<small style={styleObj}> {`<Button variant="text" />`} </small>
27-
<Button variant="text" />
28-
</FlexboxGrid.Item>
29-
</FlexboxGrid>
30-
31-
<Divider />
29+
<ButtonType types={types} set="variant" title="Normal" />
30+
<ButtonType types={types} set="color" title="Colors" />
31+
<ButtonType types={types} set="size" title="Size" />
32+
<ButtonType
33+
types={startIconTypes}
34+
set="startIcon"
35+
title="Start Icons"
36+
/>
37+
<ButtonType types={endIconTypes} set="endIcon" title="End Icons" />
3238
<b> Colors </b>
39+
3340
<FlexboxGrid justify="space-around">
3441
<FlexboxGrid.Item colspan={4}>
3542
<small style={styleObj}> {`<Button color="default" />`} </small>
File renamed without changes.

0 commit comments

Comments
 (0)