Skip to content

Commit 49f5ca5

Browse files
Merge pull request #1 from phillip-kruger/main
init
2 parents 36e3a57 + ba0638d commit 49f5ca5

File tree

9 files changed

+6829
-0
lines changed

9 files changed

+6829
-0
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish to npm on Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '16'
18+
registry-url: 'https://registry.npmjs.org/'
19+
20+
- name: Install dependencies
21+
run: npm install
22+
23+
- name: Update version in package.json
24+
run: |
25+
RELEASE_VERSION=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')
26+
npm version $RELEASE_VERSION --no-git-tag-version
27+
28+
- name: Publish to npm
29+
run: npm publish
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*

LICENSE

100644100755
File mode changed.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# qui-tabs
2+
A Lit-based web component to display things in dynamic tabs.
3+
4+
## Installation
5+
6+
```bash
7+
npm i @qomponent/qui-tabs
8+
```
9+
10+
## Usage
11+
12+
Import the component in your project:
13+
14+
```javascript
15+
import '@qomponent/qui-tabs';
16+
```
17+
18+
Then, use it in your HTML:
19+
20+
```html
21+
<qui-tabs>
22+
<div slot="tab-content" key="home" name="Home">Welcome to Home</div>
23+
<div slot="tab-content" key="profile" name="Profile">User Profile Information</div>
24+
<div slot="tab-content" key="settings" name="Settings">Settings Panel</div>
25+
</qui-tabs>
26+
```
27+
28+
## API
29+
30+
### Attributes
31+
- `key` (required) - A unique identifier for the tab.
32+
- `name` (required) - The display name of the tab.
33+
34+
### Events
35+
- `tab-selected` - Fired when a tab is selected. Event detail includes:
36+
```json
37+
{
38+
"key": "profile"
39+
}
40+
```
41+
42+
### Methods
43+
- `selectTab(key)` - Programmatically selects a tab by its key.
44+
45+
#### Example:
46+
```javascript
47+
document.querySelector('qui-tabs').selectTab('profile');
48+
```
49+
50+
## Example
51+
52+
To run the example:
53+
54+
```bash
55+
npm install
56+
npm start
57+
```
58+
59+
## Contributing
60+
61+
Pull requests are welcome. For major changes, please open an issue first
62+
to discuss what you would like to change.
63+
64+
## License
65+
66+
[Apache 2](http://www.apache.org/licenses/LICENSE-2.0)

example/index.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Tabs Web Component Demo</title>
7+
<script type="module" src="./qui-tabs.js"></script>
8+
<style>
9+
.row {
10+
display: flex;
11+
align-items: baseline;
12+
}
13+
.col {
14+
display: flex;
15+
flex-direction: column;
16+
gap: 20px;
17+
}
18+
button {
19+
padding: 10px 20px;
20+
cursor: pointer;
21+
}
22+
</style>
23+
</head>
24+
<body>
25+
<h1>Tabs</h1>
26+
27+
<qui-tabs id="tabs">
28+
<div slot="tab-content" key="home" name="Home">Welcome to Home</div>
29+
<div slot="tab-content" key="profile" name="Profile">User Profile Information</div>
30+
<div slot="tab-content" key="settings" name="Settings">Settings Panel</div>
31+
</qui-tabs>
32+
33+
<button onclick="addNewTab()">Add New Tab</button>
34+
<button onclick="selectTab('profile')">Select Profile Tab</button>
35+
36+
<h3>Selected Tab:</h3>
37+
<p id="selected-tab">None</p>
38+
39+
<script>
40+
document.addEventListener("DOMContentLoaded", () => {
41+
const tabsElement = document.getElementById("tabs");
42+
43+
// Listen for tab selection events
44+
tabsElement.addEventListener("tab-selected", (event) => {
45+
document.getElementById("selected-tab").textContent =
46+
`Key: ${event.detail.key}`;
47+
});
48+
});
49+
50+
function addNewTab() {
51+
const tabsElement = document.getElementById("tabs");
52+
const newTabId = `tab-${tabsElement.children.length + 1}`;
53+
54+
const newTab = document.createElement("div");
55+
newTab.setAttribute("slot", "tab-content");
56+
newTab.setAttribute("key", newTabId);
57+
newTab.setAttribute("name", `Tab ${tabsElement.children.length + 1}`);
58+
newTab.textContent = `Content of ${newTabId}`;
59+
60+
tabsElement.appendChild(newTab);
61+
}
62+
63+
function selectTab(key) {
64+
const tabsElement = document.getElementById("tabs");
65+
tabsElement.selectTab(key);
66+
}
67+
</script>
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)