@leftium/logo 0.0.2 → 0.2.0

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.
Files changed (34) hide show
  1. package/dist/AppLogo.svelte +146 -0
  2. package/dist/AppLogo.svelte.d.ts +7 -0
  3. package/dist/LeftiumLogo.svelte +267 -186
  4. package/dist/LeftiumLogo.svelte.d.ts +1 -0
  5. package/dist/app-logo/color-transform.d.ts +40 -0
  6. package/dist/app-logo/color-transform.js +142 -0
  7. package/dist/app-logo/config-serialization.d.ts +80 -0
  8. package/dist/app-logo/config-serialization.js +489 -0
  9. package/dist/app-logo/defaults.d.ts +60 -0
  10. package/dist/app-logo/defaults.js +55 -0
  11. package/dist/app-logo/generate-favicon-set.d.ts +44 -0
  12. package/dist/app-logo/generate-favicon-set.js +97 -0
  13. package/dist/app-logo/generate-ico.d.ts +18 -0
  14. package/dist/app-logo/generate-ico.js +63 -0
  15. package/dist/app-logo/generate-png.d.ts +16 -0
  16. package/dist/app-logo/generate-png.js +60 -0
  17. package/dist/app-logo/generate-svg.d.ts +9 -0
  18. package/dist/app-logo/generate-svg.js +160 -0
  19. package/dist/app-logo/iconify.d.ts +35 -0
  20. package/dist/app-logo/iconify.js +223 -0
  21. package/dist/app-logo/squircle.d.ts +43 -0
  22. package/dist/app-logo/squircle.js +213 -0
  23. package/dist/app-logo/types.d.ts +39 -0
  24. package/dist/app-logo/types.js +1 -0
  25. package/dist/assets/logo-parts/glow-squircle.svg +44 -0
  26. package/dist/index.d.ts +8 -3
  27. package/dist/index.js +9 -3
  28. package/dist/leftium-logo/generate-svg.d.ts +29 -0
  29. package/dist/leftium-logo/generate-svg.js +470 -0
  30. package/dist/tooltip.d.ts +18 -0
  31. package/dist/tooltip.js +38 -0
  32. package/dist/webgl-ripples/webgl-ripples.d.ts +0 -4
  33. package/dist/webgl-ripples/webgl-ripples.js +1 -1
  34. package/package.json +35 -20
