rizzo-css 0.0.25 → 0.0.27
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 +46 -0
- package/package.json +2 -1
- package/scaffold/utils/theme.ts +65 -0
- package/scaffold/vanilla/README-RIZZO.md +1 -1
- package/scaffold/vanilla/components/accordion.html +14 -0
- package/scaffold/vanilla/components/alert.html +14 -0
- package/scaffold/vanilla/components/avatar.html +14 -0
- package/scaffold/vanilla/components/badge.html +14 -0
- package/scaffold/vanilla/components/breadcrumb.html +14 -0
- package/scaffold/vanilla/components/button.html +14 -0
- package/scaffold/vanilla/components/cards.html +14 -0
- package/scaffold/vanilla/components/copy-to-clipboard.html +14 -0
- package/scaffold/vanilla/components/divider.html +14 -0
- package/scaffold/vanilla/components/dropdown.html +14 -0
- package/scaffold/vanilla/components/forms.html +14 -0
- package/scaffold/vanilla/components/icons.html +14 -0
- package/scaffold/vanilla/components/index.html +14 -0
- package/scaffold/vanilla/components/modal.html +14 -0
- package/scaffold/vanilla/components/navbar.html +14 -0
- package/scaffold/vanilla/components/pagination.html +14 -0
- package/scaffold/vanilla/components/progress-bar.html +14 -0
- package/scaffold/vanilla/components/search.html +14 -0
- package/scaffold/vanilla/components/settings.html +14 -0
- package/scaffold/vanilla/components/spinner.html +14 -0
- package/scaffold/vanilla/components/table.html +14 -0
- package/scaffold/vanilla/components/tabs.html +14 -0
- package/scaffold/vanilla/components/theme-switcher.html +14 -0
- package/scaffold/vanilla/components/toast.html +14 -0
- package/scaffold/vanilla/components/tooltip.html +14 -0
- package/scaffold/vanilla/index.html +14 -0
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ import 'rizzo-css';
|
|
|
56
56
|
**Without a bundler (plain HTML):** Use a CDN. Both unpkg and jsDelivr resolve the package root to the built CSS (via the `unpkg` / `jsdelivr` fields in this package). For reliability or to pin a version, use the explicit path:
|
|
57
57
|
|
|
58
58
|
```html
|
|
59
|
-
<!-- unpkg (pin version: replace @latest with @0.0.
|
|
59
|
+
<!-- unpkg (pin version: replace @latest with @0.0.27 or any version) -->
|
|
60
60
|
<link rel="stylesheet" href="https://unpkg.com/rizzo-css@latest/dist/rizzo.min.css" />
|
|
61
61
|
|
|
62
62
|
<!-- or jsDelivr -->
|
package/bin/rizzo-css.js
CHANGED
|
@@ -271,6 +271,30 @@ function copyPackageLicense(projectDir) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
/** Copy scaffold vanilla .gitignore into project so new vanilla projects have sensible defaults. */
|
|
275
|
+
function copyVanillaGitignore(projectDir) {
|
|
276
|
+
const gitignorePath = join(getPackageRoot(), 'scaffold', 'vanilla', '.gitignore');
|
|
277
|
+
if (existsSync(gitignorePath)) {
|
|
278
|
+
copyFileSync(gitignorePath, join(projectDir, '.gitignore'));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Copy Astro minimal scaffold .gitignore into project (full and minimal templates). */
|
|
283
|
+
function copyAstroGitignore(projectDir) {
|
|
284
|
+
const gitignorePath = join(getScaffoldAstroMinimalDir(), '.gitignore');
|
|
285
|
+
if (existsSync(gitignorePath)) {
|
|
286
|
+
copyFileSync(gitignorePath, join(projectDir, '.gitignore'));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Copy Svelte minimal scaffold .gitignore into project (full and minimal templates). */
|
|
291
|
+
function copySvelteGitignore(projectDir) {
|
|
292
|
+
const gitignorePath = join(getScaffoldSvelteMinimalDir(), '.gitignore');
|
|
293
|
+
if (existsSync(gitignorePath)) {
|
|
294
|
+
copyFileSync(gitignorePath, join(projectDir, '.gitignore'));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
274
298
|
/** Read rizzo-css.json from cwd. Returns { targetDir?, framework?, packageManager? } or null. */
|
|
275
299
|
function readRizzoConfig(cwd) {
|
|
276
300
|
if (!cwd || !existsSync(cwd)) return null;
|
|
@@ -985,6 +1009,10 @@ function getScaffoldAstroDir() {
|
|
|
985
1009
|
return join(getPackageRoot(), 'scaffold', 'astro');
|
|
986
1010
|
}
|
|
987
1011
|
|
|
1012
|
+
function getScaffoldUtilsDir() {
|
|
1013
|
+
return join(getPackageRoot(), 'scaffold', 'utils');
|
|
1014
|
+
}
|
|
1015
|
+
|
|
988
1016
|
function getScaffoldVanillaIndex() {
|
|
989
1017
|
return join(getPackageRoot(), 'scaffold', 'vanilla', 'index.html');
|
|
990
1018
|
}
|
|
@@ -1196,6 +1224,17 @@ function copyAstroComponents(projectDir, selectedNames) {
|
|
|
1196
1224
|
if (existsSync(themesSrc)) {
|
|
1197
1225
|
copyFileSync(themesSrc, join(targetDir, 'themes.ts'));
|
|
1198
1226
|
}
|
|
1227
|
+
// ThemeSwitcher.astro imports '../utils/theme' -> need src/components/utils/theme.ts in project
|
|
1228
|
+
const utilsDir = getScaffoldUtilsDir();
|
|
1229
|
+
const themeSrc = join(utilsDir, 'theme.ts');
|
|
1230
|
+
if (existsSync(themeSrc)) {
|
|
1231
|
+
const componentsDir = join(projectDir, 'src', 'components');
|
|
1232
|
+
const projectUtilsDir = join(componentsDir, 'utils');
|
|
1233
|
+
mkdirSync(projectUtilsDir, { recursive: true });
|
|
1234
|
+
let themeContent = readFileSync(themeSrc, 'utf8');
|
|
1235
|
+
themeContent = themeContent.replace(/from ['"]\.\.\/astro\/themes['"]/g, "from '../rizzo/themes'");
|
|
1236
|
+
writeFileSync(join(projectUtilsDir, 'theme.ts'), themeContent);
|
|
1237
|
+
}
|
|
1199
1238
|
}
|
|
1200
1239
|
if (count > 0 || copyIconsOnly) {
|
|
1201
1240
|
const msg = copyIconsOnly ? 'Icons' : count + ' Astro components + icons';
|
|
@@ -1530,6 +1569,7 @@ async function cmdInit(argv) {
|
|
|
1530
1569
|
console.warn('\nWarning: rizzo.min.css is very small. From repo root run: pnpm build:css');
|
|
1531
1570
|
}
|
|
1532
1571
|
copyPackageLicense(projectDir);
|
|
1572
|
+
copyAstroGitignore(projectDir);
|
|
1533
1573
|
if (componentsToCopy.length > 0) {
|
|
1534
1574
|
copyRizzoIcons(projectDir, 'astro');
|
|
1535
1575
|
copyAstroComponents(projectDir, componentsToCopy);
|
|
@@ -1543,6 +1583,7 @@ async function cmdInit(argv) {
|
|
|
1543
1583
|
console.warn('\nWarning: rizzo.min.css is very small. From repo root run: pnpm build:css');
|
|
1544
1584
|
}
|
|
1545
1585
|
copyPackageLicense(projectDir);
|
|
1586
|
+
copyAstroGitignore(projectDir);
|
|
1546
1587
|
if (componentsToCopy.length > 0) {
|
|
1547
1588
|
copyRizzoIcons(projectDir, 'astro');
|
|
1548
1589
|
copyAstroComponents(projectDir, componentsToCopy);
|
|
@@ -1556,6 +1597,7 @@ async function cmdInit(argv) {
|
|
|
1556
1597
|
console.warn('\nWarning: rizzo.min.css is very small. From repo root run: pnpm build:css');
|
|
1557
1598
|
}
|
|
1558
1599
|
copyPackageLicense(projectDir);
|
|
1600
|
+
copySvelteGitignore(projectDir);
|
|
1559
1601
|
if (componentsToCopy.length > 0) {
|
|
1560
1602
|
copyRizzoIcons(projectDir, 'svelte');
|
|
1561
1603
|
copySvelteComponents(projectDir, componentsToCopy);
|
|
@@ -1569,6 +1611,7 @@ async function cmdInit(argv) {
|
|
|
1569
1611
|
console.warn('\nWarning: rizzo.min.css is very small. From repo root run: pnpm build:css');
|
|
1570
1612
|
}
|
|
1571
1613
|
copyPackageLicense(projectDir);
|
|
1614
|
+
copySvelteGitignore(projectDir);
|
|
1572
1615
|
if (componentsToCopy.length > 0) {
|
|
1573
1616
|
copyRizzoIcons(projectDir, 'svelte');
|
|
1574
1617
|
copySvelteComponents(projectDir, componentsToCopy);
|
|
@@ -1607,6 +1650,7 @@ async function cmdInit(argv) {
|
|
|
1607
1650
|
writeFileSync(join(projectDir, 'js', 'main.js'), mainJs, 'utf8');
|
|
1608
1651
|
}
|
|
1609
1652
|
copyPackageLicense(projectDir);
|
|
1653
|
+
copyVanillaGitignore(projectDir);
|
|
1610
1654
|
} else if (useVanillaMinimal) {
|
|
1611
1655
|
const cssDir = join(projectDir, pathsForScaffold.targetDir);
|
|
1612
1656
|
cssTarget = join(cssDir, 'rizzo.min.css');
|
|
@@ -1631,6 +1675,7 @@ async function cmdInit(argv) {
|
|
|
1631
1675
|
writeFileSync(indexPath, minimalIndexWithScript, 'utf8');
|
|
1632
1676
|
writeFileSync(join(projectDir, SCAFFOLD_README_FILENAME), VANILLA_MINIMAL_README, 'utf8');
|
|
1633
1677
|
copyPackageLicense(projectDir);
|
|
1678
|
+
copyVanillaGitignore(projectDir);
|
|
1634
1679
|
} else {
|
|
1635
1680
|
if (framework === 'svelte') {
|
|
1636
1681
|
copyRizzoCssAndFontsForSvelte(projectDir, cssSource);
|
|
@@ -1663,6 +1708,7 @@ async function cmdInit(argv) {
|
|
|
1663
1708
|
}
|
|
1664
1709
|
writeFileSync(indexPath, indexContent, 'utf8');
|
|
1665
1710
|
writeFileSync(join(projectDir, SCAFFOLD_README_FILENAME), VANILLA_MANUAL_README, 'utf8');
|
|
1711
|
+
copyVanillaGitignore(projectDir);
|
|
1666
1712
|
} else if (framework === 'astro') {
|
|
1667
1713
|
indexPath = join(projectDir, 'public', 'index.html');
|
|
1668
1714
|
mkdirSync(join(projectDir, 'public'), { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rizzo-css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublishOnly": "cd ../.. && pnpm run lint:css:fix && pnpm run build:css && node scripts/copy-scaffold.js && node scripts/prepare-vanilla-scaffold.js"
|
|
6
6
|
},
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
".env.example",
|
|
27
27
|
"bin",
|
|
28
28
|
"scaffold/astro",
|
|
29
|
+
"scaffold/utils",
|
|
29
30
|
"scaffold/svelte",
|
|
30
31
|
"scaffold/vanilla",
|
|
31
32
|
"scaffold/astro-minimal",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme utilities — apply theme, resolve system preference, get/set stored theme.
|
|
3
|
+
* Used by ThemeSwitcher, Layout (flash prevention), and any consumer that sets data-theme.
|
|
4
|
+
*/
|
|
5
|
+
import { ALL_THEMES } from '../astro/themes';
|
|
6
|
+
|
|
7
|
+
export const THEME_SYSTEM = 'system';
|
|
8
|
+
export const DEFAULT_THEME_DARK = 'github-dark-classic';
|
|
9
|
+
export const DEFAULT_THEME_LIGHT = 'github-light';
|
|
10
|
+
|
|
11
|
+
/** Current theme id from the DOM (data-theme on html). */
|
|
12
|
+
export function getCurrentTheme(): string {
|
|
13
|
+
if (typeof document === 'undefined') return DEFAULT_THEME_DARK;
|
|
14
|
+
return document.documentElement.getAttribute('data-theme') || DEFAULT_THEME_DARK;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Stored theme from localStorage (may be 'system' or a theme id). */
|
|
18
|
+
export function getStoredTheme(): string {
|
|
19
|
+
if (typeof localStorage === 'undefined') return getCurrentTheme();
|
|
20
|
+
return localStorage.getItem('theme') || getCurrentTheme();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Resolve system preference to a concrete theme id. */
|
|
24
|
+
export function resolveSystemTheme(): string {
|
|
25
|
+
if (typeof window === 'undefined') return DEFAULT_THEME_DARK;
|
|
26
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? DEFAULT_THEME_DARK : DEFAULT_THEME_LIGHT;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Resolve stored theme to the effective theme id (for 'system', returns resolved dark/light). */
|
|
30
|
+
export function getResolvedTheme(): string {
|
|
31
|
+
const stored = getStoredTheme();
|
|
32
|
+
if (!stored || stored === THEME_SYSTEM) return resolveSystemTheme();
|
|
33
|
+
return stored;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Get { value, label } for a theme (for UI display). */
|
|
37
|
+
export function getThemeInfo(themeValue: string): { value: string; label: string } {
|
|
38
|
+
if (themeValue === THEME_SYSTEM) return { value: THEME_SYSTEM, label: 'System' };
|
|
39
|
+
const entry = ALL_THEMES.find((t) => t.value === themeValue);
|
|
40
|
+
return entry ? { value: entry.value, label: entry.label } : { value: themeValue, label: 'Theme' };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Get display label for a theme value (from config). */
|
|
44
|
+
export function getThemeLabel(themeValue: string): string {
|
|
45
|
+
return getThemeInfo(themeValue).label;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Apply a theme: set data-theme and persist to localStorage. Use for ThemeSwitcher and programmatic changes. */
|
|
49
|
+
export function applyTheme(themeValue: string): void {
|
|
50
|
+
if (typeof document === 'undefined' || typeof localStorage === 'undefined') return;
|
|
51
|
+
let effective: string;
|
|
52
|
+
if (themeValue === THEME_SYSTEM) {
|
|
53
|
+
effective = resolveSystemTheme();
|
|
54
|
+
document.documentElement.setAttribute('data-theme', effective);
|
|
55
|
+
localStorage.setItem('theme', THEME_SYSTEM);
|
|
56
|
+
} else {
|
|
57
|
+
document.documentElement.setAttribute('data-theme', themeValue);
|
|
58
|
+
localStorage.setItem('theme', themeValue);
|
|
59
|
+
effective = themeValue;
|
|
60
|
+
}
|
|
61
|
+
// Allow listeners to sync UI (e.g. ThemeSwitcher)
|
|
62
|
+
try {
|
|
63
|
+
window.dispatchEvent(new CustomEvent('rizzo-theme-change', { detail: { themeValue, effective } }));
|
|
64
|
+
} catch (_) {}
|
|
65
|
+
}
|
|
@@ -13,7 +13,7 @@ If you prefer to load CSS from a CDN instead of the local file, replace the `<li
|
|
|
13
13
|
- `<link rel="stylesheet" href="https://unpkg.com/rizzo-css@latest/dist/rizzo.min.css" />`
|
|
14
14
|
- Or jsDelivr: `https://cdn.jsdelivr.net/npm/rizzo-css@latest/dist/rizzo.min.css`
|
|
15
15
|
|
|
16
|
-
(Replace `@latest` with a specific version, e.g. `@0.0.
|
|
16
|
+
(Replace `@latest` with a specific version, e.g. `@0.0.27`, in production.)
|
|
17
17
|
|
|
18
18
|
The CLI replaces placeholders in `index.html` (e.g. `{{DATA_THEME}}`, `{{TITLE}}`) when you run `rizzo-css init`. The theme selected during init is used on first load when you have no saved preference in the browser.
|
|
19
19
|
|