diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ac8c5c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +lib +build +*.lock diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7cbbd1e --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +* +!lib/**/* +lib/cjs diff --git a/README.md b/README.md new file mode 100644 index 0000000..1a6b8b4 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Void Design + +A hybrid package of UI elements for ReactJS, from [void](https://github.com/void-verse) + +
+ +## What's new (v1.0.2) + +- Reduced package size by 95% + +
+ +## Installation + +- :arrow_down: Install the package + +```bash +yarn add void-design +``` + +
+ +- :spiral_notepad: Import the CSS file + +```js +import "void-design/lib/void.css"; +``` + +
+ +- :blue_heart: Start using the package + +```js +import "void-design/lib/void.css"; + +import React from "react"; +import { Input } from "void-design"; + +const App = () => { + return ( +
+ +
+ ); +}; + +export default App; +``` diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..c0541f9 --- /dev/null +++ b/example/README.md @@ -0,0 +1,70 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in your browser. + +The page will reload when you make changes.\ +You may also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can't go back!** + +If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. + +You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). + +### Code Splitting + +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) + +### Analyzing the Bundle Size + +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) + +### Making a Progressive Web App + +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) + +### Advanced Configuration + +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) + +### Deployment + +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) + +### `yarn build` fails to minify + +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/example/package.json b/example/package.json new file mode 100644 index 0000000..7dab6db --- /dev/null +++ b/example/package.json @@ -0,0 +1,40 @@ +{ + "name": "example", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^5.14.1", + "@testing-library/react": "^13.0.0", + "@testing-library/user-event": "^13.2.1", + "react": "^18.1.0", + "react-dom": "^18.1.0", + "react-scripts": "5.0.1", + "void-design": "link:..", + "web-vitals": "^2.1.0" + }, + "scripts": { + "dev": "react-scripts start", + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/example/public/favicon.ico b/example/public/favicon.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/example/public/favicon.ico differ diff --git a/example/public/index.html b/example/public/index.html new file mode 100644 index 0000000..fc73afb --- /dev/null +++ b/example/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + Testing Void Design + + + +
+ + diff --git a/example/public/logo192.png b/example/public/logo192.png new file mode 100644 index 0000000..fc44b0a Binary files /dev/null and b/example/public/logo192.png differ diff --git a/example/public/logo512.png b/example/public/logo512.png new file mode 100644 index 0000000..a4e47a6 Binary files /dev/null and b/example/public/logo512.png differ diff --git a/example/public/manifest.json b/example/public/manifest.json new file mode 100644 index 0000000..080d6c7 --- /dev/null +++ b/example/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/example/public/robots.txt b/example/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/example/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/example/src/App.js b/example/src/App.js new file mode 100644 index 0000000..696ab8e --- /dev/null +++ b/example/src/App.js @@ -0,0 +1,50 @@ +import React from "react"; +import "void-design/lib/void.css"; +import { Button, Form, Input, message } from "void-design"; + +const App = () => { + return ( +
+ + + +
window.alert(JSON.stringify(values))}> + +
+ {["primary", "secondary", "success", "warning", "error"].map( + (theme, i) => ( +
+ {["large", "medium", "small"].map((size, j) => ( +
+ {["solid", "liquid", "gas"].map((structure) => ( + + ))} +
+ ))} +
+ ) + )} +
+
+
+ ); +}; + +export default App; diff --git a/example/src/index.css b/example/src/index.css new file mode 100644 index 0000000..4a1df4d --- /dev/null +++ b/example/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} diff --git a/example/src/index.js b/example/src/index.js new file mode 100644 index 0000000..7837403 --- /dev/null +++ b/example/src/index.js @@ -0,0 +1,13 @@ +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import "./index.css"; +import App from "./App"; +import reportWebVitals from "./reportWebVitals"; + +createRoot(document.getElementById("root")).render( + + + +); + +reportWebVitals(); diff --git a/example/src/reportWebVitals.js b/example/src/reportWebVitals.js new file mode 100644 index 0000000..9ecd33f --- /dev/null +++ b/example/src/reportWebVitals.js @@ -0,0 +1,13 @@ +const reportWebVitals = (onPerfEntry) => { + if (onPerfEntry && onPerfEntry instanceof Function) { + import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(onPerfEntry); + getFID(onPerfEntry); + getFCP(onPerfEntry); + getLCP(onPerfEntry); + getTTFB(onPerfEntry); + }); + } +}; + +export default reportWebVitals; diff --git a/package.json b/package.json new file mode 100644 index 0000000..20d535d --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "void-design", + "version": "1.0.2", + "description": "UI library from Void", + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", + "types": "./lib/esm/index.d.ts", + "repository": "https://github.com/Nandan-unni/void-design.git", + "author": "Nandan-unni ", + "license": "MIT", + "scripts": { + "build": "yarn build:esm && yarn build:cjs && cp -r src/styles lib && cp src/index.css lib/void.css", + "build:esm": "tsc", + "build:cjs": "tsc --module commonjs --outDir lib/cjs" + }, + "devDependencies": { + "@types/react": "^18.0.9", + "@types/react-dom": "^18.0.4", + "react": "^18.1.0", + "react-dom": "^18.1.0", + "typescript": "^4.6.4" + }, + "peerDependencies": { + "react": "^16.8.0", + "react-dom": "^16.8.0" + } +} diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx new file mode 100644 index 0000000..d7bc6f9 --- /dev/null +++ b/src/components/Button/index.tsx @@ -0,0 +1,57 @@ +import React from "react"; +import Spinner from "../Spinner"; +import { ButtonPropTypes } from "./types"; + +const Button = ({ + className = "", + children, + type = "button", + theme = "primary", + structure = "solid", + size = "medium", + shape = "rectangle", + href, + disabled, + loading, + onClick = () => {}, +}: ButtonPropTypes): JSX.Element => { + const ButtonWrapper = ({ + children, + }: { + children: JSX.Element; + }): JSX.Element => + href && !loading && !disabled ? {children} : children; + + const generateClassName = (): string => { + let name = `${className} void-btn `; + name += `void-btn-${theme}-${structure} `; + name += `void-btn-${size} `; + name += `void-btn-${shape} `; + name += disabled ? "void-btn-disabled " : ""; + name += loading ? "void-btn-loading " : ""; + return name; + }; + + return ( + + + + ); +}; + +export default Button; diff --git a/src/components/Button/types.ts b/src/components/Button/types.ts new file mode 100644 index 0000000..5cbbc76 --- /dev/null +++ b/src/components/Button/types.ts @@ -0,0 +1,13 @@ +export type ButtonPropTypes = { + disabled?: boolean; + loading?: boolean; + className?: string; + children?: JSX.Element; + type?: "button" | "submit" | "reset"; + theme?: "primary" | "secondary" | "success" | "error" | "warning"; + structure?: "solid" | "liquid" | "gas"; + size?: "large" | "medium" | "small"; + shape?: "rectangle" | "rounded"; + href?: string; + onClick?: () => any; +}; diff --git a/src/components/Form/index.tsx b/src/components/Form/index.tsx new file mode 100644 index 0000000..85c05ad --- /dev/null +++ b/src/components/Form/index.tsx @@ -0,0 +1,37 @@ +import React from "react"; +import { FormPropTypes } from "./types"; + +const Form = ({ + className = "", + children, + onSubmit, + style, +}: FormPropTypes): JSX.Element => { + const handleOnSubmit = (event: React.FormEvent) => { + event.preventDefault(); + const formValues = {}; + const { elements } = event.currentTarget; + Object.keys(elements).map((key) => { + const { type } = elements[key]; + if (isNaN(parseInt(key))) { + const { checked, value } = elements[key]; + if (type === "radio" || type === "checkbox") formValues[key] = checked; + else formValues[key] = value; + } + }); + onSubmit && onSubmit(formValues); + }; + + return ( +
+ {children} +
+ ); +}; + +export default Form; diff --git a/src/components/Form/types.ts b/src/components/Form/types.ts new file mode 100644 index 0000000..97b688c --- /dev/null +++ b/src/components/Form/types.ts @@ -0,0 +1,8 @@ +import React from "react"; + +export type FormPropTypes = { + className?: string; + onSubmit?: (values: object) => void; + children?: JSX.Element; + style?: React.CSSProperties; +}; diff --git a/src/components/Input/date.tsx b/src/components/Input/date.tsx new file mode 100644 index 0000000..e2d42a7 --- /dev/null +++ b/src/components/Input/date.tsx @@ -0,0 +1,8 @@ +import React from "react"; +import { defaultProps, InputPropTypes } from "./types"; + +const DateInput = (props: InputPropTypes): JSX.Element => { + return ; +}; + +export default DateInput; diff --git a/src/components/Input/index.tsx b/src/components/Input/index.tsx new file mode 100644 index 0000000..9d6580c --- /dev/null +++ b/src/components/Input/index.tsx @@ -0,0 +1,14 @@ +import React from "react"; +import DateInput from "./date"; +import TextInput from "./text"; +import { InputPropTypes, InputTypeTypes } from "./types"; + +// DateInput; +const Input: React.FC & InputTypeTypes = ( + props +): JSX.Element => ; + +Input.Text = TextInput; +Input.Date = DateInput; + +export default Input; diff --git a/src/components/Input/text.tsx b/src/components/Input/text.tsx new file mode 100644 index 0000000..f4708ed --- /dev/null +++ b/src/components/Input/text.tsx @@ -0,0 +1,17 @@ +import React from "react"; +import { defaultProps, InputPropTypes } from "./types"; + +const TextInput = (props: InputPropTypes): JSX.Element => { + return ( +
+ {props.label && ( +

+ +

+ )} + +
+ ); +}; + +export default TextInput; diff --git a/src/components/Input/types.ts b/src/components/Input/types.ts new file mode 100644 index 0000000..ff5d9f8 --- /dev/null +++ b/src/components/Input/types.ts @@ -0,0 +1,36 @@ +import React from "react"; +import DateInput from "./date"; +import TextInput from "./text"; + +export type InputPropTypes = { + disabled?: boolean; + loading?: boolean; + placeholder?: string; + label?: string; + value?: string; + name?: string; + className?: string; + style?: React.CSSProperties; + onChange?: (val: string) => any; +}; + +export type InputTypeTypes = { + Text: typeof TextInput; + Date: typeof DateInput; +}; + +export const defaultProps = (props: InputPropTypes, className?: string) => { + return { + className: `void-input ${props.loading ? "void-input-loading" : ""} ${ + className || "" + } ${props.className || ""}`, + id: props.name, + name: props.name, + value: props.value, + disabled: props.disabled, + placeholder: props.placeholder, + style: props.style, + onChange: (e: React.ChangeEvent) => + props.onChange ? props.onChange(e.target.value) : () => {}, + }; +}; diff --git a/src/components/Loader/index.tsx b/src/components/Loader/index.tsx new file mode 100644 index 0000000..2efc4f9 --- /dev/null +++ b/src/components/Loader/index.tsx @@ -0,0 +1,14 @@ +import React from "react"; +import Spinner from "../Spinner"; +import { LoaderPropTypes } from "./types"; + +const Loader = ({ title = "Loading..." }: LoaderPropTypes): JSX.Element => { + return ( +
+ +

{title}

+
+ ); +}; + +export default Loader; diff --git a/src/components/Loader/types.ts b/src/components/Loader/types.ts new file mode 100644 index 0000000..7eedc8f --- /dev/null +++ b/src/components/Loader/types.ts @@ -0,0 +1,5 @@ +export type LoaderPropTypes = { + title: string; + description: string; + content: JSX.Element; +}; diff --git a/src/components/Spinner/index.tsx b/src/components/Spinner/index.tsx new file mode 100644 index 0000000..6e07568 --- /dev/null +++ b/src/components/Spinner/index.tsx @@ -0,0 +1,66 @@ +import React from "react"; +import { SpinnerPropTypes } from "./types"; + +const Spinner = ({ + size = "medium", + theme = "normal", +}: SpinnerPropTypes): JSX.Element => { + return ( + + + + + + + + + + + + ); +}; + +export default Spinner; diff --git a/src/components/Spinner/types.ts b/src/components/Spinner/types.ts new file mode 100644 index 0000000..bf67c9d --- /dev/null +++ b/src/components/Spinner/types.ts @@ -0,0 +1,4 @@ +export type SpinnerPropTypes = { + size?: "large" | "medium" | "small" | "tiny"; + theme?: "normal" | "primary" | "secondary" | "success" | "error" | "warning"; +}; diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..81b7f84 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,7 @@ +import Button from "./Button"; +import Form from "./Form"; +import Input from "./Input"; +import message from "./message"; +import Spinner from "./Spinner"; + +export { Button, Form, Input, message, Spinner }; diff --git a/src/components/message/base.ts b/src/components/message/base.ts new file mode 100644 index 0000000..eb5af12 --- /dev/null +++ b/src/components/message/base.ts @@ -0,0 +1,32 @@ +import icons from "./icons"; + +export const createMessage = ( + msg: string, + type: "info" | "success" | "warning" | "error" +): void => { + const msgBoxes = document.getElementsByClassName("void-message-box"); + let msgBox: Element; + console.log({ msgBoxes }); + if (msgBoxes[0]) { + msgBox = msgBoxes[0]; + } else { + msgBox = document.createElement("div"); + msgBox.className = "void-message-box"; + document.body.appendChild(msgBox); + } + + const msgDiv = document.createElement("div"); + msgDiv.className = `void-message void-message-${type}`; + const msgText = document.createElement("p"); + msgText.className = "void-message-text"; + msgText.innerText = msg; + const msgIcon = document.createElement("div"); + msgIcon.className = "void-message-icon"; + msgIcon.innerHTML = icons[type]; + msgDiv.appendChild(msgIcon); + msgDiv.appendChild(msgText); + msgBox.appendChild(msgDiv); + setTimeout(() => { + msgBox.removeChild(msgDiv); + }, 5000); +}; diff --git a/src/components/message/icons.ts b/src/components/message/icons.ts new file mode 100644 index 0000000..850eb15 --- /dev/null +++ b/src/components/message/icons.ts @@ -0,0 +1,8 @@ +const icons = { + success: ``, + warning: ``, + error: ``, + info: ``, +}; + +export default icons; diff --git a/src/components/message/index.ts b/src/components/message/index.ts new file mode 100644 index 0000000..949f9ff --- /dev/null +++ b/src/components/message/index.ts @@ -0,0 +1,13 @@ +import { createMessage } from "./base"; + +const message: { + success: (msg: string) => void; + error: (msg: string) => void; + warning: (msg: string) => void; +} = { + success: (msg: string) => createMessage(msg, "success"), + error: (msg: string) => createMessage(msg, "error"), + warning: (msg: string) => createMessage(msg, "warning"), +}; + +export default message; diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..55b725c --- /dev/null +++ b/src/index.css @@ -0,0 +1,11 @@ +* { + box-sizing: border-box; + margin: 0; +} + +@import url("./styles/common/colors.css"); + +@import url("./styles/button.css"); +@import url("./styles/input.css"); +@import url("./styles/message.css"); +@import url("./styles/spinner.css"); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..e4cede3 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export { Button, Form, Input, message } from "./components"; diff --git a/src/styles/button.css b/src/styles/button.css new file mode 100644 index 0000000..c3d2a9d --- /dev/null +++ b/src/styles/button.css @@ -0,0 +1,150 @@ +.void-btn { + background-color: transparent; + border: none; + outline: none; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + font-weight: 500; + border-width: 1.5px; + border-style: solid; + border-color: transparent; + margin: 5px; + padding: 5px 20px; +} + +/* start: size */ +.void-btn-large { + height: 48px; + min-width: 120px; + font-size: 14px; +} +.void-btn-medium { + height: 38px; + min-width: 120px; + font-size: 13.5px; +} +.void-btn-small { + height: 30px; + min-width: 120px; + font-size: 13px; +} +/* end: size */ + +/* start: theme-structure */ +/* start: primary */ +.void-btn-primary-solid { + border-color: var(--primaryColor); + background-color: var(--primaryColor); + color: white; +} +.void-btn-primary-liquid { + border-color: var(--primaryColor); + background-color: white; + color: var(--primaryColor); +} +.void-btn-primary-gas { + border-color: white; + background-color: white; + color: var(--primaryColor); +} +/* end: primary */ + +/* start: secondary */ +.void-btn-secondary-solid { + border-color: var(--secondaryColor); + background-color: var(--secondaryColor); + color: white; +} +.void-btn-secondary-liquid { + border-color: var(--secondaryColor); + background-color: white; + color: var(--secondaryColor); +} +.void-btn-secondary-gas { + border-color: white; + background-color: white; + color: var(--secondaryColor); +} +/* end: secondary */ + +/* start: success */ +.void-btn-success-solid { + border-color: var(--successColor); + background-color: var(--successColor); + color: white; +} +.void-btn-success-liquid { + border-color: var(--successColor); + background-color: white; + color: var(--successColor); +} +.void-btn-success-gas { + border-color: white; + background-color: white; + color: var(--successColor); +} +/* end: success */ + +/* start: warning */ +.void-btn-warning-solid { + border-color: var(--warningColor); + background-color: var(--warningColor); + color: white; +} +.void-btn-warning-liquid { + border-color: var(--warningColor); + background-color: white; + color: var(--warningColor); +} +.void-btn-warning-gas { + border-color: white; + background-color: white; + color: var(--warningColor); +} +/* end: warning */ + +/* start: error */ +.void-btn-error-solid { + border-color: var(--errorColor); + background-color: var(--errorColor); + color: white; +} +.void-btn-error-liquid { + border-color: var(--errorColor); + background-color: white; + color: var(--errorColor); +} +.void-btn-error-gas { + border-color: white; + background-color: white; + color: var(--errorColor); +} +/* end: error */ + +/* end: theme-structure */ + +/* start: shape */ +.void-btn-rectangle { + border-radius: 4px; +} +.void-btn-rounded { + border-radius: 1000px; +} +/* end: shape */ + +/* start: loading | disabled */ +.void-btn-disabled, +.void-btn-loading { + opacity: 0.7; +} +.void-btn-disabled { + cursor: not-allowed; +} +.void-btn-loading { + cursor: progress; + padding: 5px 10px; + min-width: 200px; +} +/* end: loading | disabled */ diff --git a/src/styles/common/colors.css b/src/styles/common/colors.css new file mode 100644 index 0000000..d9f5da0 --- /dev/null +++ b/src/styles/common/colors.css @@ -0,0 +1,16 @@ +:root { + --primaryColor: #1e90ff; + --primaryColorLight: #1e90ff22; + + --secondaryColor: #ff1493; + --secondaryColorLight: #ff149223; + + --successColor: #13b685; + --successColorLight: #d8f8ef; + + --warningColor: #ffa500; + --warningColorLight: #fff5dd; + + --errorColor: #ff6347; + --errorColorLight: #ff634722; +} diff --git a/src/styles/input.css b/src/styles/input.css new file mode 100644 index 0000000..52f23e7 --- /dev/null +++ b/src/styles/input.css @@ -0,0 +1,24 @@ +/* START: Input */ +.void-input-wrapper p { + font-size: 16px; + margin: 5px; +} +.void-input { + height: 45px; + width: 100%; + border-radius: 5px; + padding: 5px 10px; + border: 1.5px solid #c8c8c8; + outline: none; + transition: all ease-in-out 0.4s; + margin: 5px; +} +.void-input:hover { + border-width: 2px; +} +.void-input:active, +.void-input:focus { + box-shadow: 0px 0px 10px 1px #dddddd; +} + +/* END: Input */ diff --git a/src/styles/message.css b/src/styles/message.css new file mode 100644 index 0000000..45bd6ac --- /dev/null +++ b/src/styles/message.css @@ -0,0 +1,92 @@ +.void-message { + --messageTime: 5s; +} +.void-message-box { + position: absolute; + top: 0; + height: fit-content; + width: fit-content; + margin-left: auto; + margin-right: auto; + left: 0; + right: 0; +} +.void-message { + min-width: 200px; + box-sizing: border-box; + /* max-width: 350px; */ + width: fit-content; + border-radius: 4px; + min-height: 30px; + height: fit-content; + padding: 10px; + color: black; + display: flex; + align-items: center; + justify-content: center; + animation: slideIn var(--messageTime) forwards; + border: 0px solid transparent; + box-shadow: 5px 5px 20px 7px whitesmoke; + margin-top: 10px; +} +.void-message-icon { + display: flex; + align-items: center; + justify-content: center; + height: 18px; + width: 18px; + margin: 0 10px; + padding: 2px; + border-radius: 1000px; + color: white; +} +.void-message-icon svg { + font-weight: 900; + height: 24px; + width: 24px; + stroke-width: 3px; + /* fill: white; */ +} +.void-message-text { + width: 100%; + /* text-align: center; */ + font-size: 13px; + margin: 0 10px; + overflow-wrap: break-word; +} +.void-message-success { + background-color: var(--successColorLight); + border-color: var(--successColor); +} +.void-message-success .void-message-icon { + background-color: var(--successColor); +} +.void-message-warning { + background-color: var(--warningColorLight); + border-color: var(--warningColor); +} +.void-message-warning .void-message-icon { + background-color: var(--warningColor); +} +.void-message-error { + background-color: var(--errorColorLight); + border-color: var(--errorColor); +} +.void-message-error .void-message-icon { + background-color: var(--errorColor); +} + +@keyframes slideIn { + 0% { + margin-top: -1000px; + } + 5% { + margin-top: 10px; + } + 95% { + margin-top: 10px; + } + 100% { + margin-top: -1000px; + } +} diff --git a/src/styles/spinner.css b/src/styles/spinner.css new file mode 100644 index 0000000..4f77851 --- /dev/null +++ b/src/styles/spinner.css @@ -0,0 +1,35 @@ +.void-spinner { + height: 40px; + width: auto; +} +.void-spinner-large { + height: 60px; +} +.void-spinner-medium { + height: 40px; +} +.void-spinner-small { + height: 25px; +} +.void-spinner-tiny { + height: 20px; +} + +svg.void-spinner-normal path { + fill: #fff; +} +svg.void-spinner-primary path { + fill: var(--primaryColor); +} +svg.void-spinner-secondary path { + fill: var(--secondaryColor); +} +svg.void-spinner-success path { + fill: var(--successColor); +} +svg.void-spinner-warning path { + fill: var(--warningColor); +} +svg.void-spinner-error path { + fill: var(--errorColor); +} diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..1921998 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,4 @@ +export type ComponentTypes = { + className?: string; + style?: React.CSSProperties; +}; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..c125afd --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,3 @@ +import getType from "./type"; + +export { getType }; diff --git a/src/utils/type.ts b/src/utils/type.ts new file mode 100644 index 0000000..c57564e --- /dev/null +++ b/src/utils/type.ts @@ -0,0 +1,12 @@ +type types = "number" | "string" | "object" | "array" | "undefined" | "null"; + +const getType = (fieldValue: any): types => { + return Object.prototype.toString + .call(fieldValue) + .replace("[", "") + .replace("]", "") + .split(" ")[1] + .toLowerCase(); +}; + +export default getType; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..634d811 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "outDir": "lib/esm", + "module": "esnext", + "target": "es5", + "lib": ["es6", "dom", "es2016", "es2017"], + "jsx": "react", + "declaration": true, + "moduleResolution": "node", + "noUnusedLocals": true, + "noUnusedParameters": true, + "esModuleInterop": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noImplicitAny": true, + "strictNullChecks": true, + "suppressImplicitAnyIndexErrors": true, + "allowSyntheticDefaultImports": true + }, + "include": ["src"], + "exclude": ["node_modules", "lib"] +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..32b9e12 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + resolve: { + extensions: [".ts", ".tsx", ".js", ".jsx"], + }, +};