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