This commit is contained in:
@@ -30,7 +30,7 @@ Indicator uses **daisyUI Indicator and Badge classes**:
|
||||
|
||||
```javascript
|
||||
Indicator({ value: "3", class: "badge-primary" },
|
||||
Button({ class: "btn" }, "Notifications")
|
||||
button({ class: "btn" }, "Notifications")
|
||||
);
|
||||
```
|
||||
|
||||
@@ -47,15 +47,15 @@ Indicator({ value: "3", class: "badge-primary" },
|
||||
|
||||
```javascript
|
||||
const BasicDemo = () => {
|
||||
return Div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
return div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
Indicator({ value: '3', class: 'badge-primary' },
|
||||
Div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '📦')
|
||||
div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '📦')
|
||||
),
|
||||
Indicator({ value: '99+', class: 'badge-secondary' },
|
||||
Div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '🔔')
|
||||
div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '🔔')
|
||||
),
|
||||
Indicator({ value: 'New', class: 'badge-accent' },
|
||||
Div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '✨')
|
||||
div({ class: 'w-16 h-16 bg-base-300 rounded-lg flex items-center justify-center' }, '✨')
|
||||
)
|
||||
]);
|
||||
};
|
||||
@@ -73,20 +73,20 @@ mount(BasicDemo, '#demo-basic');
|
||||
|
||||
```javascript
|
||||
const StatusDemo = () => {
|
||||
return Div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
return div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
Indicator({ value: '●', class: 'badge-success badge-xs' },
|
||||
Div({ class: 'avatar placeholder' }, [
|
||||
Div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'JD')
|
||||
div({ class: 'avatar placeholder' }, [
|
||||
div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'JD')
|
||||
])
|
||||
),
|
||||
Indicator({ value: '●', class: 'badge-warning badge-xs' },
|
||||
Div({ class: 'avatar placeholder' }, [
|
||||
Div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'JS')
|
||||
div({ class: 'avatar placeholder' }, [
|
||||
div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'JS')
|
||||
])
|
||||
),
|
||||
Indicator({ value: '●', class: 'badge-error badge-xs' },
|
||||
Div({ class: 'avatar placeholder' }, [
|
||||
Div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'BC')
|
||||
div({ class: 'avatar placeholder' }, [
|
||||
div({ class: 'bg-neutral text-neutral-content rounded-full w-12 h-12 flex items-center justify-center' }, 'BC')
|
||||
])
|
||||
)
|
||||
]);
|
||||
@@ -107,22 +107,22 @@ mount(StatusDemo, '#demo-status');
|
||||
const ReactiveDemo = () => {
|
||||
const count = $(0);
|
||||
|
||||
return Div({ class: 'flex flex-col gap-4 items-center' }, [
|
||||
return div({ class: 'flex flex-col gap-4 items-center' }, [
|
||||
Indicator({
|
||||
value: () => count() > 0 ? count() : null,
|
||||
class: 'badge-primary'
|
||||
},
|
||||
Button({
|
||||
button({
|
||||
class: 'btn btn-lg btn-primary',
|
||||
onclick: () => count(count() + 1)
|
||||
}, 'Notifications')
|
||||
),
|
||||
Div({ class: 'flex gap-2' }, [
|
||||
Button({
|
||||
div({ class: 'flex gap-2' }, [
|
||||
button({
|
||||
class: 'btn btn-sm',
|
||||
onclick: () => count(Math.max(0, count() - 1))
|
||||
}, 'Decrease'),
|
||||
Button({
|
||||
button({
|
||||
class: 'btn btn-sm btn-ghost',
|
||||
onclick: () => count(0)
|
||||
}, 'Clear')
|
||||
@@ -161,24 +161,24 @@ const CartDemo = () => {
|
||||
|
||||
const total = () => cart().reduce((sum, item) => sum + item.price, 0);
|
||||
|
||||
return Div({ class: 'flex flex-col gap-4' }, [
|
||||
Div({ class: 'flex justify-between items-center' }, [
|
||||
return div({ class: 'flex flex-col gap-4' }, [
|
||||
div({ class: 'flex justify-between items-center' }, [
|
||||
Indicator({
|
||||
value: () => cart().length,
|
||||
class: 'badge-primary'
|
||||
},
|
||||
Button({ class: 'btn', onclick: addItem }, '🛒 Add to Cart')
|
||||
button({ class: 'btn', onclick: addItem }, '🛒 Add to Cart')
|
||||
),
|
||||
Span({ class: 'text-lg font-bold' }, () => `Total: $${total()}`)
|
||||
span({ class: 'text-lg font-bold' }, () => `Total: $${total()}`)
|
||||
]),
|
||||
() => cart().length === 0
|
||||
? Div({ class: 'alert alert-soft text-center' }, 'Cart is empty')
|
||||
: Div({ class: 'flex flex-col gap-2' }, cart().map(item =>
|
||||
Div({ class: 'flex justify-between items-center p-2 bg-base-200 rounded-lg' }, [
|
||||
Span({}, item.name),
|
||||
Div({ class: 'flex gap-2 items-center' }, [
|
||||
Span({ class: 'text-sm font-bold' }, `$${item.price}`),
|
||||
Button({
|
||||
? div({ class: 'alert alert-soft text-center' }, 'Cart is empty')
|
||||
: div({ class: 'flex flex-col gap-2' }, cart().map(item =>
|
||||
div({ class: 'flex justify-between items-center p-2 bg-base-200 rounded-lg' }, [
|
||||
span({}, item.name),
|
||||
div({ class: 'flex gap-2 items-center' }, [
|
||||
span({ class: 'text-sm font-bold' }, `$${item.price}`),
|
||||
button({
|
||||
class: 'btn btn-xs btn-ghost btn-circle',
|
||||
onclick: () => removeItem(item.id)
|
||||
}, '✕')
|
||||
@@ -219,15 +219,15 @@ const InboxDemo = () => {
|
||||
}
|
||||
};
|
||||
|
||||
return Div({ class: 'flex flex-col gap-4' }, [
|
||||
Div({ class: 'flex justify-between items-center' }, [
|
||||
return div({ class: 'flex flex-col gap-4' }, [
|
||||
div({ class: 'flex justify-between items-center' }, [
|
||||
Indicator({
|
||||
value: () => unread(),
|
||||
class: 'badge-primary'
|
||||
},
|
||||
Span({ class: 'text-lg font-bold' }, 'Inbox')
|
||||
span({ class: 'text-lg font-bold' }, 'Inbox')
|
||||
),
|
||||
Button({
|
||||
button({
|
||||
class: 'btn btn-sm btn-ghost',
|
||||
onclick: () => {
|
||||
messages().forEach(m => m.read = true);
|
||||
@@ -236,14 +236,14 @@ const InboxDemo = () => {
|
||||
}
|
||||
}, 'Mark all read')
|
||||
]),
|
||||
Div({ class: 'flex flex-col gap-2' }, () => messages().map(msg =>
|
||||
Div({
|
||||
div({ class: 'flex flex-col gap-2' }, () => messages().map(msg =>
|
||||
div({
|
||||
class: `p-3 rounded-lg cursor-pointer transition-all ${msg.read ? 'bg-base-200 opacity-60' : 'bg-primary/10 border-l-4 border-primary'}`,
|
||||
onclick: () => markAsRead(msg.id)
|
||||
}, [
|
||||
Div({ class: 'font-medium' }, msg.from),
|
||||
Div({ class: 'text-sm' }, msg.subject),
|
||||
!msg.read && Span({ class: 'badge badge-xs badge-primary mt-1' }, 'New')
|
||||
div({ class: 'font-medium' }, msg.from),
|
||||
div({ class: 'text-sm' }, msg.subject),
|
||||
!msg.read && span({ class: 'badge badge-xs badge-primary mt-1' }, 'New')
|
||||
])
|
||||
))
|
||||
]);
|
||||
@@ -263,20 +263,20 @@ mount(InboxDemo, '#demo-inbox');
|
||||
|
||||
```javascript
|
||||
const VariantsDemo = () => {
|
||||
return Div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
return div({ class: 'flex flex-wrap gap-8 justify-center' }, [
|
||||
Indicator({ value: '3', class: 'badge-primary badge-sm' },
|
||||
Div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '📧')
|
||||
div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '📧')
|
||||
),
|
||||
Indicator({ value: '99+', class: 'badge-secondary badge-md' },
|
||||
Div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '🔔')
|
||||
div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '🔔')
|
||||
),
|
||||
Indicator({ value: '●', class: 'badge-success badge-xs' },
|
||||
Div({ class: 'avatar' }, [
|
||||
Div({ class: 'w-10 h-10 rounded-full bg-primary' })
|
||||
div({ class: 'avatar' }, [
|
||||
div({ class: 'w-10 h-10 rounded-full bg-primary' })
|
||||
])
|
||||
),
|
||||
Indicator({ value: '!', class: 'badge-error badge-sm' },
|
||||
Div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '⚠️')
|
||||
div({ class: 'w-12 h-12 bg-base-300 rounded-lg flex items-center justify-center' }, '⚠️')
|
||||
)
|
||||
]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user