willba-component-library 0.0.16 → 0.0.18
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.
- package/.storybook/main.ts +19 -0
- package/.storybook/preview.ts +15 -0
- package/lib/components/Button/Button.d.ts +29 -0
- package/lib/components/Button/Button.stories.d.ts +7 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.esm.js +108 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +110 -0
- package/lib/index.js.map +1 -0
- package/package.json +33 -14
- package/rollup.config.mjs +46 -0
- package/src/components/Button/Button.stories.tsx +34 -0
- package/src/components/Button/Button.tsx +54 -0
- package/src/components/Button/button.css +30 -0
- package/src/index.ts +3 -0
- package/stories/Button.stories.ts +50 -0
- package/stories/Button.tsx +48 -0
- package/stories/Configure.mdx +364 -0
- package/stories/Header.stories.ts +27 -0
- package/stories/Header.tsx +56 -0
- package/stories/Page.stories.ts +29 -0
- package/stories/Page.tsx +73 -0
- package/stories/assets/accessibility.png +0 -0
- package/stories/assets/accessibility.svg +5 -0
- package/stories/assets/addon-library.png +0 -0
- package/stories/assets/assets.png +0 -0
- package/stories/assets/context.png +0 -0
- package/stories/assets/discord.svg +15 -0
- package/stories/assets/docs.png +0 -0
- package/stories/assets/figma-plugin.png +0 -0
- package/stories/assets/github.svg +3 -0
- package/stories/assets/share.png +0 -0
- package/stories/assets/styling.png +0 -0
- package/stories/assets/testing.png +0 -0
- package/stories/assets/theming.png +0 -0
- package/stories/assets/tutorials.svg +12 -0
- package/stories/assets/youtube.svg +4 -0
- package/stories/button.css +30 -0
- package/stories/header.css +32 -0
- package/stories/page.css +69 -0
- package/tsconfig.json +23 -0
- package/dist/cjs/index.js +0 -2638
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types/components/Button/Button.d.ts +0 -7
- package/dist/cjs/types/components/FilterBar/FilterBar.d.ts +0 -2
- package/dist/cjs/types/components/FilterBar/index.d.ts +0 -1
- package/dist/cjs/types/components/index.d.ts +0 -2
- package/dist/cjs/types/index.d.ts +0 -1
- package/dist/esm/index.js +0 -2635
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types/components/Button/Button.d.ts +0 -7
- package/dist/esm/types/components/FilterBar/FilterBar.d.ts +0 -2
- package/dist/esm/types/components/FilterBar/index.d.ts +0 -1
- package/dist/esm/types/components/index.d.ts +0 -2
- package/dist/esm/types/index.d.ts +0 -1
- package/dist/index.d.ts +0 -10
- /package/{dist/cjs/types → lib}/components/Button/index.d.ts +0 -0
- /package/{dist/esm/types/components/Button/index.d.ts → src/components/Button/index.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StorybookConfig } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ["../src/**/*.stories.tsx"],
|
|
5
|
+
addons: [
|
|
6
|
+
"@storybook/addon-links",
|
|
7
|
+
"@storybook/addon-essentials",
|
|
8
|
+
"@storybook/addon-onboarding",
|
|
9
|
+
"@storybook/addon-interactions",
|
|
10
|
+
],
|
|
11
|
+
framework: {
|
|
12
|
+
name: "@storybook/react-vite",
|
|
13
|
+
options: {},
|
|
14
|
+
},
|
|
15
|
+
docs: {
|
|
16
|
+
autodocs: "tag",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export default config;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Preview } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
const preview: Preview = {
|
|
4
|
+
parameters: {
|
|
5
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default preview;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./button.css";
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Is this the principal call to action on the page?
|
|
6
|
+
*/
|
|
7
|
+
type?: "primary" | "secondary";
|
|
8
|
+
/**
|
|
9
|
+
* What background color to use
|
|
10
|
+
*/
|
|
11
|
+
textColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How large should the button be?
|
|
14
|
+
*/
|
|
15
|
+
size?: "small" | "medium" | "large";
|
|
16
|
+
/**
|
|
17
|
+
* Button contents
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional click handler
|
|
22
|
+
*/
|
|
23
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Primary UI component for user interaction
|
|
27
|
+
*/
|
|
28
|
+
declare const Button: ({ type, textColor, size, onClick, label, }: ButtonProps) => React.JSX.Element;
|
|
29
|
+
export default Button;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Button from "./Button";
|
|
3
|
+
declare const meta: Meta<typeof Button>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Button>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Is this the principal call to action on the page?
|
|
6
|
+
*/
|
|
7
|
+
type?: "primary" | "secondary";
|
|
8
|
+
/**
|
|
9
|
+
* What background color to use
|
|
10
|
+
*/
|
|
11
|
+
textColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How large should the button be?
|
|
14
|
+
*/
|
|
15
|
+
size?: "small" | "medium" | "large";
|
|
16
|
+
/**
|
|
17
|
+
* Button contents
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional click handler
|
|
22
|
+
*/
|
|
23
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Primary UI component for user interaction
|
|
27
|
+
*/
|
|
28
|
+
declare const Button: ({ type, textColor, size, onClick, label, }: ButtonProps) => React.JSX.Element;
|
|
29
|
+
|
|
30
|
+
export { Button };
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var classnames = {exports: {}};
|
|
8
|
+
|
|
9
|
+
/*!
|
|
10
|
+
Copyright (c) 2018 Jed Watson.
|
|
11
|
+
Licensed under the MIT License (MIT), see
|
|
12
|
+
http://jedwatson.github.io/classnames
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
(function (module) {
|
|
16
|
+
/* global define */
|
|
17
|
+
|
|
18
|
+
(function () {
|
|
19
|
+
|
|
20
|
+
var hasOwn = {}.hasOwnProperty;
|
|
21
|
+
|
|
22
|
+
function classNames() {
|
|
23
|
+
var classes = [];
|
|
24
|
+
|
|
25
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
26
|
+
var arg = arguments[i];
|
|
27
|
+
if (!arg) continue;
|
|
28
|
+
|
|
29
|
+
var argType = typeof arg;
|
|
30
|
+
|
|
31
|
+
if (argType === 'string' || argType === 'number') {
|
|
32
|
+
classes.push(arg);
|
|
33
|
+
} else if (Array.isArray(arg)) {
|
|
34
|
+
if (arg.length) {
|
|
35
|
+
var inner = classNames.apply(null, arg);
|
|
36
|
+
if (inner) {
|
|
37
|
+
classes.push(inner);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else if (argType === 'object') {
|
|
41
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
42
|
+
classes.push(arg.toString());
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (var key in arg) {
|
|
47
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
48
|
+
classes.push(key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return classes.join(' ');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (module.exports) {
|
|
58
|
+
classNames.default = classNames;
|
|
59
|
+
module.exports = classNames;
|
|
60
|
+
} else {
|
|
61
|
+
window.classNames = classNames;
|
|
62
|
+
}
|
|
63
|
+
}());
|
|
64
|
+
} (classnames));
|
|
65
|
+
|
|
66
|
+
var classnamesExports = classnames.exports;
|
|
67
|
+
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
68
|
+
|
|
69
|
+
function styleInject(css, ref) {
|
|
70
|
+
if ( ref === void 0 ) ref = {};
|
|
71
|
+
var insertAt = ref.insertAt;
|
|
72
|
+
|
|
73
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
74
|
+
|
|
75
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
76
|
+
var style = document.createElement('style');
|
|
77
|
+
style.type = 'text/css';
|
|
78
|
+
|
|
79
|
+
if (insertAt === 'top') {
|
|
80
|
+
if (head.firstChild) {
|
|
81
|
+
head.insertBefore(style, head.firstChild);
|
|
82
|
+
} else {
|
|
83
|
+
head.appendChild(style);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
head.appendChild(style);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (style.styleSheet) {
|
|
90
|
+
style.styleSheet.cssText = css;
|
|
91
|
+
} else {
|
|
92
|
+
style.appendChild(document.createTextNode(css));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var css_248z = ".storybook-button {\n font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;\n font-weight: 700;\n border: 0;\n border-radius: 3em;\n cursor: pointer;\n display: inline-block;\n line-height: 1;\n}\n.storybook-button--primary {\n color: white;\n background-color: #1ea7fd;\n}\n.storybook-button--secondary {\n color: #333;\n background-color: transparent;\n box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;\n}\n.storybook-button--small {\n font-size: 12px;\n padding: 10px 16px;\n}\n.storybook-button--medium {\n font-size: 14px;\n padding: 11px 20px;\n}\n.storybook-button--large {\n font-size: 16px;\n padding: 12px 24px;\n}";
|
|
97
|
+
styleInject(css_248z);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Primary UI component for user interaction
|
|
101
|
+
*/
|
|
102
|
+
var Button = function (_a) {
|
|
103
|
+
var _b = _a.type, type = _b === void 0 ? "primary" : _b, textColor = _a.textColor, _c = _a.size, size = _c === void 0 ? "medium" : _c, onClick = _a.onClick, label = _a.label;
|
|
104
|
+
return (React.createElement("button", { type: "button", className: classNames("storybook-button", "storybook-button--".concat(size), "storybook-button--".concat(type)), style: textColor ? { color: textColor } : {}, onClick: onClick }, label));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { Button };
|
|
108
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../node_modules/classnames/index.js","../node_modules/style-inject/dist/style-inject.es.js","../src/components/Button/Button.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\tvar nativeCodeString = '[native code]';\n\n\tfunction classNames() {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg)) {\n\t\t\t\tif (arg.length) {\n\t\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\t\tif (inner) {\n\t\t\t\t\t\tclasses.push(inner);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\t\t\tclasses.push(arg.toString());\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport classNames from \"classnames\";\nimport \"./button.css\";\n\nexport interface ButtonProps {\n /**\n * Is this the principal call to action on the page?\n */\n type?: \"primary\" | \"secondary\";\n /**\n * What background color to use\n */\n textColor?: string;\n /**\n * How large should the button be?\n */\n size?: \"small\" | \"medium\" | \"large\";\n /**\n * Button contents\n */\n label: string;\n /**\n * Optional click handler\n */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\n/**\n * Primary UI component for user interaction\n */\nconst Button = ({\n type = \"primary\",\n textColor,\n size = \"medium\",\n onClick,\n label,\n}: ButtonProps) => {\n return (\n <button\n type=\"button\"\n className={classNames(\n \"storybook-button\",\n `storybook-button--${size}`,\n `storybook-button--${type}`\n )}\n style={textColor ? { color: textColor } : {}}\n onClick={onClick}\n >\n {label}\n </button>\n );\n};\n\nexport default Button;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA;AACA;AACA,CAAA,CAAC,YAAY;AAEb;AACA,EAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAEhC;EACC,SAAS,UAAU,GAAG;AACvB,GAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,GAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,IAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,IAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,IAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;IACG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,EAAE;AACrD,KAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAClC,KAAI,IAAI,GAAG,CAAC,MAAM,EAAE;MACf,IAAI,KAAK,GAAG,UAAU,CAAC,KAA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,EAClB,oBAAA,CAAA,MAAA,CAAqB,IAAI,CAAE,EAC3B,4BAAqB,IAAI,CAAE,CAC5B,EACD,KAAK,EAAE,SAAS,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,EAC5C,OAAO,EAAE,OAAO,IAEf,KAAK,CACC,EACT;AACJ;;;;","x_google_ignoreList":[0,1]}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function getDefaultExportFromCjs (x) {
|
|
6
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
var classnames = {exports: {}};
|
|
10
|
+
|
|
11
|
+
/*!
|
|
12
|
+
Copyright (c) 2018 Jed Watson.
|
|
13
|
+
Licensed under the MIT License (MIT), see
|
|
14
|
+
http://jedwatson.github.io/classnames
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
(function (module) {
|
|
18
|
+
/* global define */
|
|
19
|
+
|
|
20
|
+
(function () {
|
|
21
|
+
|
|
22
|
+
var hasOwn = {}.hasOwnProperty;
|
|
23
|
+
|
|
24
|
+
function classNames() {
|
|
25
|
+
var classes = [];
|
|
26
|
+
|
|
27
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
28
|
+
var arg = arguments[i];
|
|
29
|
+
if (!arg) continue;
|
|
30
|
+
|
|
31
|
+
var argType = typeof arg;
|
|
32
|
+
|
|
33
|
+
if (argType === 'string' || argType === 'number') {
|
|
34
|
+
classes.push(arg);
|
|
35
|
+
} else if (Array.isArray(arg)) {
|
|
36
|
+
if (arg.length) {
|
|
37
|
+
var inner = classNames.apply(null, arg);
|
|
38
|
+
if (inner) {
|
|
39
|
+
classes.push(inner);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} else if (argType === 'object') {
|
|
43
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
44
|
+
classes.push(arg.toString());
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (var key in arg) {
|
|
49
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
50
|
+
classes.push(key);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return classes.join(' ');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (module.exports) {
|
|
60
|
+
classNames.default = classNames;
|
|
61
|
+
module.exports = classNames;
|
|
62
|
+
} else {
|
|
63
|
+
window.classNames = classNames;
|
|
64
|
+
}
|
|
65
|
+
}());
|
|
66
|
+
} (classnames));
|
|
67
|
+
|
|
68
|
+
var classnamesExports = classnames.exports;
|
|
69
|
+
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
70
|
+
|
|
71
|
+
function styleInject(css, ref) {
|
|
72
|
+
if ( ref === void 0 ) ref = {};
|
|
73
|
+
var insertAt = ref.insertAt;
|
|
74
|
+
|
|
75
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
76
|
+
|
|
77
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
78
|
+
var style = document.createElement('style');
|
|
79
|
+
style.type = 'text/css';
|
|
80
|
+
|
|
81
|
+
if (insertAt === 'top') {
|
|
82
|
+
if (head.firstChild) {
|
|
83
|
+
head.insertBefore(style, head.firstChild);
|
|
84
|
+
} else {
|
|
85
|
+
head.appendChild(style);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
head.appendChild(style);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (style.styleSheet) {
|
|
92
|
+
style.styleSheet.cssText = css;
|
|
93
|
+
} else {
|
|
94
|
+
style.appendChild(document.createTextNode(css));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var css_248z = ".storybook-button {\n font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;\n font-weight: 700;\n border: 0;\n border-radius: 3em;\n cursor: pointer;\n display: inline-block;\n line-height: 1;\n}\n.storybook-button--primary {\n color: white;\n background-color: #1ea7fd;\n}\n.storybook-button--secondary {\n color: #333;\n background-color: transparent;\n box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;\n}\n.storybook-button--small {\n font-size: 12px;\n padding: 10px 16px;\n}\n.storybook-button--medium {\n font-size: 14px;\n padding: 11px 20px;\n}\n.storybook-button--large {\n font-size: 16px;\n padding: 12px 24px;\n}";
|
|
99
|
+
styleInject(css_248z);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Primary UI component for user interaction
|
|
103
|
+
*/
|
|
104
|
+
var Button = function (_a) {
|
|
105
|
+
var _b = _a.type, type = _b === void 0 ? "primary" : _b, textColor = _a.textColor, _c = _a.size, size = _c === void 0 ? "medium" : _c, onClick = _a.onClick, label = _a.label;
|
|
106
|
+
return (React.createElement("button", { type: "button", className: classNames("storybook-button", "storybook-button--".concat(size), "storybook-button--".concat(type)), style: textColor ? { color: textColor } : {}, onClick: onClick }, label));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.Button = Button;
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/classnames/index.js","../node_modules/style-inject/dist/style-inject.es.js","../src/components/Button/Button.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\tvar nativeCodeString = '[native code]';\n\n\tfunction classNames() {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg)) {\n\t\t\t\tif (arg.length) {\n\t\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\t\tif (inner) {\n\t\t\t\t\t\tclasses.push(inner);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\t\t\tclasses.push(arg.toString());\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport classNames from \"classnames\";\nimport \"./button.css\";\n\nexport interface ButtonProps {\n /**\n * Is this the principal call to action on the page?\n */\n type?: \"primary\" | \"secondary\";\n /**\n * What background color to use\n */\n textColor?: string;\n /**\n * How large should the button be?\n */\n size?: \"small\" | \"medium\" | \"large\";\n /**\n * Button contents\n */\n label: string;\n /**\n * Optional click handler\n */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\n/**\n * Primary UI component for user interaction\n */\nconst Button = ({\n type = \"primary\",\n textColor,\n size = \"medium\",\n onClick,\n label,\n}: ButtonProps) => {\n return (\n <button\n type=\"button\"\n className={classNames(\n \"storybook-button\",\n `storybook-button--${size}`,\n `storybook-button--${type}`\n )}\n style={textColor ? { color: textColor } : {}}\n onClick={onClick}\n >\n {label}\n </button>\n );\n};\n\nexport default Button;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA;AACA;AACA,CAAA,CAAC,YAAY;AAEb;AACA,EAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAEhC;EACC,SAAS,UAAU,GAAG;AACvB,GAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,GAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,IAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,IAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,IAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;IACG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,EAAE;AACrD,KAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAClC,KAAI,IAAI,GAAG,CAAC,MAAM,EAAE;MACf,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;MAC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AAE,EAC3B,4BAAqB,IAAI,CAAE,CAC5B,EACD,KAAK,EAAE,SAAS,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,EAC5C,OAAO,EAAE,OAAO,IAEf,KAAK,CACC,EACT;AACJ;;;;","x_google_ignoreList":[0,1]}
|
package/package.json
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "willba-component-library",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.18",
|
|
4
|
+
"description": "A stroybook 6 with TypeScript demo",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.esm.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
5
8
|
"scripts": {
|
|
6
|
-
"
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build",
|
|
12
|
+
"build": "rollup -c"
|
|
7
13
|
},
|
|
8
14
|
"author": "Willba",
|
|
9
|
-
"license": "
|
|
10
|
-
"
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
11
17
|
"@rollup/plugin-commonjs": "^25.0.3",
|
|
12
18
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
13
19
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
14
|
-
"@types/react": "^
|
|
15
|
-
"
|
|
20
|
+
"@types/react": "^18.2.19",
|
|
21
|
+
"classnames": "^2.3.2",
|
|
22
|
+
"postcss": "^8.4.27",
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0",
|
|
16
25
|
"rollup": "^3.27.2",
|
|
17
26
|
"rollup-plugin-dts": "^5.3.1",
|
|
27
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
18
28
|
"rollup-plugin-postcss": "^4.0.2",
|
|
19
|
-
"tslib": "^2.6.1",
|
|
20
29
|
"typescript": "^5.1.6"
|
|
21
30
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^18.2.0",
|
|
33
|
+
"react-dom": "^18.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@storybook/addon-essentials": "^7.2.1",
|
|
37
|
+
"@storybook/addon-interactions": "^7.2.1",
|
|
38
|
+
"@storybook/addon-links": "^7.2.1",
|
|
39
|
+
"@storybook/addon-onboarding": "^1.0.8",
|
|
40
|
+
"@storybook/blocks": "^7.2.1",
|
|
41
|
+
"@storybook/react": "^7.2.1",
|
|
42
|
+
"@storybook/react-vite": "^7.2.1",
|
|
43
|
+
"@storybook/testing-library": "^0.2.0",
|
|
44
|
+
"storybook": "^7.2.1"
|
|
45
|
+
}
|
|
46
|
+
|
|
28
47
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import peerDepsExternal from "rollup-plugin-peer-deps-external";
|
|
2
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
+
import typescript from "@rollup/plugin-typescript";
|
|
5
|
+
import postcss from "rollup-plugin-postcss";
|
|
6
|
+
import dts from "rollup-plugin-dts";
|
|
7
|
+
|
|
8
|
+
// This is required to read package.json file when
|
|
9
|
+
// using Native ES modules in Node.js
|
|
10
|
+
// https://rollupjs.org/command-line-interface/#importing-package-json
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
const requireFile = createRequire(import.meta.url);
|
|
13
|
+
const packageJson = requireFile("./package.json");
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
{
|
|
17
|
+
input: "src/index.ts",
|
|
18
|
+
output: [
|
|
19
|
+
{
|
|
20
|
+
file: packageJson.main,
|
|
21
|
+
format: "cjs",
|
|
22
|
+
sourcemap: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
file: packageJson.module,
|
|
26
|
+
format: "esm",
|
|
27
|
+
sourcemap: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
plugins: [
|
|
31
|
+
peerDepsExternal(),
|
|
32
|
+
resolve(),
|
|
33
|
+
commonjs(),
|
|
34
|
+
typescript(),
|
|
35
|
+
postcss({
|
|
36
|
+
extensions: [".css"],
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
input: "lib/index.d.ts",
|
|
42
|
+
output: [{ file: "lib/index.d.ts", format: "es" }],
|
|
43
|
+
plugins: [dts()],
|
|
44
|
+
external: [/\.css$/],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import Button from "./Button";
|
|
4
|
+
|
|
5
|
+
// Default metadata of the story https://storybook.js.org/docs/react/api/csf#default-export
|
|
6
|
+
const meta: Meta<typeof Button> = {
|
|
7
|
+
title: "Components/Button",
|
|
8
|
+
component: Button,
|
|
9
|
+
argTypes: {
|
|
10
|
+
textColor: { control: "color" },
|
|
11
|
+
onClick: { action: "clicked" },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
// The story type for the component https://storybook.js.org/docs/react/api/csf#named-story-exports
|
|
18
|
+
type Story = StoryObj<typeof Button>;
|
|
19
|
+
|
|
20
|
+
export const Primary: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
label: "Primary 😃",
|
|
23
|
+
size: "large",
|
|
24
|
+
type: "primary",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Secondary: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
...Primary.args,
|
|
31
|
+
type: "secondary",
|
|
32
|
+
label: "Secondary 😇",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./button.css";
|
|
4
|
+
|
|
5
|
+
export interface ButtonProps {
|
|
6
|
+
/**
|
|
7
|
+
* Is this the principal call to action on the page?
|
|
8
|
+
*/
|
|
9
|
+
type?: "primary" | "secondary";
|
|
10
|
+
/**
|
|
11
|
+
* What background color to use
|
|
12
|
+
*/
|
|
13
|
+
textColor?: string;
|
|
14
|
+
/**
|
|
15
|
+
* How large should the button be?
|
|
16
|
+
*/
|
|
17
|
+
size?: "small" | "medium" | "large";
|
|
18
|
+
/**
|
|
19
|
+
* Button contents
|
|
20
|
+
*/
|
|
21
|
+
label: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional click handler
|
|
24
|
+
*/
|
|
25
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Primary UI component for user interaction
|
|
30
|
+
*/
|
|
31
|
+
const Button = ({
|
|
32
|
+
type = "primary",
|
|
33
|
+
textColor,
|
|
34
|
+
size = "medium",
|
|
35
|
+
onClick,
|
|
36
|
+
label,
|
|
37
|
+
}: ButtonProps) => {
|
|
38
|
+
return (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className={classNames(
|
|
42
|
+
"storybook-button",
|
|
43
|
+
`storybook-button--${size}`,
|
|
44
|
+
`storybook-button--${type}`
|
|
45
|
+
)}
|
|
46
|
+
style={textColor ? { color: textColor } : {}}
|
|
47
|
+
onClick={onClick}
|
|
48
|
+
>
|
|
49
|
+
{label}
|
|
50
|
+
</button>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default Button;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.storybook-button {
|
|
2
|
+
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
3
|
+
font-weight: 700;
|
|
4
|
+
border: 0;
|
|
5
|
+
border-radius: 3em;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
line-height: 1;
|
|
9
|
+
}
|
|
10
|
+
.storybook-button--primary {
|
|
11
|
+
color: white;
|
|
12
|
+
background-color: #1ea7fd;
|
|
13
|
+
}
|
|
14
|
+
.storybook-button--secondary {
|
|
15
|
+
color: #333;
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
|
|
18
|
+
}
|
|
19
|
+
.storybook-button--small {
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
padding: 10px 16px;
|
|
22
|
+
}
|
|
23
|
+
.storybook-button--medium {
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
padding: 11px 20px;
|
|
26
|
+
}
|
|
27
|
+
.storybook-button--large {
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
padding: 12px 24px;
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Example/Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
parameters: {
|
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
16
|
+
argTypes: {
|
|
17
|
+
backgroundColor: { control: 'color' },
|
|
18
|
+
},
|
|
19
|
+
} satisfies Meta<typeof Button>;
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
|
|
24
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
25
|
+
export const Primary: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
primary: true,
|
|
28
|
+
label: 'Button',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Secondary: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
label: 'Button',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Large: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
size: 'large',
|
|
41
|
+
label: 'Button',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Small: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
size: 'small',
|
|
48
|
+
label: 'Button',
|
|
49
|
+
},
|
|
50
|
+
};
|