Skip to content

Commit

Permalink
feat: v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-dan-unni committed Jul 6, 2022
1 parent 1e80aad commit 35a97f4
Show file tree
Hide file tree
Showing 44 changed files with 1,040 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
lib
build
*.lock
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!lib/**/*
lib/cjs
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Void Design

A hybrid package of UI elements for ReactJS, from [void](https://github.com/void-verse)

<br />

## What's new (v1.0.2)

- Reduced package size by 95%

<br />

## Installation

- :arrow_down: Install the package

```bash
yarn add void-design
```

<br />

- :spiral_notepad: Import the CSS file

```js
import "void-design/lib/void.css";
```

<br />

- :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 (
<div>
<Input placeholder="Enter your name" />
</div>
);
};

export default App;
```
70 changes: 70 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 40 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Binary file added example/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions example/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Webapp for testing Void Design" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Testing Void Design</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Binary file added example/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions example/public/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
3 changes: 3 additions & 0 deletions example/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
50 changes: 50 additions & 0 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -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 (
<div style={{ margin: "50px" }}>
<Button
theme="success"
onClick={() => message.success("Successfully completed")}
>
Success Here!
</Button>
<Button theme="warning" onClick={() => message.warning("Its a warning")}>
Warning Here!
</Button>
<Button theme="error" onClick={() => message.error("Some error occured")}>
Error Here!
</Button>
<Form onSubmit={(values) => window.alert(JSON.stringify(values))}>
<Input label="Name" name="name" placeholder="Enter your name" />
<div style={{ display: "flex", flexWrap: "wrap", width: "90vw" }}>
{["primary", "secondary", "success", "warning", "error"].map(
(theme, i) => (
<div style={{ display: "flex", flexWrap: "wrap", width: "50vw" }}>
{["large", "medium", "small"].map((size, j) => (
<div style={{ display: "flex", minWidth: "690px" }}>
{["solid", "liquid", "gas"].map((structure) => (
<Button
theme={theme}
loading={j % 2 === 0 && i % 2 === 0}
disabled={j % 3 === 0 && i % 3 === 0}
size={size}
structure={structure}
>
{theme} {size} {structure}
</Button>
))}
</div>
))}
</div>
)
)}
</div>
</Form>
</div>
);
};

export default App;
13 changes: 13 additions & 0 deletions example/src/index.css
Original file line number Diff line number Diff line change
@@ -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;
}
13 changes: 13 additions & 0 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -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(
<StrictMode>
<App />
</StrictMode>
);

reportWebVitals();
13 changes: 13 additions & 0 deletions example/src/reportWebVitals.js
Original file line number Diff line number Diff line change
@@ -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;
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"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"
}
}
57 changes: 57 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -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 ? <a href={href}>{children}</a> : 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 (
<ButtonWrapper>
<button
className={`${generateClassName()}`}
onClick={disabled || loading ? () => {} : onClick}
type={disabled ? "button" : type}
>
{loading && (
<>
<Spinner
theme={structure === "solid" ? "normal" : theme}
size={size === "large" ? "small" : "tiny"}
/>
&nbsp; &nbsp;
</>
)}
{children}
</button>
</ButtonWrapper>
);
};

export default Button;
Loading

0 comments on commit 35a97f4

Please sign in to comment.