Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d62e99b17e | |||
| 7c142eb677 | |||
| 70a38f504b | |||
| 0fc4913209 | |||
| 4b2fb8868a | |||
| 0efb288a93 |
1677
dist/sigpro-ui.cjs
vendored
Normal file
1677
dist/sigpro-ui.cjs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1621
dist/sigpro-ui.esm.js
vendored
Normal file
1621
dist/sigpro-ui.esm.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1385
dist/sigpro-ui.js
vendored
1385
dist/sigpro-ui.js
vendored
File diff suppressed because it is too large
Load Diff
7
dist/sigpro-ui.min.js
vendored
7
dist/sigpro-ui.min.js
vendored
File diff suppressed because one or more lines are too long
1680
dist/sigpro-ui.umd.js
vendored
Normal file
1680
dist/sigpro-ui.umd.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
dist/sigpro-ui.umd.min.js
vendored
Normal file
1
dist/sigpro-ui.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -8,214 +8,241 @@ Styled button with full DaisyUI support and reactive states.
|
||||
|
||||
## Props
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `class` | `string` | `''` | Additional CSS classes (DaisyUI + Tailwind) |
|
||||
| `disabled` | `boolean \| Signal<boolean>` | `false` | Disabled state |
|
||||
| `loading` | `boolean \| Signal<boolean>` | `false` | Shows loading spinner |
|
||||
| `badge` | `string \| Signal<string>` | `-` | Badge text displayed on corner |
|
||||
| `badgeClass` | `string` | `'badge-secondary'` | Badge styling classes |
|
||||
| `tooltip` | `string \| Signal<string>` | `-` | Tooltip text on hover |
|
||||
| `icon` | `string \| VNode \| Signal` | `-` | Icon displayed before text |
|
||||
| `onclick` | `function` | `-` | Click event handler |
|
||||
| `type` | `string` | `'button'` | Native button type |
|
||||
| Prop | Type | Default | Description |
|
||||
| :----------- | :--------------------------- | :------------------ | :------------------------------------------ |
|
||||
| `class` | `string` | `''` | Additional CSS classes (DaisyUI + Tailwind) |
|
||||
| `disabled` | `boolean \| Signal<boolean>` | `false` | Disabled state |
|
||||
| `loading` | `boolean \| Signal<boolean>` | `false` | Shows loading spinner |
|
||||
| `badge` | `string \| Signal<string>` | `-` | Badge text displayed on corner |
|
||||
| `badgeClass` | `string` | `'badge-secondary'` | Badge styling classes |
|
||||
| `tooltip` | `string \| Signal<string>` | `-` | Tooltip text on hover |
|
||||
| `icon` | `string \| VNode \| Signal` | `-` | Icon displayed before text |
|
||||
| `onclick` | `function` | `-` | Click event handler |
|
||||
| `type` | `string` | `'button'` | Native button type |
|
||||
|
||||
## Live Examples
|
||||
|
||||
### Basic Button
|
||||
|
||||
<div id="demo-basic"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button } from 'https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm';
|
||||
|
||||
const Demo = () => {
|
||||
return Button({ class: "btn-primary" }, "Click Me");
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-basic");
|
||||
</script>
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-basic" class="bg-base-100 p-6 rounded-xl border border-base-300 flex items-center justify-center"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
Button({ class: "btn-primary" }, "Click Me")
|
||||
const BasicDemo = () => {
|
||||
return Button({ class: "btn btn-primary" }, "Click Me");
|
||||
};
|
||||
$mount(BasicDemo, "#demo-basic");
|
||||
```
|
||||
|
||||
### With Loading State
|
||||
|
||||
<div id="demo-loading"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $, $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button } from '../../sigpro-ui/sigpro-ui.js';
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-loading" class="bg-base-100 p-6 rounded-xl border border-base-300 flex items-center justify-center"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
const LoadingDemo = () => {
|
||||
const isSaving = $(false);
|
||||
|
||||
const Demo = () => {
|
||||
return Button({
|
||||
class: "btn-success",
|
||||
return Button(
|
||||
{
|
||||
class: "btn btn-success",
|
||||
loading: isSaving,
|
||||
onclick: async () => {
|
||||
isSaving(true);
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
isSaving(false);
|
||||
}
|
||||
}, "Save Changes");
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-loading");
|
||||
</script>
|
||||
|
||||
```javascript
|
||||
const isSaving = $(false);
|
||||
|
||||
Button({
|
||||
class: "btn-success",
|
||||
loading: isSaving,
|
||||
onclick: async () => {
|
||||
isSaving(true);
|
||||
await saveData();
|
||||
isSaving(false);
|
||||
}
|
||||
}, "Save Changes")
|
||||
},
|
||||
},
|
||||
"Save Changes",
|
||||
);
|
||||
};
|
||||
$mount(LoadingDemo, "#demo-loading");
|
||||
```
|
||||
|
||||
### With Badge
|
||||
|
||||
<div id="demo-badge"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button } from 'https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm';
|
||||
|
||||
const Demo = () => {
|
||||
return Button({
|
||||
class: "btn-outline",
|
||||
badge: "3",
|
||||
badgeClass: "badge-accent"
|
||||
}, "Notifications");
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-badge");
|
||||
</script>
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-badge" class="bg-base-100 p-6 rounded-xl border border-base-300 flex items-center justify-center"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
Button({
|
||||
class: "btn-outline",
|
||||
badge: "3",
|
||||
badgeClass: "badge-accent"
|
||||
}, "Notifications")
|
||||
const BadgeDemo = () => {
|
||||
return Button(
|
||||
{
|
||||
class: "btn btn-outline",
|
||||
badge: "3",
|
||||
badgeClass: "badge-accent",
|
||||
},
|
||||
"Notifications",
|
||||
);
|
||||
};
|
||||
$mount(BadgeDemo, "#demo-badge");
|
||||
```
|
||||
|
||||
### With Tooltip
|
||||
|
||||
<div id="demo-tooltip"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button } from 'https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm';
|
||||
|
||||
const Demo = () => {
|
||||
return Button({
|
||||
class: "btn-ghost",
|
||||
tooltip: "Delete item"
|
||||
}, "Delete");
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-tooltip");
|
||||
</script>
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-tooltip" class="bg-base-100 p-6 rounded-xl border border-base-300 flex items-center justify-center"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
Button({
|
||||
class: "btn-ghost",
|
||||
tooltip: "Delete item"
|
||||
}, "Delete")
|
||||
const TooltipDemo = () => {
|
||||
return Button(
|
||||
{
|
||||
class: "btn btn-ghost",
|
||||
tooltip: "Delete item",
|
||||
},
|
||||
"Delete",
|
||||
);
|
||||
};
|
||||
$mount(TooltipDemo, "#demo-tooltip");
|
||||
```
|
||||
|
||||
### Disabled State
|
||||
|
||||
<div id="demo-disabled"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $, $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button } from 'https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm';
|
||||
|
||||
const isDisabled = $(true);
|
||||
|
||||
const Demo = () => {
|
||||
return Button({
|
||||
class: "btn-primary",
|
||||
disabled: isDisabled
|
||||
}, "Submit");
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-disabled");
|
||||
</script>
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-disabled" class="bg-base-100 p-6 rounded-xl border border-base-300 flex items-center justify-center"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
const isDisabled = $(true);
|
||||
const DisabledDemo = () => {
|
||||
const isDisabled = $(true);
|
||||
|
||||
Button({
|
||||
class: "btn-primary",
|
||||
disabled: isDisabled
|
||||
}, "Submit")
|
||||
return Button(
|
||||
{
|
||||
class: "btn btn-primary",
|
||||
disabled: isDisabled,
|
||||
},
|
||||
"Submit",
|
||||
);
|
||||
};
|
||||
$mount(DisabledDemo, "#demo-disabled");
|
||||
```
|
||||
|
||||
### All Variants
|
||||
|
||||
<div id="demo-variants"></div>
|
||||
|
||||
<script type="module">
|
||||
import { $, $mount } from 'https://cdn.jsdelivr.net/npm/sigpro@latest/+esm';
|
||||
import { Button, Div } from 'https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm';
|
||||
|
||||
const isLoading = $(false);
|
||||
|
||||
const Demo = () => {
|
||||
return Div({ class: "flex flex-wrap gap-2" }, [
|
||||
Button({ class: "btn-primary" }, "Primary"),
|
||||
Button({ class: "btn-secondary" }, "Secondary"),
|
||||
Button({ class: "btn-accent" }, "Accent"),
|
||||
Button({ class: "btn-ghost" }, "Ghost"),
|
||||
Button({ class: "btn-outline" }, "Outline"),
|
||||
Button({ class: "btn-success", loading: isLoading, onclick: () => {
|
||||
isLoading(true);
|
||||
setTimeout(() => isLoading(false), 1500);
|
||||
} }, "Loading")
|
||||
]);
|
||||
};
|
||||
|
||||
$mount(Demo, "#demo-variants");
|
||||
</script>
|
||||
<div class="card bg-base-200 border border-base-300 shadow-sm my-6">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-sm uppercase opacity-50 mb-4">Live Demo</h3>
|
||||
<div id="demo-variants" class="bg-base-100 p-6 rounded-xl border border-base-300"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```javascript
|
||||
Div({ class: "flex flex-wrap gap-2" }, [
|
||||
Button({ class: "btn-primary" }, "Primary"),
|
||||
Button({ class: "btn-secondary" }, "Secondary"),
|
||||
Button({ class: "btn-accent" }, "Accent"),
|
||||
Button({ class: "btn-ghost" }, "Ghost"),
|
||||
Button({ class: "btn-outline" }, "Outline")
|
||||
])
|
||||
```
|
||||
const VariantsDemo = () => {
|
||||
return Div({ class: "flex flex-wrap gap-2 justify-center" }, [
|
||||
Button({ class: "btn btn-primary" }, "Primary"),
|
||||
Button({ class: "btn btn-secondary" }, "Secondary"),
|
||||
Button({ class: "btn btn-accent" }, "Accent"),
|
||||
Button({ class: "btn btn-ghost" }, "Ghost"),
|
||||
Button({ class: "btn btn-outline" }, "Outline"),
|
||||
]);
|
||||
};
|
||||
$mount(VariantsDemo, "#demo-variants");
|
||||
```
|
||||
|
||||
## Ventajas de este enfoque:
|
||||
<script>
|
||||
(function() {
|
||||
const initButtonExamples = () => {
|
||||
|
||||
1. **Ejecución real** - Los ejemplos son interactivos y funcionales
|
||||
2. **Código visible** - Debajo de cada ejemplo se muestra el código fuente
|
||||
3. **Aprendizaje visual** - Los usuarios pueden ver y probar los componentes
|
||||
4. **Reactivo** - Los ejemplos con signals demuestran la reactividad en acción
|
||||
// 1. Basic Button
|
||||
const basicTarget = document.querySelector('#demo-basic');
|
||||
if (basicTarget && !basicTarget.hasChildNodes()) {
|
||||
const BasicDemo = () => Button({ class: "btn btn-primary" }, "Click Me");
|
||||
$mount(BasicDemo, basicTarget);
|
||||
}
|
||||
|
||||
## Consejos adicionales:
|
||||
// 2. Loading State
|
||||
const loadingTarget = document.querySelector('#demo-loading');
|
||||
if (loadingTarget && !loadingTarget.hasChildNodes()) {
|
||||
const LoadingDemo = () => {
|
||||
const isSaving = $(false);
|
||||
return Button({
|
||||
class: "btn btn-success",
|
||||
loading: isSaving,
|
||||
onclick: async () => {
|
||||
isSaving(true);
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
isSaving(false);
|
||||
}
|
||||
}, "Save Changes");
|
||||
};
|
||||
$mount(LoadingDemo, loadingTarget);
|
||||
}
|
||||
|
||||
Para mejorar la experiencia, podrías agregar estilos a los contenedores de los ejemplos:
|
||||
// 3. Badge
|
||||
const badgeTarget = document.querySelector('#demo-badge');
|
||||
if (badgeTarget && !badgeTarget.hasChildNodes()) {
|
||||
const BadgeDemo = () => Button({
|
||||
class: "btn btn-outline",
|
||||
badge: "3",
|
||||
badgeClass: "badge-accent"
|
||||
}, "Notifications");
|
||||
$mount(BadgeDemo, badgeTarget);
|
||||
}
|
||||
|
||||
```css
|
||||
/* En tu HTML, dentro de <style> */
|
||||
.demo-container {
|
||||
margin: 1rem 0;
|
||||
padding: 1rem;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 0.5rem;
|
||||
background: #f8fafc;
|
||||
}
|
||||
// 4. Tooltip
|
||||
const tooltipTarget = document.querySelector('#demo-tooltip');
|
||||
if (tooltipTarget && !tooltipTarget.hasChildNodes()) {
|
||||
const TooltipDemo = () => Button({
|
||||
class: "btn btn-ghost",
|
||||
tooltip: "Delete item"
|
||||
}, "Delete");
|
||||
$mount(TooltipDemo, tooltipTarget);
|
||||
}
|
||||
|
||||
// 5. Disabled State
|
||||
const disabledTarget = document.querySelector('#demo-disabled');
|
||||
if (disabledTarget && !disabledTarget.hasChildNodes()) {
|
||||
const DisabledDemo = () => {
|
||||
const isDisabled = $(true);
|
||||
return Button({
|
||||
class: "btn btn-primary",
|
||||
disabled: isDisabled
|
||||
}, "Submit");
|
||||
};
|
||||
$mount(DisabledDemo, disabledTarget);
|
||||
}
|
||||
|
||||
// 6. All Variants
|
||||
const variantsTarget = document.querySelector('#demo-variants');
|
||||
if (variantsTarget && !variantsTarget.hasChildNodes()) {
|
||||
const VariantsDemo = () => Div({ class: "flex flex-wrap gap-2 justify-center" }, [
|
||||
Button({ class: "btn btn-primary" }, "Primary"),
|
||||
Button({ class: "btn btn-secondary" }, "Secondary"),
|
||||
Button({ class: "btn btn-accent" }, "Accent"),
|
||||
Button({ class: "btn btn-ghost" }, "Ghost"),
|
||||
Button({ class: "btn btn-outline" }, "Outline")
|
||||
]);
|
||||
$mount(VariantsDemo, variantsTarget);
|
||||
}
|
||||
};
|
||||
|
||||
// Ejecutar la función después de definirla
|
||||
initButtonExamples();
|
||||
|
||||
// Registrar para navegación en Docsify
|
||||
if (window.$docsify) {
|
||||
window.$docsify.plugins = [].concat(window.$docsify.plugins || [], (hook) => {
|
||||
hook.doneEach(initButtonExamples);
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
@@ -39,13 +39,8 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
import * as sigpro from "https://cdn.jsdelivr.net/npm/sigpro@latest/+esm";
|
||||
import { UI } from "https://cdn.jsdelivr.net/npm/sigpro-ui@latest/+esm";
|
||||
window.sigpro = sigpro;
|
||||
// const ui = UI("en");
|
||||
// window.sigproui = ui;
|
||||
</script>
|
||||
<script src="https://unpkg.com/sigpro"></script>
|
||||
<script src="https://unpkg.com/sigpro-ui"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
|
||||
</body>
|
||||
|
||||
4
index.js
4
index.js
@@ -33,4 +33,8 @@ const SigproUI = {
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
SigproUI.install(window);
|
||||
}
|
||||
|
||||
export default SigproUI;
|
||||
|
||||
55
package.json
55
package.json
@@ -1,14 +1,22 @@
|
||||
{
|
||||
"name": "sigpro-ui",
|
||||
"version": "1.0.3",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"main": "./dist/sigpro-ui.js",
|
||||
"module": "./index.js",
|
||||
"unpkg": "./dist/sigpro-ui.min.js",
|
||||
"jsdelivr": "./dist/sigpro-ui.min.js",
|
||||
"version": "1.0.6",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/natxocc/sigpro-ui.git"
|
||||
},
|
||||
"main": "./dist/sigpro-ui.cjs",
|
||||
"module": "./dist/sigpro-ui.esm.js",
|
||||
"unpkg": "./dist/sigpro-ui.umd.min.js",
|
||||
"jsdelivr": "./dist/sigpro-ui.umd.min.js",
|
||||
"exports": {
|
||||
".": "./index.js"
|
||||
".": {
|
||||
"import": "./dist/sigpro-ui.esm.js",
|
||||
"require": "./dist/sigpro-ui.cjs"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/natxocc/sigpro-ui/issues"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
@@ -18,21 +26,6 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"homepage": "https://natxocc.github.io/sigpro-ui/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/natxocc/sigpro-ui.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/natxocc/sigpro-ui/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "bun x serve docs",
|
||||
"build": "bun build ./index.js --bundle --external sigpro --outfile=./dist/sigpro-ui.js --format=iife --global-name=SigProUI && bun build ./index.js --bundle --external sigpro --outfile=./dist/sigpro-ui.min.js --format=iife --global-name=SigProUI --minify",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"sigpro": ">=1.1.16"
|
||||
},
|
||||
"keywords": [
|
||||
"signals",
|
||||
"reactive",
|
||||
@@ -41,5 +34,19 @@
|
||||
"UI",
|
||||
"vanilla-js",
|
||||
"reactive-programming"
|
||||
]
|
||||
],
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"docs": "bun x serve docs",
|
||||
"build": "rollup -c",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"sigpro": ">=1.1.16"
|
||||
},
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"rollup": "^4.34.8"
|
||||
}
|
||||
}
|
||||
49
rollup.config.js
Normal file
49
rollup.config.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import terser from '@rollup/plugin-terser';
|
||||
|
||||
export default [
|
||||
// ESM
|
||||
{
|
||||
input: './index.js',
|
||||
external: ['sigpro'],
|
||||
output: {
|
||||
file: './dist/sigpro-ui.esm.js',
|
||||
format: 'esm'
|
||||
}
|
||||
},
|
||||
// CommonJS
|
||||
{
|
||||
input: './index.js',
|
||||
external: ['sigpro'],
|
||||
output: {
|
||||
file: './dist/sigpro-ui.cjs',
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
// UMD (IIFE para navegador)
|
||||
{
|
||||
input: './index.js',
|
||||
external: ['sigpro'],
|
||||
output: {
|
||||
file: './dist/sigpro-ui.umd.js',
|
||||
format: 'iife',
|
||||
name: 'SigProUI',
|
||||
globals: {
|
||||
sigpro: 'SigPro'
|
||||
}
|
||||
}
|
||||
},
|
||||
// UMD minificado
|
||||
{
|
||||
input: './index.js',
|
||||
external: ['sigpro'],
|
||||
output: {
|
||||
file: './dist/sigpro-ui.umd.min.js',
|
||||
format: 'iife',
|
||||
name: 'SigProUI',
|
||||
globals: {
|
||||
sigpro: 'SigPro'
|
||||
},
|
||||
plugins: [terser()]
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user