From cae7e8e3c20892ddfab900fa7c941d8950cd5965 Mon Sep 17 00:00:00 2001 From: Gameonn Date: Wed, 4 May 2022 10:09:07 +0530 Subject: [PATCH] Add ButtonType component --- package-lock.json | 13 ++++---- package.json | 1 + src/App.js | 5 ++- src/Button.js | 34 -------------------- src/components/Button.js | 39 +++++++++++++++++++++++ src/{ => components}/Button.module.css | 0 src/components/ButtonType.js | 38 +++++++++++++++++++++++ src/{ => components}/Main.js | 43 +++++++++++++++----------- src/{ => components}/Page.js | 0 9 files changed, 112 insertions(+), 61 deletions(-) delete mode 100644 src/Button.js create mode 100644 src/components/Button.js rename src/{ => components}/Button.module.css (100%) create mode 100644 src/components/ButtonType.js rename src/{ => components}/Main.js (84%) rename src/{ => components}/Page.js (100%) diff --git a/package-lock.json b/package-lock.json index 834c5e5..5976b9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.1.1", "@testing-library/user-event": "^13.5.0", + "nanoid": "^3.3.4", "react": "^18.0.0", "react-dom": "^18.0.0", "react-scripts": "5.0.1", @@ -11151,9 +11152,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.2.tgz", - "integrity": "sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -24075,9 +24076,9 @@ } }, "nanoid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.2.tgz", - "integrity": "sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA==" + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" }, "natural-compare": { "version": "1.4.0", diff --git a/package.json b/package.json index e71c92d..3a9bba3 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.1.1", "@testing-library/user-event": "^13.5.0", + "nanoid": "^3.3.4", "react": "^18.0.0", "react-dom": "^18.0.0", "react-scripts": "5.0.1", diff --git a/src/App.js b/src/App.js index e6a8ee4..bed7f3b 100644 --- a/src/App.js +++ b/src/App.js @@ -1,14 +1,13 @@ -import Page from "./Page"; +import Page from "./components/Page"; import "./App.css"; const App = () => { - console.log("App"); return (
- Created By: Gameonn{" "} + Created By: Gameonn - devChallenges.io
diff --git a/src/Button.js b/src/Button.js deleted file mode 100644 index ecfd5f3..0000000 --- a/src/Button.js +++ /dev/null @@ -1,34 +0,0 @@ -import styles from "./Button.module.css"; - -const Button = ({ - variant, - text, - disableShadow, - states, - disabled, - size, - color, - startIcon, - endIcon, - children -}) => { - return ( - - ); -}; - -export default Button; diff --git a/src/components/Button.js b/src/components/Button.js new file mode 100644 index 0000000..10cc692 --- /dev/null +++ b/src/components/Button.js @@ -0,0 +1,39 @@ +import styles from "./Button.module.css"; + +const Button = (...props) => { + console.log(props, "Button"); + return

Hey

; +}; + +// const Button = ({ +// variant, +// text, +// disableShadow, +// states, +// disabled, +// size, +// color, +// startIcon, +// endIcon, +// children +// }) => { +// return ( +// +// ); +// }; + +export default Button; diff --git a/src/Button.module.css b/src/components/Button.module.css similarity index 100% rename from src/Button.module.css rename to src/components/Button.module.css diff --git a/src/components/ButtonType.js b/src/components/ButtonType.js new file mode 100644 index 0000000..e3cb549 --- /dev/null +++ b/src/components/ButtonType.js @@ -0,0 +1,38 @@ +import Button from "./Button"; +import { FlexboxGrid, Divider } from "rsuite"; +import { nanoid } from "nanoid"; + +let styleObj = { + display: "block", + height: "40px" +}; + +const ButtonType = ({ title, types, set }) => { + // console.log(types, "types"); + let item = {}; + let selectedTypes = Object.fromEntries( + Object.keys(types).filter(([key]) => key.includes(set)) + )[set]; + // console.log(selectedTypes); + return ( +
+ {title} + + {selectedTypes && + selectedTypes.map(type => { + item[set] = type; + return ( + + {`
+ ); +}; + +export default ButtonType; diff --git a/src/Main.js b/src/components/Main.js similarity index 84% rename from src/Main.js rename to src/components/Main.js index 280ddcb..b4d6934 100644 --- a/src/Main.js +++ b/src/components/Main.js @@ -1,4 +1,5 @@ import Button from "./Button"; +import ButtonType from "./ButtonType"; import { FlexboxGrid, Divider } from "rsuite"; let styleObj = { @@ -6,30 +7,36 @@ let styleObj = { height: "40px" }; +const variantTypes = ["", "outline", "text"]; +const colorTypes = ["default", "primary", "danger", "secondary"]; +const sizeTypes = ["xs", "sm", "md", "lg"]; +const startIconTypes = ["home", "bookmarks", "bolt", "book"]; +const endIconTypes = ["toys", "whatshot", "weekend", "vignette"]; + +const types = { + color: ["default", "primary", "danger", "secondary"], + size: ["xs", "sm", "md", "lg"], + variant: ["", "outline", "text"], + startIcon: ["home", "bookmarks", "bolt", "book"], + endIcon: ["toys", "whatshot", "weekend", "vignette"] +}; + const Main = () => { - console.log("Main"); return (

Buttons


- Normal - - - {`