@leftium/logo 0.0.1 → 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/LICENSE +21 -0
- package/dist/AppLogo.svelte +137 -0
- package/dist/AppLogo.svelte.d.ts +4 -0
- package/dist/LeftiumLogo.svelte +269 -187
- 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 +1 -5
- package/dist/webgl-ripples/webgl-ripples.js +1 -1
- package/package.json +39 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Leftium
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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>
|