umwd-components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ /** @type { import('@storybook/react-webpack5').StorybookConfig } */
2
+ const config = {
3
+ stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
4
+ addons: [
5
+ "@storybook/addon-links",
6
+ "@storybook/addon-essentials",
7
+ "@storybook/preset-create-react-app",
8
+ "@storybook/addon-onboarding",
9
+ "@storybook/addon-interactions",
10
+ ],
11
+ framework: {
12
+ name: "@storybook/react-webpack5",
13
+ options: {},
14
+ },
15
+ docs: {
16
+ autodocs: "tag",
17
+ },
18
+ staticDirs: ["..\\public"],
19
+ };
20
+ export default config;
@@ -0,0 +1,14 @@
1
+ /** @type { import('@storybook/react').Preview } */
2
+ const preview = {
3
+ parameters: {
4
+ actions: { argTypesRegex: "^on[A-Z].*" },
5
+ controls: {
6
+ matchers: {
7
+ color: /(background|color)$/i,
8
+ date: /Date$/i,
9
+ },
10
+ },
11
+ },
12
+ };
13
+
14
+ export default preview;
@@ -0,0 +1,7 @@
1
+ {
2
+ "workbench.colorCustomizations": {
3
+ "activityBar.background": "#113517",
4
+ "titleBar.activeBackground": "#174A20",
5
+ "titleBar.activeForeground": "#F5FCF6"
6
+ }
7
+ }
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ 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.
37
+
38
+ 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.
39
+
40
+ 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.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ 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)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ 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)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ 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)
59
+
60
+ ### Advanced Configuration
61
+
62
+ 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)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ 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)
@@ -0,0 +1 @@
1
+ import e,{useState as t,useEffect as a,useCallback as r}from"react";!function(e,t){void 0===t&&(t={});var a=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css","top"===a&&r.firstChild?r.insertBefore(c,r.firstChild):r.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e))}}(".requirement{align-items:center;display:flex;height:35px}.requirement p{font-family:sans-serif;font-size:14px;font-weight:700;margin-left:10px}.invalid{color:red}.valid{color:#7ac142}.checkmark{stroke-width:5;stroke:#fff;stroke-miterlimit:10;animation:fill .4s ease-in-out .4s forwards,scale .3s ease-in-out .9s both;border-radius:50%;box-shadow:inset 0 0 0 #7ac142;display:block;height:15px;width:15px}.checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;fill:none;animation:stroke .6s cubic-bezier(.65,0,.45,1) forwards}.checkmark__check{stroke-dasharray:48;stroke-dashoffset:48;animation:stroke .2s cubic-bezier(.65,0,.45,1) .5s forwards;transform-origin:50% 50%}@keyframes stroke{to{stroke-dashoffset:0}}@keyframes scale{0%,to{transform:none}50%{transform:scale3d(1.1,1.1,1)}}@keyframes fill{to{box-shadow:inset 0 0 0 30px #7ac142}}");const c=()=>e.createElement("svg",{x:"0px",y:"0px",width:"15px",height:"15px",viewBox:"0 0 122.879 122.879",enableBackground:"new 0 0 122.879 122.879"},e.createElement("g",null,e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FF4141",d:"M61.44,0c33.933,0,61.439,27.507,61.439,61.439 s-27.506,61.439-61.439,61.439C27.507,122.879,0,95.372,0,61.439S27.507,0,61.44,0L61.44,0z M73.451,39.151 c2.75-2.793,7.221-2.805,9.986-0.027c2.764,2.776,2.775,7.292,0.027,10.083L71.4,61.445l12.076,12.249 c2.729,2.77,2.689,7.257-0.08,10.022c-2.773,2.765-7.23,2.758-9.955-0.013L61.446,71.54L49.428,83.728 c-2.75,2.793-7.22,2.805-9.986,0.027c-2.763-2.776-2.776-7.293-0.027-10.084L51.48,61.434L39.403,49.185 c-2.728-2.769-2.689-7.256,0.082-10.022c2.772-2.765,7.229-2.758,9.953,0.013l11.997,12.165L73.451,39.151L73.451,39.151z"}))),s=()=>e.createElement("svg",{className:"checkmark",viewBox:"0 0 52 52"},e.createElement("circle",{className:"checkmark__circle",cx:"26",cy:"26",r:"25",fill:"none"}),e.createElement("path",{className:"checkmark__check",fill:"none",d:"M14.1 27.2l7.1 7.2 16.7-16.8"})),i=({value:e,requirement:r})=>{const[i,l]=t();return a((()=>{l(r.validator(e))}),[e,r]),React.createElement("div",{className:"requirement"},i?React.createElement(s,null):React.createElement(c,null),React.createElement("p",{className:i?"valid":"invalid"},r.text))},l=({value:e,requirements:t,onValidChange:c})=>{const s=r(c,[]);return a((()=>{s(t.every((t=>t.validator(e))))}),[e,t,s]),t.map(((t,a)=>React.createElement(i,{key:a,value:e,requirement:t,onValidChange:c})))};export{l as Requirements};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e);!function(e,t){void 0===t&&(t={});var a=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===a&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}(".requirement{align-items:center;display:flex;height:35px}.requirement p{font-family:sans-serif;font-size:14px;font-weight:700;margin-left:10px}.invalid{color:red}.valid{color:#7ac142}.checkmark{stroke-width:5;stroke:#fff;stroke-miterlimit:10;animation:fill .4s ease-in-out .4s forwards,scale .3s ease-in-out .9s both;border-radius:50%;box-shadow:inset 0 0 0 #7ac142;display:block;height:15px;width:15px}.checkmark__circle{stroke-dasharray:166;stroke-dashoffset:166;stroke-width:2;stroke-miterlimit:10;stroke:#7ac142;fill:none;animation:stroke .6s cubic-bezier(.65,0,.45,1) forwards}.checkmark__check{stroke-dasharray:48;stroke-dashoffset:48;animation:stroke .2s cubic-bezier(.65,0,.45,1) .5s forwards;transform-origin:50% 50%}@keyframes stroke{to{stroke-dashoffset:0}}@keyframes scale{0%,to{transform:none}50%{transform:scale3d(1.1,1.1,1)}}@keyframes fill{to{box-shadow:inset 0 0 0 30px #7ac142}}");const r=()=>a.default.createElement("svg",{x:"0px",y:"0px",width:"15px",height:"15px",viewBox:"0 0 122.879 122.879",enableBackground:"new 0 0 122.879 122.879"},a.default.createElement("g",null,a.default.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FF4141",d:"M61.44,0c33.933,0,61.439,27.507,61.439,61.439 s-27.506,61.439-61.439,61.439C27.507,122.879,0,95.372,0,61.439S27.507,0,61.44,0L61.44,0z M73.451,39.151 c2.75-2.793,7.221-2.805,9.986-0.027c2.764,2.776,2.775,7.292,0.027,10.083L71.4,61.445l12.076,12.249 c2.729,2.77,2.689,7.257-0.08,10.022c-2.773,2.765-7.23,2.758-9.955-0.013L61.446,71.54L49.428,83.728 c-2.75,2.793-7.22,2.805-9.986,0.027c-2.763-2.776-2.776-7.293-0.027-10.084L51.48,61.434L39.403,49.185 c-2.728-2.769-2.689-7.256,0.082-10.022c2.772-2.765,7.229-2.758,9.953,0.013l11.997,12.165L73.451,39.151L73.451,39.151z"}))),s=()=>a.default.createElement("svg",{className:"checkmark",viewBox:"0 0 52 52"},a.default.createElement("circle",{className:"checkmark__circle",cx:"26",cy:"26",r:"25",fill:"none"}),a.default.createElement("path",{className:"checkmark__check",fill:"none",d:"M14.1 27.2l7.1 7.2 16.7-16.8"})),c=({value:t,requirement:a})=>{const[c,l]=e.useState();return e.useEffect((()=>{l(a.validator(t))}),[t,a]),React.createElement("div",{className:"requirement"},c?React.createElement(s,null):React.createElement(r,null),React.createElement("p",{className:c?"valid":"invalid"},a.text))};exports.Requirements=({value:t,requirements:a,onValidChange:r})=>{const s=e.useCallback(r,[]);return e.useEffect((()=>{s(a.every((e=>e.validator(t))))}),[t,a,s]),a.map(((e,a)=>React.createElement(c,{key:a,value:t,requirement:e,onValidChange:r})))};
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "umwd-components",
3
+ "version": "0.1.0",
4
+ "description": "UMWD Component library",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.es.js",
7
+ "scripts": {
8
+ "start": "react-scripts start",
9
+ "build": "react-scripts build",
10
+ "test": "react-scripts test",
11
+ "eject": "react-scripts eject",
12
+ "storybook": "storybook dev -p 6006",
13
+ "build-storybook": "storybook build",
14
+ "build-lib": "rollup -c"
15
+ },
16
+ "eslintConfig": {
17
+ "extends": [
18
+ "react-app",
19
+ "react-app/jest",
20
+ "plugin:storybook/recommended"
21
+ ]
22
+ },
23
+ "browserslist": {
24
+ "production": [
25
+ ">0.2%",
26
+ "not dead",
27
+ "not op_mini all"
28
+ ],
29
+ "development": [
30
+ "last 1 chrome version",
31
+ "last 1 firefox version",
32
+ "last 1 safari version"
33
+ ]
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-babel": "^6.0.4",
37
+ "@rollup/plugin-node-resolve": "^15.2.3",
38
+ "@storybook/addon-essentials": "^7.5.3",
39
+ "@storybook/addon-interactions": "^7.5.3",
40
+ "@storybook/addon-links": "^7.5.3",
41
+ "@storybook/addon-onboarding": "^1.0.8",
42
+ "@storybook/blocks": "^7.5.3",
43
+ "@storybook/preset-create-react-app": "^7.5.3",
44
+ "@storybook/react": "^7.5.3",
45
+ "@storybook/react-webpack5": "^7.5.3",
46
+ "@storybook/testing-library": "^0.2.2",
47
+ "@testing-library/jest-dom": "^5.17.0",
48
+ "@testing-library/react": "^13.4.0",
49
+ "@testing-library/user-event": "^13.5.0",
50
+ "babel-plugin-named-exports-order": "^0.0.2",
51
+ "eslint-plugin-storybook": "^0.6.15",
52
+ "prop-types": "^15.8.1",
53
+ "react": "^18.2.0",
54
+ "react-dom": "^18.2.0",
55
+ "react-scripts": "5.0.1",
56
+ "rollup": "^2.79.1",
57
+ "rollup-plugin-peer-deps-external": "^2.2.4",
58
+ "rollup-plugin-postcss": "^4.0.2",
59
+ "rollup-plugin-terser": "^7.0.2",
60
+ "storybook": "^7.5.3",
61
+ "web-vitals": "^2.1.4",
62
+ "webpack": "^5.89.0"
63
+ },
64
+ "peerDependencies": {
65
+ "react": "^18.2.0",
66
+ "react-dom": "^18.2.0"
67
+ }
68
+ }
Binary file
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,35 @@
1
+ import babel from "@rollup/plugin-babel";
2
+ import resolve from "@rollup/plugin-node-resolve";
3
+ import external from "rollup-plugin-peer-deps-external";
4
+ import { terser } from "rollup-plugin-terser";
5
+ import postcss from "rollup-plugin-postcss";
6
+
7
+ export default [
8
+ {
9
+ input: "./src/index.js",
10
+ output: [
11
+ {
12
+ file: "dist/index.js",
13
+ format: "cjs",
14
+ },
15
+ {
16
+ file: "dist/index.es.js",
17
+ format: "es",
18
+ exports: "named",
19
+ },
20
+ ],
21
+ plugins: [
22
+ postcss({
23
+ plugins: [],
24
+ minimize: true,
25
+ }),
26
+ babel({
27
+ exclude: "node_modules/**",
28
+ presets: ["@babel/preset-react"],
29
+ }),
30
+ external(),
31
+ resolve(),
32
+ terser(),
33
+ ],
34
+ },
35
+ ];
@@ -0,0 +1,30 @@
1
+ import PropTypes from "prop-types";
2
+
3
+ function Button({ label, backgroundColor = "red", size = "md", onClick }) {
4
+ let scale = 1;
5
+ if (size === "sm") {
6
+ scale = 0.75;
7
+ }
8
+ if (size === "lg") {
9
+ scale = 1.25;
10
+ }
11
+ const style = {
12
+ backgroundColor,
13
+ padding: `${0.5 * scale}rem ${1 * scale}rem`,
14
+ border: "none",
15
+ };
16
+ return (
17
+ <button style={style} onClick={onClick}>
18
+ {label}
19
+ </button>
20
+ );
21
+ }
22
+
23
+ Button.propTypes = {
24
+ label: PropTypes.string,
25
+ backgroundColor: PropTypes.string,
26
+ size: PropTypes.oneOf(["sm", "md", "lg"]),
27
+ onClick: PropTypes.func,
28
+ };
29
+
30
+ export default Button;
@@ -0,0 +1,21 @@
1
+ // Ported from Alexander Haniotis' code here: https://codepen.io/haniotis/pen/KwvYLO
2
+ import React from "react";
3
+
4
+ export const Checkmark = () => {
5
+ return (
6
+ <svg className="checkmark" viewBox="0 0 52 52">
7
+ <circle
8
+ className="checkmark__circle"
9
+ cx="26"
10
+ cy="26"
11
+ r="25"
12
+ fill="none"
13
+ />
14
+ <path
15
+ className="checkmark__check"
16
+ fill="none"
17
+ d="M14.1 27.2l7.1 7.2 16.7-16.8"
18
+ />
19
+ </svg>
20
+ );
21
+ };
@@ -0,0 +1 @@
1
+ export * from "./Checkmark";
@@ -0,0 +1,19 @@
1
+ import { Xmark } from "../Xmark";
2
+ import { Checkmark } from "../Checkmark";
3
+ import { useEffect, useState } from "react";
4
+
5
+ export const Requirement = ({ value, requirement }) => {
6
+ const [isValid, setIsValid] = useState();
7
+
8
+ useEffect(() => {
9
+ setIsValid(requirement.validator(value));
10
+ }, [value, requirement]);
11
+
12
+ return (
13
+ <div className="requirement">
14
+ {isValid ? <Checkmark /> : <Xmark />}
15
+
16
+ <p className={isValid ? "valid" : "invalid"}>{requirement.text}</p>
17
+ </div>
18
+ );
19
+ };
@@ -0,0 +1 @@
1
+ export * from "./Requirement";
@@ -0,0 +1,20 @@
1
+ import "../../styles.css";
2
+ import { Requirement } from "../Requirement";
3
+ import { useCallback, useEffect } from "react";
4
+
5
+ export const Requirements = ({ value, requirements, onValidChange }) => {
6
+ const validChangeCb = useCallback(onValidChange, []);
7
+
8
+ useEffect(() => {
9
+ validChangeCb(requirements.every((r) => r.validator(value)));
10
+ }, [value, requirements, validChangeCb]);
11
+
12
+ return requirements.map((r, index) => (
13
+ <Requirement
14
+ key={index}
15
+ value={value}
16
+ requirement={r}
17
+ onValidChange={onValidChange}
18
+ />
19
+ ));
20
+ };
@@ -0,0 +1 @@
1
+ export * from "./Requirements";
@@ -0,0 +1,19 @@
1
+ import PropTypes from "prop-types";
2
+
3
+ function Stack({ children, spacing = 2, direction = "row", wrap = false }) {
4
+ const style = {
5
+ display: "flex",
6
+ gap: `${spacing * 0.25}rem`,
7
+ flexWrap: wrap ? "wrap" : "nowrap",
8
+ flexDirection: direction,
9
+ };
10
+ return <div style={style}>{children}</div>;
11
+ }
12
+
13
+ Stack.propTypes = {
14
+ spacing: PropTypes.number,
15
+ wrap: PropTypes.bool,
16
+ direction: PropTypes.oneOf(["row", "column"]),
17
+ };
18
+
19
+ export default Stack;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ export const Xmark = () => {
4
+ return (
5
+ <svg
6
+ x="0px"
7
+ y="0px"
8
+ width="15px"
9
+ height="15px"
10
+ viewBox="0 0 122.879 122.879"
11
+ enableBackground="new 0 0 122.879 122.879"
12
+ >
13
+ <g>
14
+ <path
15
+ fillRule="evenodd"
16
+ clipRule="evenodd"
17
+ fill="#FF4141"
18
+ d="M61.44,0c33.933,0,61.439,27.507,61.439,61.439 s-27.506,61.439-61.439,61.439C27.507,122.879,0,95.372,0,61.439S27.507,0,61.44,0L61.44,0z M73.451,39.151 c2.75-2.793,7.221-2.805,9.986-0.027c2.764,2.776,2.775,7.292,0.027,10.083L71.4,61.445l12.076,12.249 c2.729,2.77,2.689,7.257-0.08,10.022c-2.773,2.765-7.23,2.758-9.955-0.013L61.446,71.54L49.428,83.728 c-2.75,2.793-7.22,2.805-9.986,0.027c-2.763-2.776-2.776-7.293-0.027-10.084L51.48,61.434L39.403,49.185 c-2.728-2.769-2.689-7.256,0.082-10.022c2.772-2.765,7.229-2.758,9.953,0.013l11.997,12.165L73.451,39.151L73.451,39.151z"
19
+ />
20
+ </g>
21
+ </svg>
22
+ );
23
+ };
@@ -0,0 +1 @@
1
+ export * from "./Xmark";
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ //export all components from this file
2
+ export * from "./components/Requirements";
@@ -0,0 +1,57 @@
1
+ import Button from "../components/Button";
2
+
3
+ export default {
4
+ title: "Web Dev Simplified/Button",
5
+ component: Button,
6
+ argTypes: { onClick: { action: "was clicked" } },
7
+ };
8
+
9
+ const Template = (args) => <Button {...args} />;
10
+
11
+ export const Red = Template.bind({});
12
+
13
+ Red.args = {
14
+ label: "Press me",
15
+ backgroundColor: "red",
16
+ size: "md",
17
+ };
18
+
19
+ export const Yellow = Template.bind({});
20
+
21
+ Yellow.args = {
22
+ label: "Press me",
23
+ backgroundColor: "yellow",
24
+ size: "md",
25
+ };
26
+
27
+ export const Green = Template.bind({});
28
+
29
+ Green.args = {
30
+ label: "Press me",
31
+ backgroundColor: "green",
32
+ size: "md",
33
+ };
34
+
35
+ export const Blue = Template.bind({});
36
+
37
+ Blue.args = {
38
+ label: "Press me",
39
+ backgroundColor: "blue",
40
+ size: "md",
41
+ };
42
+
43
+ export const Small = Template.bind({});
44
+
45
+ Small.args = {
46
+ label: "Press me",
47
+ backgroundColor: "blue",
48
+ size: "sm",
49
+ };
50
+
51
+ export const Large = Template.bind({});
52
+
53
+ Large.args = {
54
+ label: "Press me",
55
+ backgroundColor: "blue",
56
+ size: "lg",
57
+ };
@@ -0,0 +1,61 @@
1
+ import { useState } from "react";
2
+ import "./styles.css";
3
+ import { Requirements } from "../components/Requirements";
4
+
5
+ export default {
6
+ title: "PortEXE/Requirements",
7
+ component: Requirements,
8
+ };
9
+
10
+ const RequirementsWithHooks = () => {
11
+ const [valid, setValid] = useState(false);
12
+ const [password, setPassword] = useState("");
13
+ const [username, setUsername] = useState("");
14
+
15
+ const passwordRequirements = [
16
+ {
17
+ text: "Must be at least 8 characters long",
18
+ validator: (val) => val.length >= 8,
19
+ },
20
+ {
21
+ text: "Must contain at least one number",
22
+ validator: (val) => /\d/g.test(val),
23
+ },
24
+ {
25
+ text: "Must contain at least one lower-case letter",
26
+ validator: (val) => /[a-z]/g.test(val),
27
+ },
28
+ {
29
+ text: "Must contain at least one upper-case letter",
30
+ validator: (val) => /[A-Z]/g.test(val),
31
+ },
32
+ ];
33
+
34
+ return (
35
+ <div className="form">
36
+ <h1>Signup</h1>
37
+ <Requirements
38
+ value={password}
39
+ requirements={passwordRequirements}
40
+ onValidChange={(isValid) => setValid(isValid)}
41
+ />
42
+ <input
43
+ type="text"
44
+ placeholder="Username"
45
+ value={username}
46
+ onChange={(e) => setUsername(e.target.value)}
47
+ />
48
+ <input
49
+ type="password"
50
+ placeholder="Password"
51
+ value={password}
52
+ onChange={(e) => setPassword(e.target.value)}
53
+ />
54
+ <button disabled={!valid || !username}>Signup</button>
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export const Default = {
60
+ render: () => <RequirementsWithHooks />,
61
+ };
@@ -0,0 +1,71 @@
1
+ import Stack from "../components/Stack";
2
+
3
+ export default {
4
+ title: "Web Dev Simplified/Stack",
5
+ component: Stack,
6
+ argTypes: { numberOfChildren: { type: "number" } },
7
+ };
8
+
9
+ const Template = ({ numberOfChildren, ...args }) => (
10
+ <Stack {...args}>
11
+ {[...Array(numberOfChildren).keys()].map((n) => (
12
+ <div
13
+ style={{
14
+ width: "50px",
15
+ height: "50px",
16
+ backgroundColor: "red",
17
+ display: "flex",
18
+ justifyContent: "center",
19
+ alignItems: "center",
20
+ }}
21
+ >
22
+ {n + 1}
23
+ </div>
24
+ ))}
25
+ </Stack>
26
+ );
27
+
28
+ export const Horizontal = Template.bind({});
29
+
30
+ Horizontal.args = {
31
+ direction: "row",
32
+ spacing: 2,
33
+ wrap: false,
34
+ numberOfChildren: 5,
35
+ };
36
+
37
+ export const Vertical = Template.bind({});
38
+
39
+ Vertical.args = {
40
+ direction: "column",
41
+ spacing: 2,
42
+ wrap: false,
43
+ numberOfChildren: 5,
44
+ };
45
+
46
+ export const NoSpacing = Template.bind({});
47
+
48
+ NoSpacing.args = {
49
+ direction: "row",
50
+ spacing: 0,
51
+ wrap: false,
52
+ numberOfChildren: 5,
53
+ };
54
+
55
+ export const WrapOverflow = Template.bind({});
56
+
57
+ WrapOverflow.args = {
58
+ direction: "row",
59
+ spacing: 2,
60
+ wrap: true,
61
+ numberOfChildren: 40,
62
+ };
63
+
64
+ export const Empty = Template.bind({});
65
+
66
+ Empty.args = {
67
+ direction: "row",
68
+ spacing: 2,
69
+ wrap: false,
70
+ numberOfChildren: 0,
71
+ };
@@ -0,0 +1,35 @@
1
+ .form {
2
+ width: 500px;
3
+ padding: 25px;
4
+ border-radius: 5px;
5
+ padding-bottom: 50px;
6
+ box-shadow: 0px 0px 5px gray;
7
+ }
8
+ .form input {
9
+ width: 100%;
10
+ border: none;
11
+ padding: 8px;
12
+ outline: none;
13
+ margin-top: 25px;
14
+ border-radius: 5px;
15
+ box-sizing: border-box;
16
+ box-shadow: 0px 0px 3px gray;
17
+ }
18
+ .form button {
19
+ width: 100%;
20
+ padding: 8px;
21
+ border: none;
22
+ outline: none;
23
+ color: white;
24
+ margin-top: 25px;
25
+ border-radius: 5px;
26
+ box-sizing: border-box;
27
+ background-color: rgb(65, 65, 201);
28
+ }
29
+ .form button:disabled {
30
+ cursor: not-allowed;
31
+ background-color: lightgray;
32
+ }
33
+ .form h1 {
34
+ font-family: sans-serif;
35
+ }
package/src/styles.css ADDED
@@ -0,0 +1,70 @@
1
+ .requirement {
2
+ height: 35px;
3
+ display: flex;
4
+ align-items: center;
5
+ }
6
+ .requirement p {
7
+ font-size: 14px;
8
+ margin-left: 10px;
9
+ font-weight: bold;
10
+ font-family: sans-serif;
11
+ }
12
+ .invalid {
13
+ color: red;
14
+ }
15
+ .valid {
16
+ color: #7ac142;
17
+ }
18
+
19
+ /* Ported from Alexander Haniotis' code here: https://codepen.io/haniotis/pen/KwvYLO */
20
+ .checkmark {
21
+ width: 15px;
22
+ height: 15px;
23
+ border-radius: 50%;
24
+ display: block;
25
+ stroke-width: 5;
26
+ stroke: #fff;
27
+ stroke-miterlimit: 10;
28
+ box-shadow: inset 0px 0px 0px #7ac142;
29
+ animation: fill 0.4s ease-in-out 0.4s forwards,
30
+ scale 0.3s ease-in-out 0.9s both;
31
+ }
32
+
33
+ .checkmark__circle {
34
+ stroke-dasharray: 166;
35
+ stroke-dashoffset: 166;
36
+ stroke-width: 2;
37
+ stroke-miterlimit: 10;
38
+ stroke: #7ac142;
39
+ fill: none;
40
+ animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
41
+ }
42
+
43
+ .checkmark__check {
44
+ transform-origin: 50% 50%;
45
+ stroke-dasharray: 48;
46
+ stroke-dashoffset: 48;
47
+ animation: stroke 0.2s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
48
+ }
49
+
50
+ @keyframes stroke {
51
+ 100% {
52
+ stroke-dashoffset: 0;
53
+ }
54
+ }
55
+
56
+ @keyframes scale {
57
+ 0%,
58
+ 100% {
59
+ transform: none;
60
+ }
61
+ 50% {
62
+ transform: scale3d(1.1, 1.1, 1);
63
+ }
64
+ }
65
+
66
+ @keyframes fill {
67
+ 100% {
68
+ box-shadow: inset 0px 0px 0px 30px #7ac142;
69
+ }
70
+ }