@lemonadejs/tabs 1.0.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.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Javascript Modal
2
+
3
+ [Official website and documentation is here](https://lemonadejs.net/components/tabs)
4
+
5
+ Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
6
+
7
+ The LemonadeJS JavaScript Tabs is a responsive and reactive component that creates selected tabs.
8
+
9
+ ## Features
10
+
11
+ - Lightweight: The JavaScript Modal is only about 2 KBytes;
12
+ - Reactive: Any changes to the underlying data are automatically applied to the HTML, making it easy to keep your grid up-to-date;
13
+ - Integration: It can be used as a standalone library or integrated with any modern framework;
14
+
15
+ ## Getting Started
16
+
17
+ You can install using NPM or using directly from a CDN.
18
+
19
+ ### npm Installation
20
+
21
+ To install it in your project using npm, run the following command:
22
+
23
+ ```bash
24
+ $ npm install @lemonadejs/tabs
25
+ ```
26
+
27
+ ### CDN
28
+
29
+ To use data grid via a CDN, include the following script tags in your HTML file:
30
+
31
+ ```html
32
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
33
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/tabs/dist/index.min.js"></script>
34
+ ```
35
+
36
+ ## License
37
+
38
+ The [LemonadeJS](https://lemonadejs.net) tabs is released under the MIT.
39
+
40
+ ## Other Tools
41
+
42
+ - [jSuites](https://jsuites.net/v4/)
43
+ - [Jspreadsheet](https://jspreadsheet.com)
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ if (!lemonade && typeof (require) === 'function') {
2
+ var lemonade = require('lemonadejs');
3
+ }
4
+
5
+ ; (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
+ typeof define === 'function' && define.amd ? define(factory) :
8
+ global.Tabs = factory();
9
+ }(this, (function () {
10
+
11
+ const Tabs = function (html) {
12
+ let self = this
13
+
14
+ let content = html;
15
+
16
+ if (self.data) {
17
+ for (let i = 0; i < self.data.length; i++) {
18
+ content += `<div title="${self.data[i].title}">${self.data[i].content}</div>`;
19
+ }
20
+ }
21
+
22
+ self.tabs = [];
23
+
24
+ self.onload = function () {
25
+ for (let i = 0; i < self.content.children.length; i++) {
26
+ self.tabs.push({ title: self.content.children[i].title });
27
+ }
28
+ self.refresh('tabs');
29
+
30
+ if (! isNaN(parseInt(self.selected))) {
31
+ select(self.selected);
32
+ }
33
+ }
34
+
35
+ const select = function (index) {
36
+ index = parseInt(index);
37
+
38
+ for (let i = 0; i < self.content.children.length; i++) {
39
+ self.headers.children[i].classList.remove('selected');
40
+ self.content.children[i].classList.remove('selected');
41
+ }
42
+ self.headers.children[index].classList.add('selected');
43
+ self.content.children[index].classList.add('selected');
44
+ }
45
+
46
+ self.onchange = function (property) {
47
+ if (property === 'selected') {
48
+ select(self.selected);
49
+ }
50
+ }
51
+
52
+ self.click = function (ev, el) {
53
+ if (ev.target.tagName === 'LI') {
54
+ self.selected = Array.prototype.indexOf.call(el.children, ev.target);
55
+ }
56
+ }
57
+
58
+ return `<div class="lm-tabs" position="{{self.position||''}}">
59
+ <ul :ref="self.headers" :loop="self.tabs" onclick="self.click(e, this)" :selected="self.selected"><li class="lm-tab-list-item">{{self.title}}</li></ul>
60
+ <div :ref="self.content" class="lm-tabs-content">${content}</div>
61
+ </div>`
62
+ }
63
+
64
+ lemonade.setComponents({ Tabs: Tabs });
65
+
66
+ return function (root, options) {
67
+ if (typeof (root) === 'object') {
68
+ lemonade.render(Tabs, root, options)
69
+ return options;
70
+ } else {
71
+ return Tabs.call(this, root)
72
+ }
73
+ }
74
+ })));
package/dist/style.css ADDED
@@ -0,0 +1,46 @@
1
+ .lm-tabs {
2
+ }
3
+
4
+ .lm-tabs .lm-tabs-content > div {
5
+ padding: 10px;
6
+ }
7
+
8
+ .lm-tabs > ul {
9
+ list-style-type: none;
10
+ display: flex;
11
+ margin: 0;
12
+ padding: 0;
13
+ margin-bottom: 5px;
14
+ width: fit-content;
15
+ align-self: center;
16
+ }
17
+
18
+ .lm-tabs > ul > li {
19
+ cursor: pointer;
20
+ user-select: none;
21
+ padding: 2px 12px;
22
+ outline: 1px solid rgba(0, 0, 0, 0.2);
23
+ background-position: center;
24
+ transition: background 0.8s;
25
+ }
26
+
27
+ .lm-tabs > ul > li:hover {
28
+ background: #eee radial-gradient(circle, transparent 1%, #eee 1%) center/15000%;
29
+ }
30
+ .lm-tabs > ul > li:active {
31
+ background-color: #ddd;
32
+ background-size: 100%;
33
+ transition: background 0s;
34
+ }
35
+
36
+ .lm-tabs .lm-tabs-content > div {
37
+ display: none;
38
+ }
39
+
40
+ .lm-tabs .lm-tabs-content > div.selected {
41
+ display: block;
42
+ }
43
+
44
+ .lm-tabs[position="center"] > ul {
45
+ margin: 0 auto;
46
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@lemonadejs/tabs",
3
+ "title": "JavaScript Tabs",
4
+ "description": "LemonadeJS tabs is a JavaScript component to create tabs.",
5
+ "author": {
6
+ "name": "Contact <contact@lemonadejs.net>",
7
+ "url": "https://lemonadejs.net"
8
+ },
9
+ "keywords": [
10
+ "javascript tabs",
11
+ "lemonadejs tabs",
12
+ "js tabs",
13
+ "tabs js"
14
+ ],
15
+ "dependencies": {
16
+ "lemonadejs": "^3.3.1"
17
+ },
18
+ "main": "dist/index.js",
19
+ "version": "1.0.0"
20
+ }