@@ -0,0 +1,146 @@
1
+ <script lang="ts">
2
+ import type { AppLogoProps, GradientConfig } from './app-logo/types.js';
3
+ import { APP_LOGO_DEFAULTS, DEFAULT_EMOJI_STYLE } from './app-logo/defaults.js';
4
+ import { resolveIcon, type ResolvedIcon } from './app-logo/iconify.js';
5
+ import { applyColorMode } from './app-logo/color-transform.js';
6
+ import { generateCornerPath } from './app-logo/squircle.js';
7
+
8
+ let {
9
+ icon = APP_LOGO_DEFAULTS.icon,
10
+ iconColor = APP_LOGO_DEFAULTS.iconColor,
11
+ iconColorMode = APP_LOGO_DEFAULTS.iconColorMode,
12
+ iconSize = APP_LOGO_DEFAULTS.iconSize,
13
+ iconOffsetX = APP_LOGO_DEFAULTS.iconOffsetX,
14
+ iconOffsetY = APP_LOGO_DEFAULTS.iconOffsetY,
15
+ iconRotation = APP_LOGO_DEFAULTS.iconRotation,
16
+ grayscaleLightness = 100,
17
+ cornerRadius = APP_LOGO_DEFAULTS.cornerRadius,
18
+ cornerShape = APP_LOGO_DEFAULTS.cornerShape,
19
+ background = APP_LOGO_DEFAULTS.background as AppLogoProps['background'],
20
+ size = APP_LOGO_DEFAULTS.size,
21
+ emojiStyle = DEFAULT_EMOJI_STYLE
22
+ }: AppLogoProps & { emojiStyle?: string } = $props();
23
+
24
+ // Resolved icon state — use $state.raw since this is replaced, not mutated
25
+ let resolved: ResolvedIcon | null = $state.raw(null);
26
+
27
+ // Fetch icon when the icon prop changes
28
+ $effect(() => {
29
+ const currentIcon = icon;
30
+ const currentEmojiStyle = emojiStyle;
31
+ resolved = null;
32
+
33
+ resolveIcon(currentIcon, currentEmojiStyle).then((result) => {
34
+ // Only update if icon/emojiStyle hasn't changed while we were fetching
35
+ if (icon === currentIcon && emojiStyle === currentEmojiStyle) {
36
+ resolved = result;
37
+ }
38
+ });
39
+ });
40
+
41
+ // Apply color transformation to the resolved SVG content
42
+ let coloredSvgContent = $derived.by(() => {
43
+ const r = resolved;
44
+ if (!r) return '';
45
+ return applyColorMode(
46
+ r.svgContent,
47
+ r.isMonochrome,
48
+ iconColorMode,
49
+ iconColor,
50
+ grayscaleLightness
51
+ );
52
+ });
53
+
54
+ // Build the full inline SVG with viewBox and 100% sizing
55
+ let iconHtml = $derived.by(() => {
56
+ const r = resolved;
57
+ if (!r) return '';
58
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${r.viewBox}" width="100%" height="100%" preserveAspectRatio="xMidYMid meet">${coloredSvgContent}</svg>`;
59
+ });
60
+
61
+ // Build background CSS from either a solid color string or GradientConfig
62
+ let backgroundStyle = $derived.by(() => {
63
+ if (typeof background === 'string') {
64
+ return `background-color: ${background};`;
65
+ }
66
+
67
+ // GradientConfig
68
+ const grad = background as GradientConfig;
69
+ const angle = grad.angle ?? 45;
70
+ const position = grad.position ?? 0;
71
+ const scale = grad.scale ?? 1;
72
+
73
+ // Transform stop positions to account for position and scale.
74
+ // Default stops span 0% to 100%. Scale compresses/expands them,
75
+ // and position shifts them along the axis.
76
+ const colorStops = grad.colors
77
+ .map((color, i) => {
78
+ const baseOffset = grad.stops?.[i] ?? i / (grad.colors.length - 1);
79
+ // Scale around center (0.5), then shift by position
80
+ const adjusted = (baseOffset - 0.5) / scale + 0.5 - position / 200;
81
+ return `${color} ${(adjusted * 100).toFixed(1)}%`;
82
+ })
83
+ .join(', ');
84
+
85
+ return `background-image: linear-gradient(${angle}deg, ${colorStops});`;
86
+ });
87
+
88
+ // Compute CSS clip-path for non-'round' corner shapes
89
+ let clipPathStyle = $derived.by(() => {
90
+ if (cornerShape === 'round' || !cornerRadius) return undefined;
91
+ const pathD = generateCornerPath(size, cornerRadius, cornerShape);
92
+ return `path('${pathD}')`;
93
+ });
94
+
95
+ // Icon wrapper transform for offset and rotation
96
+ let iconTransform = $derived.by(() => {
97
+ const parts: string[] = [];
98
+ if (iconOffsetX || iconOffsetY) {
99
+ parts.push(`translate(${iconOffsetX}%, ${iconOffsetY}%)`);
100
+ }
101
+ if (iconRotation) {
102
+ parts.push(`rotate(${iconRotation}deg)`);
103
+ }
104
+ return parts.length > 0 ? parts.join(' ') : undefined;
105
+ });
106
+ </script>
107
+
108
+ <div class="app-logo" style:width="{size}px" style:height="{size}px">
109
+ <div
110
+ class="app-logo-square"
111
+ style="{backgroundStyle} {cornerShape === 'round' ? `border-radius: ${cornerRadius}%;` : ''}"
112
+ style:clip-path={clipPathStyle}
113
+ >
114
+ {#if iconHtml}
115
+ <div
116
+ class="app-logo-icon"
117
+ style:width="{iconSize}%"
118
+ style:height="{iconSize}%"
119
+ style:transform={iconTransform}
120
+ >
121
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
122
+ {@html iconHtml}
123
+ </div>
124
+ {/if}
125
+ </div>
126
+ </div>
127
+
128
+ <style>
129
+ .app-logo {
130
+ display: inline-block;
131
+ }
132
+
133
+ .app-logo-square {
134
+ position: relative;
135
+ width: 100%;
136
+ height: 100%;
137
+ overflow: hidden;
138
+ }
139
+
140
+ .app-logo-icon {
141
+ position: absolute;
142
+ top: 50%;
143
+ left: 50%;
144
+ translate: -50% -50%;
145
+ }
146
+ </style>
@@ -0,0 +1,7 @@
1
+ import type { AppLogoProps } from './app-logo/types.js';
2
+ type $$ComponentProps = AppLogoProps & {
3
+ emojiStyle?: string;
4
+ };
5
+ declare const AppLogo: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type AppLogo = ReturnType<typeof AppLogo>;
7
+ export default AppLogo;