tabexseriescomponents 0.0.1

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/README.md ADDED
@@ -0,0 +1,525 @@
1
+
2
+ In this tutorial i will be showing you how to create an npm library that is composed of react component. This will definetly help you incase you want to reuse code in multiple projects or if you just want to create your own library.
3
+
4
+ #### Table of contents:
5
+ - [Getting Started](#getting-started)
6
+ - [Creating the library](#creating-the-library)
7
+ - [Initializing the library](#initializing-the-library)
8
+ - [Bundling the library](#bundling-the-library)
9
+ - [Re-arranging the package directory](#re-arranging-the-package-directory)
10
+ - [Installing bundlers](#installing-bundlers)
11
+ - [Configuration](#configuration)
12
+ - [Editing `package.json` scripts](#editing-packagejson-scripts)
13
+ - [Build package](#build-package)
14
+ - [Editing `package.json`](#editing-packagejson)
15
+ - [Fields](#fields)
16
+ - [`name` and `vesrion`](#name-and-vesrion)
17
+ - [decription](#decription)
18
+ - [keywords](#keywords)
19
+ - [homepage](#homepage)
20
+ - [license](#license)
21
+ - [people fields: author, contributors](#people-fields-author-contributors)
22
+ - [Adding `peerDependecies`](#adding-peerdependecies)
23
+ - [Final package.json](#final-packagejson)
24
+ - [Publishing](#publishing)
25
+ - [Creating `.npmignore`](#creating-npmignore)
26
+ - [Finding a name](#finding-a-name)
27
+ - [Testing your package](#testing-your-package)
28
+ - [Adding README.md](#adding-readmemd)
29
+ - [Publishing](#publishing-1)
30
+ - [Conclusion](#conclusion)
31
+
32
+
33
+ If you are ready, lets get started.
34
+
35
+ ## Getting Started
36
+ First we shall initialize a react project. So got to your terminal and enter the directory that you want to create your project and create a new react app with the `create-react-app` CLI.
37
+
38
+ ```bash
39
+ npx create-react-app react-npm-library
40
+ ## then enter the new directory
41
+ cd react-npm-library
42
+ ## then start the dev server
43
+ yarn start
44
+ ```
45
+ I recommend using `npx` sinc it installs the latest versions of `react-scripts` and does not install any thing globally.
46
+
47
+ Then enter the `src` directory and create a new directory where you will place your component library
48
+
49
+ ```bash
50
+ cd src
51
+ mkdir react-library ## you can name it any name
52
+ ```
53
+
54
+ ## Creating the library
55
+
56
+ if you have done the above steps now you are ready to create you libray. So now lets create a simple library that creates good buttons.
57
+
58
+ Inside the `react-library` directory we shall create a file for the component.
59
+ ```bash
60
+ torch button.jsx
61
+ torch index.css
62
+ ```
63
+ Then place this code in `button.jsx`
64
+
65
+ ```jsx
66
+ import React, {useState, useEffect} from 'react';
67
+ import './button.css'
68
+
69
+ const AwesomeButton = (props) => {
70
+ const [color, setColor] = useState(null)
71
+ useEffect(() => {
72
+ if (props.variant) {
73
+ if (props.variant === 'primary') {
74
+ setColor('#0077ff')
75
+ } else if (props.variant === 'secondary') {
76
+ setColor('#ff0062')
77
+ } else if (props.variant === 'success') {
78
+ setColor('#0f8000')
79
+ } else {
80
+ setColor('#949393')
81
+ }
82
+ }
83
+ })
84
+ const {children} = props
85
+
86
+ return (
87
+ <button
88
+ className='buttonComponent'
89
+ style={{
90
+ backgroundColor: color
91
+ }}
92
+ >
93
+ {children.toUpperCase()}
94
+ </button>
95
+ )
96
+ }
97
+
98
+ export default AwesomeButton;
99
+ ```
100
+
101
+ in index.css
102
+ ```css
103
+ .buttonComponent {
104
+ border-radius: 3px;
105
+ padding: 0.3rem 0.5rem;
106
+ transition: all .3s ease-out;
107
+ box-shadow: #272727b0 1px 1px 1px, #272727b0 -1px -1px 1px;
108
+ }
109
+ .buttonComponent:hover {
110
+ box-shadow: #272727b0 1px 1px 3px, #272727b0 -1px -1px 3px;
111
+ }
112
+ .buttonComponent:active {
113
+ opacity: .8;
114
+ }
115
+ ```
116
+
117
+ Now you can import it from `App.js` and test it. If it works well then lets move on.
118
+
119
+ ## Initializing the library
120
+
121
+ Now if it works so you have to enter the `react-library` directory and create get it ready for publishing.
122
+ ```bash
123
+ cd react-library
124
+ ```
125
+
126
+ After then initialize an npm package
127
+ ```bash
128
+ npm init -y
129
+ ```
130
+ This will create a `package.json` file in the root directory. It should look like this
131
+
132
+ ```json
133
+ {
134
+ "name": "react-library",
135
+ "version": "1.0.0",
136
+ "description": "",
137
+ "main": "index.js",
138
+ "scripts": {
139
+ "test": "echo \"Error: no test specified\" && exit 1"
140
+ },
141
+ "author": "",
142
+ "license": "ISC"
143
+ }
144
+ ```
145
+ Now you are ready to move on to the next section
146
+
147
+ ## Bundling the library
148
+
149
+ Now lets get ready to bundle the library. We shall do this in a few steps
150
+
151
+ ### Re-arranging the package directory
152
+
153
+ So now lets arrange the `react-library` directory so it can be favourable for bundling.
154
+
155
+ Move to your terminal and type these commands inside the `react-library` directory
156
+ ```bash
157
+ mkdir src
158
+ move button.jsx src
159
+ move index.css src
160
+ cd src
161
+ torch index.js
162
+ ```
163
+ The above commands will move the `button.jsx` and `index.css` files to a new `src` directory and also create a new file called `index.js`
164
+ By now your project structure looks something like this.
165
+ ```bash
166
+ |
167
+ - src
168
+ | - index.js
169
+ | - index.css
170
+ | - button.jsx
171
+ - package.json
172
+ ```
173
+
174
+ Inside the `index.js` file add the following code
175
+
176
+ ```js
177
+ import AwesomeButton from './button.js'
178
+
179
+ const returnLibrary = () => {
180
+ return {
181
+ AwesomeButton: AwesomeButton
182
+ // you can add here other components that you want to export
183
+ }
184
+ }
185
+ export default returnLibrary()
186
+ ```
187
+
188
+ ### Installing bundlers
189
+
190
+ Now lets install the bundlers. I recommend [rollup](https://rollupjs.org) since I thimk it is easy to use when bundling libraries compared to webpack but if you want to use another bundler then you can use it.
191
+ So in the root of the `react-library` directory install rollup.
192
+
193
+ > __Note__: You have to install them as `devDependencies` by adding the `--save-dev` flag. This is because they are used by you when in development mode else if you don't this will cause make your users to install thenm if you add them to the `dependency` list
194
+ ```bash
195
+ npm install rollup --save-dev
196
+ ```
197
+ Rollup will be used to compile our code. But since we definitely might want to compile into es5 syntax so we shall have to install [__babel__](https://babeljs.io/) and a plugin to use with rollup. You should not that `jsx` syntax is special and is not valid javascript so you should also install support for it.
198
+ So type the following commad int in the command line to install all __required__ packages.
199
+
200
+ ```bash
201
+ npm install @babel/cli @babel/core @babel/preset-env @babel/preset-react @rollup/plugin-babel --save-dev
202
+ ```
203
+
204
+ Since we are also bundling css then we shall have to install a styles bundler for rollup we shall use `rollup-plugin-styles`
205
+
206
+ ```bash
207
+ npm install rollup-plugin-styles autoprefixer --save-dev
208
+ ```
209
+ ___
210
+ __Optional__
211
+
212
+ We can also add babel runtime helpers. this is important if you are bundling a library with babel. So type this in the command line
213
+ ```bash
214
+ npm install @babel/runtime
215
+ npm install @babel/plugin-transform-runtime --save-dev
216
+ ```
217
+
218
+ If you want sourcemaps then intall this plugin to.
219
+
220
+ ```bash
221
+ npm install rollup-plugin-sourcemaps --save-dev
222
+ ```
223
+ ___
224
+
225
+ ### Configuration
226
+
227
+ Now lets configure the rullop and babel for compiling our code.
228
+ In the root directory create these to files.
229
+ - `rollup.config.js`
230
+ - `.babelrc`
231
+
232
+
233
+ Inside `rollup.config.js` add the following code.
234
+ ```js
235
+ import styles from "rollup-plugin-styles";
236
+ const autoprefixer = require('autoprefixer');
237
+ import { terser } from 'rollup-plugin-terser'
238
+ import babel from '@rollup/plugin-babel';
239
+ import sourcemaps from 'rollup-plugin-sourcemaps';
240
+
241
+ // the entry point for the library
242
+ const input = 'src/index.js'
243
+
244
+ //
245
+ var MODE = [
246
+ {
247
+ fomart: 'cjs'
248
+ },
249
+ {
250
+ fomart: 'esm'
251
+ },
252
+ {
253
+ fomart: 'umd'
254
+ }
255
+ ]
256
+
257
+
258
+
259
+
260
+ var config = []
261
+
262
+
263
+ MODE.map((m) => {
264
+ var conf = {
265
+ input: input,
266
+ output: {
267
+ // then name of your package
268
+ name: "react-awesome-buttons",
269
+ file: `dist/index.${m.fomart}.js`,
270
+ format: m.fomart,
271
+ exports: "auto"
272
+ },
273
+ // this externelizes react to prevent rollup from compiling it
274
+ external: ["react", /@babel\/runtime/],
275
+ plugins: [
276
+ // these are babel comfigurations
277
+ babel({
278
+ exclude: 'node_modules/**',
279
+ plugins: ['@babel/transform-runtime'],
280
+ babelHelpers: 'runtime'
281
+ }),
282
+ // this adds sourcemaps
283
+ sourcemaps(),
284
+ // this adds support for styles
285
+ styles({
286
+ postcss: {
287
+ plugins: [
288
+ autoprefixer()
289
+ ]
290
+ }
291
+ })
292
+ ]
293
+ }
294
+ config.push(conf)
295
+ })
296
+
297
+ export default [
298
+ ...config,
299
+ ]
300
+ ```
301
+ Also add this to `.babelrc`
302
+ ```json
303
+ {
304
+ "presets": [
305
+ "@babel/preset-react",
306
+ "@babel/preset-env"
307
+ ]
308
+ }
309
+ ```
310
+ ### Editing `package.json` scripts
311
+
312
+ Now got to `package.json` and edit the scripts section and change it to this.
313
+ ```json
314
+ // package.json
315
+ ...
316
+ "scripts": {
317
+ "build": "rollup -c"
318
+ }
319
+ ...
320
+
321
+ ```
322
+
323
+ ### Build package
324
+
325
+ Now that everything is set run
326
+
327
+ ```bash
328
+ npm run build
329
+ ```
330
+ This will compile your package into the `dist` directory.
331
+
332
+
333
+ ## Editing `package.json`
334
+
335
+ Now that our library has been built lets edit `package.json` to make our library ready for publishing.
336
+
337
+ If you have followed from the beginning i think your `packages.json` looks something like this.
338
+
339
+ ```json
340
+ {
341
+ "name": "react-library",
342
+ "version": "1.0.0",
343
+ "description": "",
344
+ "main": "index.js",
345
+ "directories": {
346
+ "test": "test"
347
+ },
348
+ "scripts": {
349
+ "build": "rollup -c"
350
+ },
351
+ "keywords": [],
352
+ "author": "",
353
+ "license": "ISC",
354
+ "dependencies": {
355
+ "@babel/runtime": "^7.12.5"
356
+ },
357
+ "devDependencies": {
358
+ "@babel/cli": "^7.12.10",
359
+ "@babel/core": "^7.12.10",
360
+ "@babel/plugin-transform-runtime": "^7.12.10",
361
+ "@babel/preset-env": "^7.12.11",
362
+ "@babel/preset-react": "^7.12.10",
363
+ "@rollup/plugin-babel": "^5.2.2",
364
+ "rollup-plugin-sourcemaps": "^0.6.3",
365
+ "rollup-plugin-styles": "^3.12.2",
366
+ }
367
+ }
368
+ ```
369
+
370
+ I will explain what a few important feilds represent and you can find out more on at the [npm documentation](https://docs.npmjs.com/cli/v6/configuring-npm/package-json "npm documentation").
371
+
372
+ ### Fields
373
+ #### `name` and `vesrion`
374
+ If you plan to publish your package, the most important things in your package.json are the name and version fields as they will be required. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. If you don't plan to publish your package, the name and version fields are optional.
375
+ A name can be optionally prefixed by a scope, e.g. @myorg/mypackage.
376
+
377
+ #### decription
378
+ Put a description in it. It's a string. This helps people discover your package, as it's listed in npm search.
379
+ #### keywords
380
+ Put keywords in it. It's an array of strings. This helps people discover your package as it's listed in npm search.
381
+
382
+ #### homepage
383
+ The url to the project homepage.
384
+
385
+ #### license
386
+ You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.
387
+
388
+ If you're using a common license such as BSD-2-Clause or MIT, add a current SPDX license identifier for the license you're using, like this:
389
+ ```json
390
+ {"license":"BSD-3-Clause"}
391
+ ```
392
+ #### people fields: author, contributors
393
+ The "author" is one person. "contributors" is an array of people. A "person" is an object with a "name" field and optionally "url" and "email", like this:
394
+
395
+ ```json
396
+ {
397
+ "name":"Barney Rubble",
398
+ "email":"b@rubble.com",
399
+ "url":"http://barnyrubble.tumblr.com/"
400
+ }
401
+ ```
402
+ ### Adding `peerDependecies`
403
+ Since we dont want to have react installed twice in the users projects but also need the user to have it we shall add it as a `peerDependecies` so add this to you package.json file
404
+ ```json
405
+ "peerDependencies": {
406
+ "react": "^17.0.1",
407
+ "react-dom": "^17.0.1"
408
+ }
409
+ ```
410
+ ### Final package.json
411
+
412
+ Now edit it to look like this
413
+
414
+ ```json
415
+ {
416
+ "name": "react-library",
417
+ "version": "1.0.0",
418
+ "description": "your description",
419
+ "main": "dist/index.cjs.js",
420
+ "scripts": {
421
+ "build": "rollup -c"
422
+ },
423
+ "peerDependencies": {
424
+ "react": "^17.0.1",
425
+ "react-dom": "^17.0.1"
426
+ },
427
+ "dependencies": {
428
+ "@babel/runtime": "^7.12.5"
429
+ },
430
+ "keywords": [
431
+ "react",
432
+ "keywords"
433
+ ],
434
+ "author": "Your name",
435
+ "license": "MIT",
436
+ "devDependencies": {
437
+ "@babel/cli": "^7.12.10",
438
+ "@babel/core": "^7.12.10",
439
+ "@babel/plugin-transform-runtime": "^7.12.10",
440
+ "@babel/preset-env": "^7.12.11",
441
+ "@babel/preset-react": "^7.12.10",
442
+ "@rollup/plugin-babel": "^5.2.2",
443
+ "rollup-plugin-sourcemaps": "^0.6.3",
444
+ "rollup-plugin-styles": "^3.12.2",
445
+ }
446
+ }
447
+
448
+ ```
449
+
450
+ ## Publishing
451
+
452
+ Now you are ready to publish.
453
+ First create an npm account if you don't have one.
454
+
455
+ ### Creating `.npmignore`
456
+
457
+ I hope by now your projects structure looks like this:
458
+
459
+ ```bash
460
+ |
461
+ | - dist
462
+ | - index.esm.js
463
+ | - index.cjs.js
464
+ | - index.umd.js
465
+ | - src
466
+ | - index.js
467
+ | - index.css
468
+ | - button.jsx
469
+ | - .babelrc
470
+ | - package.json
471
+ | - rollup.config.js
472
+ ```
473
+ But since we dont want to publish our source code to npm we only want to publish the compiled code then we will create a `.npmignore` file that will prevent files we dont want to publish from being published
474
+
475
+ add this to `.npmignore` file.
476
+ ```ignore
477
+ ## the src folder
478
+ src
479
+ .babelrc
480
+ rollup.config.js
481
+ ## node modules folder
482
+ node_modules
483
+ ## incase you have a git repositiory initiated
484
+ .git
485
+ .gitignore
486
+ CVS
487
+ .svn
488
+ .hg
489
+ .lock-wscript
490
+ .wafpickle-N
491
+ .DS_Store
492
+ npm-debug.log
493
+ .npmrc
494
+
495
+ config.gypi
496
+ package-lock.json
497
+ ```
498
+ ### Finding a name
499
+
500
+ Sometimes you might try to publish a package and find that the name is either already taken or the name is almost identical to onother package so its better to first search and see if the package name is already taken. So type the following command in the command line.
501
+ ```bash
502
+ npm search [package name]
503
+ ```
504
+
505
+ if you find that nobody is using it them you can usethe name.
506
+
507
+ ### Testing your package
508
+
509
+ To test your package your have to go to another projects on you comuter and type
510
+ ```bash
511
+ npm link /path/to/your/package
512
+ ```
513
+
514
+
515
+ ### Adding README.md
516
+ You should also add a `Readme.md` file that will be displayed on npm having a description of your package. You might be familiar with it if you have ever created a repository on GitHub
517
+
518
+ ### Publishing
519
+
520
+ If all works well then you can publish it by typing
521
+ ```bash
522
+ npm publish
523
+ ```
524
+ ## Conclusion
525
+ I hope this article has been helpful to you if you have any question just leave it in the comments section and all the source code can be found on [Github](https://github.com/jim-junior/react-npm-library-template "GitHub repository")
@@ -0,0 +1,3 @@
1
+ /*
2
+ This file will auto generated by rollup and it wont be empty it will have the esm version of your package
3
+ */
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var React = require('react');
5
+
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+
8
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
12
+
13
+ var css = ".buttonComponent {\n\tborder-radius: 3px;\n\tpadding: 0.3rem 0.5rem;\n\ttransition: all 0.3s ease-out;\n\tbox-shadow: #272727b0 1px 1px 1px, #272727b0 -1px -1px 1px;\n}\n.buttonComponent:hover {\n\tbox-shadow: #272727b0 1px 1px 3px, #272727b0 -1px -1px 3px;\n}\n.buttonComponent:active {\n\topacity: 0.8;\n}\n";
14
+ n(css,{});
15
+
16
+ var AwesomeButton = function AwesomeButton(props) {
17
+ var _useState = React.useState(null),
18
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
19
+ color = _useState2[0],
20
+ setColor = _useState2[1];
21
+
22
+ React.useEffect(function () {
23
+ if (props.variant) {
24
+ if (props.variant === 'primary') {
25
+ setColor('#0077ff');
26
+ } else if (props.variant === 'secondary') {
27
+ setColor('#ff0062');
28
+ } else if (props.variant === 'success') {
29
+ setColor('#0f8000');
30
+ } else {
31
+ setColor('#949393');
32
+ }
33
+ }
34
+ });
35
+ var children = props.children;
36
+ return /*#__PURE__*/React__default["default"].createElement("button", {
37
+ className: "buttonComponent",
38
+ style: {
39
+ backgroundColor: color
40
+ }
41
+ }, children.toUpperCase());
42
+ };
43
+
44
+ var returnLibrary = function returnLibrary() {
45
+ return {
46
+ AwesomeButton: AwesomeButton // you can add here other components that you want to export
47
+
48
+ };
49
+ };
50
+
51
+ var index = returnLibrary();
52
+
53
+ module.exports = index;
@@ -0,0 +1,46 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import React, { useState, useEffect } from 'react';
3
+
4
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
5
+
6
+ var css = ".buttonComponent {\n\tborder-radius: 3px;\n\tpadding: 0.3rem 0.5rem;\n\ttransition: all 0.3s ease-out;\n\tbox-shadow: #272727b0 1px 1px 1px, #272727b0 -1px -1px 1px;\n}\n.buttonComponent:hover {\n\tbox-shadow: #272727b0 1px 1px 3px, #272727b0 -1px -1px 3px;\n}\n.buttonComponent:active {\n\topacity: 0.8;\n}\n";
7
+ n(css,{});
8
+
9
+ var AwesomeButton = function AwesomeButton(props) {
10
+ var _useState = useState(null),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ color = _useState2[0],
13
+ setColor = _useState2[1];
14
+
15
+ useEffect(function () {
16
+ if (props.variant) {
17
+ if (props.variant === 'primary') {
18
+ setColor('#0077ff');
19
+ } else if (props.variant === 'secondary') {
20
+ setColor('#ff0062');
21
+ } else if (props.variant === 'success') {
22
+ setColor('#0f8000');
23
+ } else {
24
+ setColor('#949393');
25
+ }
26
+ }
27
+ });
28
+ var children = props.children;
29
+ return /*#__PURE__*/React.createElement("button", {
30
+ className: "buttonComponent",
31
+ style: {
32
+ backgroundColor: color
33
+ }
34
+ }, children.toUpperCase());
35
+ };
36
+
37
+ var returnLibrary = function returnLibrary() {
38
+ return {
39
+ AwesomeButton: AwesomeButton // you can add here other components that you want to export
40
+
41
+ };
42
+ };
43
+
44
+ var index = returnLibrary();
45
+
46
+ export { index as default };
@@ -0,0 +1,56 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@babel/runtime/helpers/slicedToArray'), require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['@babel/runtime/helpers/slicedToArray', 'react'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["react-awesome-buttons"] = factory(global._slicedToArray, global.React));
5
+ })(this, (function (_slicedToArray, React) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+
12
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
13
+
14
+ var css = ".buttonComponent {\n\tborder-radius: 3px;\n\tpadding: 0.3rem 0.5rem;\n\ttransition: all 0.3s ease-out;\n\tbox-shadow: #272727b0 1px 1px 1px, #272727b0 -1px -1px 1px;\n}\n.buttonComponent:hover {\n\tbox-shadow: #272727b0 1px 1px 3px, #272727b0 -1px -1px 3px;\n}\n.buttonComponent:active {\n\topacity: 0.8;\n}\n";
15
+ n(css,{});
16
+
17
+ var AwesomeButton = function AwesomeButton(props) {
18
+ var _useState = React.useState(null),
19
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
20
+ color = _useState2[0],
21
+ setColor = _useState2[1];
22
+
23
+ React.useEffect(function () {
24
+ if (props.variant) {
25
+ if (props.variant === 'primary') {
26
+ setColor('#0077ff');
27
+ } else if (props.variant === 'secondary') {
28
+ setColor('#ff0062');
29
+ } else if (props.variant === 'success') {
30
+ setColor('#0f8000');
31
+ } else {
32
+ setColor('#949393');
33
+ }
34
+ }
35
+ });
36
+ var children = props.children;
37
+ return /*#__PURE__*/React__default["default"].createElement("button", {
38
+ className: "buttonComponent",
39
+ style: {
40
+ backgroundColor: color
41
+ }
42
+ }, children.toUpperCase());
43
+ };
44
+
45
+ var returnLibrary = function returnLibrary() {
46
+ return {
47
+ AwesomeButton: AwesomeButton // you can add here other components that you want to export
48
+
49
+ };
50
+ };
51
+
52
+ var index = returnLibrary();
53
+
54
+ return index;
55
+
56
+ }));
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "tabexseriescomponents",
3
+ "version": "0.0.1",
4
+ "description": "your description",
5
+ "main": "dist/index.cjs.js",
6
+ "scripts": {
7
+ "build": "rollup -c"
8
+ },
9
+ "peerDependencies": {
10
+ "react": "^17.0.1",
11
+ "react-dom": "^17.0.1"
12
+ },
13
+ "dependencies": {
14
+ "@babel/runtime": "^7.12.5",
15
+ "rollup-plugin-terser": "^7.0.2"
16
+ },
17
+ "keywords": [
18
+ "react",
19
+ "keywords"
20
+ ],
21
+ "author": "Your name",
22
+ "license": "MIT",
23
+ "devDependencies": {
24
+ "@babel/cli": "^7.18.10",
25
+ "@babel/core": "^7.18.13",
26
+ "@babel/plugin-transform-runtime": "^7.12.10",
27
+ "@babel/preset-env": "^7.18.10",
28
+ "@babel/preset-react": "^7.18.6",
29
+ "@rollup/plugin-babel": "^5.3.1",
30
+ "autoprefixer": "^10.4.8",
31
+ "rollup": "^2.79.0",
32
+ "rollup-plugin-sourcemaps": "^0.6.3",
33
+ "rollup-plugin-styles": "^3.14.1"
34
+ }
35
+ }