rizzo-css 0.0.7 → 0.0.9
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 +1 -1
- package/bin/rizzo-css.js +101 -31
- package/dist/rizzo.min.css +11 -9
- package/package.json +1 -1
- package/scaffold/astro-app/src/layouts/Layout.astro +8 -0
- package/scaffold/astro-app/src/pages/index.astro +23 -8
- package/scaffold/svelte/Accordion.svelte +2 -1
- package/scaffold/svelte/Alert.svelte +1 -0
- package/scaffold/svelte/Breadcrumb.svelte +1 -0
- package/scaffold/svelte/CopyToClipboard.svelte +5 -2
- package/scaffold/svelte/Dropdown.svelte +30 -10
- package/scaffold/svelte/Modal.svelte +1 -0
- package/scaffold/svelte/Table.svelte +8 -4
- package/scaffold/svelte-app/README.md +28 -0
- package/scaffold/svelte-app/src/app.d.ts +15 -0
- package/scaffold/svelte-app/src/app.html +8 -0
- package/scaffold/svelte-app/src/routes/+page.svelte +27 -8
- package/scaffold/vanilla/index.html +442 -54
|
@@ -29,17 +29,18 @@
|
|
|
29
29
|
align = 'start',
|
|
30
30
|
}: Props = $props();
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
32
|
+
const fallbackId = `dropdown-${Math.random().toString(36).slice(2, 11)}`;
|
|
33
|
+
const dropdownId = $derived(id ?? fallbackId);
|
|
34
|
+
const menuId = $derived(`${dropdownId}-menu`);
|
|
35
|
+
const triggerId = $derived(`${dropdownId}-trigger`);
|
|
35
36
|
|
|
36
37
|
let open = $state(false);
|
|
37
38
|
let openSubmenuIndex = $state<number | null>(null);
|
|
38
39
|
let menuEl: HTMLDivElement;
|
|
39
40
|
let triggerEl: HTMLButtonElement;
|
|
40
41
|
|
|
41
|
-
const classes = ['dropdown', className].filter(Boolean).join(' ').trim();
|
|
42
|
-
const menuClasses = `dropdown__menu dropdown__menu--${position} dropdown__menu--${align}
|
|
42
|
+
const classes = $derived(['dropdown', className].filter(Boolean).join(' ').trim());
|
|
43
|
+
const menuClasses = $derived(`dropdown__menu dropdown__menu--${position} dropdown__menu--${align}`);
|
|
43
44
|
|
|
44
45
|
function closeMenu() {
|
|
45
46
|
open = false;
|
|
@@ -119,7 +120,8 @@
|
|
|
119
120
|
>
|
|
120
121
|
<span class="dropdown__trigger-text">{trigger}</span>
|
|
121
122
|
<span class="dropdown__icon" aria-hidden="true">
|
|
122
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
123
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" role="img" aria-labelledby="{dropdownId}-trigger-icon-title">
|
|
124
|
+
<title id="{dropdownId}-trigger-icon-title">Expand menu</title>
|
|
123
125
|
<path d="m6 9 6 6 6-6" />
|
|
124
126
|
</svg>
|
|
125
127
|
</span>
|
|
@@ -147,7 +149,8 @@
|
|
|
147
149
|
<a
|
|
148
150
|
class="dropdown__item dropdown__item--disabled={item.disabled}"
|
|
149
151
|
role="menuitem"
|
|
150
|
-
href={item.
|
|
152
|
+
href={item.href}
|
|
153
|
+
aria-label={item.label}
|
|
151
154
|
aria-disabled={item.disabled ? 'true' : undefined}
|
|
152
155
|
tabindex={open ? 0 : -1}
|
|
153
156
|
onclick={(e) => {
|
|
@@ -175,16 +178,21 @@
|
|
|
175
178
|
}
|
|
176
179
|
}}
|
|
177
180
|
onkeydown={(e) => {
|
|
181
|
+
if (item.disabled) return;
|
|
178
182
|
if (hasSubmenu && (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowRight')) {
|
|
179
183
|
e.preventDefault();
|
|
180
184
|
toggleSubmenu(index);
|
|
185
|
+
} else if (!hasSubmenu && (e.key === 'Enter' || e.key === ' ')) {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
handleItemClick(item, e as unknown as MouseEvent);
|
|
181
188
|
}
|
|
182
189
|
}}
|
|
183
190
|
>
|
|
184
191
|
<span>{item.label}</span>
|
|
185
192
|
{#if hasSubmenu}
|
|
186
193
|
<span class="dropdown__item-arrow" aria-hidden="true">
|
|
187
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
194
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" role="img" aria-labelledby="{dropdownId}-submenu-arrow-{index}-title">
|
|
195
|
+
<title id="{dropdownId}-submenu-arrow-{index}-title">Expand submenu</title>
|
|
188
196
|
<path d="m6 9 6 6 6-6" />
|
|
189
197
|
</svg>
|
|
190
198
|
</span>
|
|
@@ -205,9 +213,13 @@
|
|
|
205
213
|
<a
|
|
206
214
|
class="dropdown__item dropdown__submenu-item dropdown__item--disabled={subItem.disabled}"
|
|
207
215
|
role="menuitem"
|
|
208
|
-
href={subItem.
|
|
216
|
+
href={subItem.href}
|
|
217
|
+
aria-label={subItem.label}
|
|
209
218
|
aria-disabled={subItem.disabled ? 'true' : undefined}
|
|
210
|
-
onclick={() =>
|
|
219
|
+
onclick={(e) => {
|
|
220
|
+
if (subItem.disabled) e.preventDefault();
|
|
221
|
+
else closeMenu();
|
|
222
|
+
}}
|
|
211
223
|
>
|
|
212
224
|
<span>{subItem.label}</span>
|
|
213
225
|
</a>
|
|
@@ -223,6 +235,14 @@
|
|
|
223
235
|
closeMenu();
|
|
224
236
|
}
|
|
225
237
|
}}
|
|
238
|
+
onkeydown={(e) => {
|
|
239
|
+
if (subItem.disabled) return;
|
|
240
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
subItem.onClick?.(subItem.value ?? subItem.label);
|
|
243
|
+
closeMenu();
|
|
244
|
+
}
|
|
245
|
+
}}
|
|
226
246
|
>
|
|
227
247
|
<span>{subItem.label}</span>
|
|
228
248
|
</div>
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
<h2 id="{modalId}-title" class="modal__title">{title}</h2>
|
|
139
139
|
<button type="button" class="modal__close" aria-label="Close modal" data-modal-close onclick={close}>
|
|
140
140
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
141
|
+
<title>Close</title>
|
|
141
142
|
<path d="M18 6L6 18" />
|
|
142
143
|
<path d="M6 6l12 12" />
|
|
143
144
|
</svg>
|
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
}: Props = $props();
|
|
30
30
|
|
|
31
31
|
const tableId = `table-${Math.random().toString(36).slice(2, 11)}`;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const classes = $derived(
|
|
33
|
+
['table', striped ? 'table--striped' : '', sortable ? 'table--sortable' : '', filterable ? 'table--filterable' : '', className]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.join(' ')
|
|
36
|
+
.trim()
|
|
37
|
+
);
|
|
36
38
|
|
|
37
39
|
let sortColumnIndex = $state<number | null>(null);
|
|
38
40
|
let sortDirection = $state<'ascending' | 'descending'>('ascending');
|
|
@@ -85,6 +87,7 @@
|
|
|
85
87
|
<label for="{tableId}-filter" class="sr-only">Filter table</label>
|
|
86
88
|
<span class="table__filter-icon" aria-hidden="true">
|
|
87
89
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="table__filter-icon-svg" aria-hidden="true">
|
|
90
|
+
<title>Filter</title>
|
|
88
91
|
<path d="M4 6h16M4 12h10M4 18h6" />
|
|
89
92
|
</svg>
|
|
90
93
|
</span>
|
|
@@ -128,6 +131,7 @@
|
|
|
128
131
|
<span class="table__cell-content">{col.label}</span>
|
|
129
132
|
<span class="table__sort-icon" aria-hidden="true">
|
|
130
133
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="table__sort-icon-svg" aria-hidden="true">
|
|
134
|
+
<title>Sort</title>
|
|
131
135
|
<path d="M3 6h18M7 12h10M10 18h4" />
|
|
132
136
|
</svg>
|
|
133
137
|
</span>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# SvelteKit + Rizzo CSS
|
|
2
|
+
|
|
3
|
+
This project was scaffolded with `npx rizzo-css init` (Svelte).
|
|
4
|
+
|
|
5
|
+
## First-time setup
|
|
6
|
+
|
|
7
|
+
**Install dependencies before running any SvelteKit command:**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm install
|
|
11
|
+
# or: npm install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then start the dev server:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The theme selected during `rizzo-css init` is set in `src/app.html` (`data-theme`) and is used on first load when you have no saved preference in the browser.
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
- `pnpm dev` — Start dev server
|
|
25
|
+
- `pnpm build` — Build for production
|
|
26
|
+
- `pnpm preview` — Preview production build
|
|
27
|
+
|
|
28
|
+
Docs: [rizzo-css.vercel.app](https://rizzo-css.vercel.app)
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
2
2
|
// for information about these interfaces
|
|
3
|
+
|
|
4
|
+
/** Toast options (injected by app.html script from Rizzo CSS scaffold) */
|
|
5
|
+
interface ToastOptions {
|
|
6
|
+
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
7
|
+
position?: string;
|
|
8
|
+
autoDismiss?: number;
|
|
9
|
+
dismissible?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
declare global {
|
|
4
13
|
namespace App {
|
|
5
14
|
// interface Error {}
|
|
@@ -8,6 +17,12 @@ declare global {
|
|
|
8
17
|
// interface PageState {}
|
|
9
18
|
// interface Platform {}
|
|
10
19
|
}
|
|
20
|
+
|
|
21
|
+
interface Window {
|
|
22
|
+
showToast?(message: string, options?: ToastOptions): string | null;
|
|
23
|
+
removeToast?(id: string): void;
|
|
24
|
+
removeAllToasts?(): void;
|
|
25
|
+
}
|
|
11
26
|
}
|
|
12
27
|
|
|
13
28
|
export {};
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<!-- Theme flash prevention + accessibility (same as main site) -->
|
|
7
|
+
<script>
|
|
8
|
+
(function(){try{var s=localStorage.getItem('theme');var d='github-dark-classic';var l='github-light';var initial=document.documentElement.getAttribute('data-theme');var r=!s?(initial||(matchMedia('(prefers-color-scheme: dark)').matches?d:l)):s==='system'?(matchMedia('(prefers-color-scheme: dark)').matches?d:l):s;document.documentElement.setAttribute('data-theme',r);var f=localStorage.getItem('fontSizeScale');if(f)document.documentElement.style.setProperty('--font-size-scale',f);if(localStorage.getItem('reducedMotion')==='true')document.documentElement.classList.add('reduced-motion');if(localStorage.getItem('highContrast')==='true')document.documentElement.classList.add('high-contrast');var b=localStorage.getItem('scrollbarStyle')||'thin';if(b==='thick')document.documentElement.classList.add('scrollbar-thick');else if(b==='hidden')document.documentElement.classList.add('scrollbar-hidden','hide-scrollbars');}catch(e){}})();
|
|
9
|
+
</script>
|
|
10
|
+
<!-- Toast: showToast, removeToast, removeAllToasts -->
|
|
11
|
+
<script>
|
|
12
|
+
(function(){if(typeof window==='undefined'||window.showToast)return;function t(m,o){if(!m)return null;o=o||{};var v=o.variant||'info',p=o.position||'top-right',a=o.autoDismiss!==undefined?o.autoDismiss:5000,d=o.dismissible!==undefined?o.dismissible:true,i='toast-'+Math.random().toString(36).substr(2,9);function c(){if(!document.body)return;var cn=document.getElementById('toast-container-'+p);if(!cn){cn=document.createElement('div');cn.id='toast-container-'+p;cn.className='toast-container toast-container--'+p;cn.style.cssText='display:flex;visibility:visible;z-index:1100';document.body.appendChild(cn);}var to=document.createElement('div');to.id=i;to.className='alert alert--'+v;to.setAttribute('role','alert');to.setAttribute('aria-live','polite');to.style.cssText='display:flex;visibility:visible;opacity:0;transition:opacity .3s ease-out,transform .3s ease-out';var ir=p.indexOf('right')!==-1,il=p.indexOf('left')!==-1;to.style.transform=ir?'translateX(100%)':il?'translateX(-100%)':'translateY(-100%)';var co=document.createElement('div');co.className='alert__content';co.textContent=m;to.appendChild(co);if(d){var cb=document.createElement('button');cb.type='button';cb.className='alert__close';cb.setAttribute('aria-label','Dismiss toast');cb.innerHTML='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><line x1="4" y1="4" x2="12" y2="12"></line><line x1="12" y1="4" x2="4" y2="12"></line></svg>';to.appendChild(cb);cb.onclick=function(){to.style.opacity='0';to.style.transform=ir?'translateX(100%)':il?'translateX(-100%)':'translateY(-100%)';setTimeout(function(){if(to.parentNode)to.remove();if(cn.children.length===0)cn.remove();},300);};}cn.appendChild(to);requestAnimationFrame(function(){to.offsetHeight;setTimeout(function(){requestAnimationFrame(function(){to.style.opacity='1';to.style.transform=ir||il?'translateX(0)':'translateY(0)';});},10);});if(a>0)setTimeout(function(){if(to.parentNode){to.style.opacity='0';to.style.transform=ir?'translateX(100%)':il?'translateX(-100%)':'translateY(-100%)';setTimeout(function(){if(to.parentNode)to.remove();if(cn.children.length===0)cn.remove();},300);}},a);return i;}document.body?c():document.addEventListener('DOMContentLoaded',c);return i;}function r(i){var to=document.getElementById(i);if(to){var cn=to.parentElement;to.style.opacity='0';to.style.transform='translateY(-10px)';setTimeout(function(){if(to.parentNode)to.remove();if(cn&&cn.classList.contains('toast-container')&&!cn.children.length)cn.remove();},300);}}function ra(){document.querySelectorAll('.toast-container').forEach(function(c){c.querySelectorAll('.alert').forEach(function(t){t.style.opacity='0';t.style.transform='translateY(-10px)';});setTimeout(function(){c.remove();},300);});}window.showToast=t;window.removeToast=r;window.removeAllToasts=ra;})();
|
|
13
|
+
</script>
|
|
6
14
|
<!-- Rizzo CSS: full bundle (reset + base + components + themes) -->
|
|
7
15
|
<link rel="stylesheet" href="/css/rizzo.min.css" />
|
|
8
16
|
%sveltekit.head%
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
function showDemoToast() {
|
|
3
|
+
if (typeof window !== 'undefined' && window.showToast) {
|
|
4
|
+
window.showToast('Hello from Rizzo!', { variant: 'success' });
|
|
5
|
+
}
|
|
6
|
+
}
|
|
3
7
|
</script>
|
|
4
8
|
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</
|
|
9
|
+
<a href="#main-content" class="skip-link">Skip to main content</a>
|
|
10
|
+
<header class="container flex flex-wrap items-center justify-between gap-4" style="padding-top: var(--spacing-4); padding-bottom: var(--spacing-4); border-bottom: 1px solid var(--border);">
|
|
11
|
+
<a href="/" class="font-semibold" style="font-size: var(--font-size-lg); color: var(--text); text-decoration: none;">{{TITLE}}</a>
|
|
12
|
+
<a href="https://rizzo-css.vercel.app/docs/getting-started" class="btn btn-outline" target="_blank" rel="noopener noreferrer">Docs</a>
|
|
13
|
+
</header>
|
|
14
|
+
<main id="main-content" class="flex flex-col items-center justify-center text-center min-h-screen" style="padding: var(--spacing-12) var(--spacing-4); min-height: calc(100vh - 4rem);">
|
|
15
|
+
<span class="badge badge--primary badge--sm mb-4">Svelte + Rizzo CSS</span>
|
|
16
|
+
<h1 style="font-size: clamp(2.5rem, 8vw, 4rem); font-weight: 800; line-height: 1.1; margin: 0 0 var(--spacing-4) 0; color: var(--text);">Build something great</h1>
|
|
17
|
+
<p style="font-size: var(--font-size-xl); color: var(--text-dim); max-width: 42ch; margin: 0 0 var(--spacing-8) 0; line-height: var(--line-height-relaxed);">Same design system as Vanilla JS and Astro — 14 themes, 24 components, full keyboard and screen reader support.</p>
|
|
18
|
+
<div class="flex flex-wrap justify-center gap-4 mb-12">
|
|
19
|
+
<a href="https://rizzo-css.vercel.app/docs/getting-started" class="btn btn-primary" target="_blank" rel="noopener noreferrer">Get started</a>
|
|
20
|
+
<a href="https://rizzo-css.vercel.app/docs/components" class="btn btn-outline" target="_blank" rel="noopener noreferrer">Components</a>
|
|
21
|
+
<button type="button" class="btn btn-outline" on:click={showDemoToast}>Show toast</button>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="flex flex-wrap justify-center gap-3 mb-16">
|
|
24
|
+
<span class="badge badge--info">14 themes</span>
|
|
25
|
+
<span class="badge badge--info">24 components</span>
|
|
26
|
+
<span class="badge badge--info">WCAG AA</span>
|
|
27
|
+
</div>
|
|
28
|
+
<footer style="margin-top: auto; padding-top: var(--spacing-8); color: var(--text-dim); font-size: var(--font-size-sm);">
|
|
29
|
+
<a href="https://rizzo-css.vercel.app" style="color: var(--accent);">Rizzo CSS</a> — design system for the web
|
|
30
|
+
</footer>
|
|
12
31
|
</main>
|