Compare commits

..

1 commit

Author SHA1 Message Date
Ayo
ee14bae6a2 chore: use workspaces 2026-05-14 11:51:28 +02:00
17 changed files with 397 additions and 999 deletions

4
.gitignore vendored
View file

@ -3,6 +3,4 @@ dist
*~ *~
*swo *swo
*swp *swp
custom-elements.json

View file

@ -7,7 +7,7 @@ Colored circles that can pulse. That's it. That's the component.
Copy the following to your HTML page: Copy the following to your HTML page:
```html ```html
<script type="module" src="https://esm.sh/@ayo-run/status-indicator@2.1.2/es2022/status-indicator.mjs"></script> <script type="module" src="https://esm.sh/@ayo-run/status-indicator"></script>
<status-indicator pulse status="positive"> <status-indicator pulse status="positive">
All systems operational All systems operational
@ -16,6 +16,9 @@ Copy the following to your HTML page:
See example on CodePen: https://codepen.io/ayo-run/pen/RNorXrK See example on CodePen: https://codepen.io/ayo-run/pen/RNorXrK
> [!NOTE]
> In this example, `esm.sh` bundles the base class together with the component. For most use cases, that is good enough but, still, "it depends". Copying the code will work just fine, but it woudn't hurt to read around about the trade-offs how bundling affects your application.
## Installation via NPM ## Installation via NPM
If you want to install the library as a node module, you can install the [published package](https://npmx.dev/@ayo-run/status-indicator) and the [base class](https://webcomponent.io) via NPM: If you want to install the library as a node module, you can install the [published package](https://npmx.dev/@ayo-run/status-indicator) and the [base class](https://webcomponent.io) via NPM:
@ -83,7 +86,7 @@ You can add the `pulse` attribute to make the circle... pulse
## Result ## Result
![screenshot](https://raw.githubusercontent.com/ayo-run/status-indicator/refs/heads/main/screenshot.png) ![screenshot](./screenshot.png)
--- ---

View file

@ -1,7 +0,0 @@
import { wcbStaticProps, distPaths } from 'web-component-base/cem-plugin'
export default {
globs: ['src/**/*.{js,ts}'],
outdir: '.',
plugins: [wcbStaticProps(), distPaths()],
}

43
lib/package.json Normal file
View file

@ -0,0 +1,43 @@
{
"name": "@ayo-run/status-indicator",
"version": "2.0.3",
"type": "module",
"description": "Circles with color that can pulse to indicate status",
"license": "MIT",
"author": "Ayo Ayco",
"repository": {
"type": "git",
"url": "git+https://github.com/ayo-run/status-indicator.git",
"directory": "lib"
},
"homepage": "https://status-indicator.webcomponent.io",
"module": "./dist/status-indicator.js",
"exports": {
".": {
"default": "./dist/status-indicator.js",
"import": "./dist/status-indicator.js",
"require": "./dist/status-indicator.umd.cjs"
}
},
"files": [
"dist",
"README.md",
"LICENSE",
"screenshot.png"
],
"scripts": {
"test": "echo \"Warning: no test specified\"",
"build": "vite build",
"prepare": "husky"
},
"devDependencies": {
"@types/node": "^25.6.2",
"eslint": "^10.3.0",
"husky": "^9.1.7",
"unplugin-dts": "^1.0.0",
"vite": "^8.0.11"
},
"peerDependencies": {
"web-component-base": "^4.1.2"
}
}

View file

@ -1,23 +1,18 @@
import { WebComponent, html } from 'web-component-base' import { WebComponent, html } from 'web-component-base'
type Status = 'default' | 'active' | 'positive' | 'intermediary' | 'negative' type StatusType = 'default' | 'active' | 'positive' | 'intermediary' | 'negative'
type StatusProps = { class StatusIndicator extends WebComponent {
status: Status,
pulse: boolean
}
class StatusIndicator extends WebComponent<StatusProps> {
static shadowRootInit: ShadowRootInit = { static shadowRootInit: ShadowRootInit = {
mode: 'closed' mode: 'closed'
} }
static props: StatusProps = { static props = {
status: 'default', status: 'default',
pulse: false pulse: false
} }
#indicatorColor: Record<Status, string> = { #indicatorColor: Record<StatusType, string> = {
default: '216, 226, 233', default: '216, 226, 233',
active: '0, 149, 255', active: '0, 149, 255',
positive: '75, 210, 143', positive: '75, 210, 143',
@ -48,8 +43,8 @@ class StatusIndicator extends WebComponent<StatusProps> {
marginRight: '0.05rem', marginRight: '0.05rem',
...(this.props.pulse ? this.#pulseAnimationCSSRules : []) ...(this.props.pulse ? this.#pulseAnimationCSSRules : [])
}}> </div> }}> </div>
Weeeee
<span class="status-indicator-label"><slot></slot></span> <span class="status-indicator-label">Wooooo <slot></slot></span>
${ ${
/** if pulse is set, add animation keyframes */ /** if pulse is set, add animation keyframes */

View file

@ -1,12 +1,10 @@
import { resolve } from 'node:path' import { resolve } from 'node:path'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
export default defineConfig({ export default defineConfig({
publicDir: false,
build: { build: {
lib: { lib: {
entry: resolve(import.meta.dirname, 'src/status-indicator.ts'), entry: resolve(import.meta.dirname, 'src/status-indicator.js'),
name: 'StatusIndicator', name: 'StatusIndicator',
fileName: 'status-indicator', fileName: 'status-indicator',
}, },
@ -14,10 +12,10 @@ export default defineConfig({
external: ['web-component-base'], external: ['web-component-base'],
output: { output: {
globals: { globals: {
'web-component-base': 'web-component-base', 'WebComponent': 'WebComponent',
'html': 'html'
} }
}, }
} }
}, }
plugins: [dts()]
}) })

View file

@ -1,47 +1,20 @@
{ {
"name": "@ayo-run/status-indicator", "name": "status-indicator-monorepo",
"version": "3.0.0", "version": "1.0.0",
"private": true,
"type": "module", "type": "module",
"description": "Circles with color that can pulse to indicate status",
"license": "MIT",
"author": "Ayo Ayco",
"repository": {
"type": "git",
"url": "git+https://github.com/ayo-run/status-indicator.git"
},
"homepage": "https://status-indicator.webcomponent.io",
"module": "./dist/status-indicator.js",
"types": "./dist/status-indicator.d.ts",
"exports": {
".": {
"default": "./dist/status-indicator.js",
"import": "./dist/status-indicator.js",
"require": "./dist/status-indicator.umd.cjs"
}
},
"files": [
"dist",
"README.md",
"LICENSE",
"custom-elements.json"
],
"scripts": { "scripts": {
"test": "echo \"Warning: no test specified\"", "test": "echo \"Warning: no test specified\"",
"build": "vite build && cem analyze", "dev": "pnpm -F site run dev",
"build:lib": "vite build --config vite-lib.config.ts && cem analyze", "build:site": "pnpm -F site run build",
"dev": "vite", "build:lib": "pnpm -F @ayo-run/status-indicator run build",
"prepare": "husky" "prepare": "husky"
}, },
"devDependencies": { "devDependencies": {
"@custom-elements-manifest/analyzer": "^0.11.0", "@types/node": "^25.6.2",
"@types/node": "^26.1.1", "eslint": "^10.3.0",
"eslint": "^10.7.0",
"husky": "^9.1.7", "husky": "^9.1.7",
"vite": "^8.1.5", "unplugin-dts": "^1.0.0",
"vite-plugin-dts": "^5.0.3" "vite": "^8.0.11"
}, }
"peerDependencies": {
"web-component-base": "^6.1.4"
},
"customElements": "custom-elements.json"
} }

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,5 @@
packages:
- "site"
- "lib"
allowBuilds: allowBuilds:
web-component-base: false web-component-base: false

View file

@ -18,8 +18,12 @@
<link rel="apple-touch-icon" href="apple-touch-icon.png"/> <link rel="apple-touch-icon" href="apple-touch-icon.png"/>
<link rel="shortcut icon" href="/favicon.svg" type="image/svg+xml"/> <link rel="shortcut icon" href="/favicon.svg" type="image/svg+xml"/>
<link rel="stylesheet" href="pico.min.css"> <link rel="stylesheet" href="pico.min.css">
<script type="module" src="./src/status-indicator.ts"></script>
<script type="module" src="./main.ts"></script>
<style> <style>
html, body { html, body {
height: 100% height: 100%
@ -94,7 +98,7 @@
Copy the following to your HTML page: Copy the following to your HTML page:
</p> </p>
<code><pre> <code><pre>
&lt;script type="module" src="https://esm.sh/@ayo-run/status-indicator@2.1.2/es2022/status-indicator.mjs"&gt;&lt;/script&gt; &lt;script type="module" src="https://esm.sh/@ayo-run/status-indicator"&gt;&lt;/script&gt;
&lt;status-indicator pulse status="positive"&gt; &lt;status-indicator pulse status="positive"&gt;
All systems operational All systems operational

3
site/main.ts Normal file
View file

@ -0,0 +1,3 @@
import StatusIndicator from "@ayo-run/status-indicator";
console.log(StatusIndicator)

18
site/package.json Normal file
View file

@ -0,0 +1,18 @@
{
"name": "site",
"private": true,
"version": "1.0.0",
"description": "demo site for the status-indicator web component",
"scripts": {
"dev": "vite"
},
"keywords": [
"web",
"component"
],
"author": "Ayo Ayco",
"license": "MIT",
"dependencies": {
"@ayo-run/status-indicator": "*"
}
}

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB