@valerius_petrini/corekit-ui 0.1.34 → 0.1.36
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 -21
- package/README.md +65 -65
- package/dist/actions/fbm.js +68 -68
- package/dist/components/Analytics.svelte +27 -27
- package/dist/components/Button.svelte +39 -39
- package/dist/components/FloatingInput.svelte +60 -60
- package/dist/components/Navbar.svelte +36 -36
- package/dist/components/NavbarElement.svelte +38 -38
- package/dist/components/SEO.svelte +42 -42
- package/dist/components/Typewriter.svelte +83 -83
- package/dist/styles/color.js +7 -7
- package/dist/styles/layout.css +40 -0
- package/dist/types/Analytics.d.ts +2 -2
- package/dist/types/Button.d.ts +11 -11
- package/dist/types/FloatingInput.d.ts +11 -11
- package/dist/types/Navbar.d.ts +13 -13
- package/dist/types/SEO.d.ts +5 -5
- package/dist/types/Typewriter.d.ts +16 -16
- package/package.json +59 -58
- package/src/lib/styles/color.ts +11 -0
- package/src/lib/styles/layout.css +40 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Valerius Petrini
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Valerius Petrini
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
# Svelte library
|
|
2
|
-
|
|
3
|
-
Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
|
|
4
|
-
|
|
5
|
-
Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
|
|
6
|
-
|
|
7
|
-
## Creating a project
|
|
8
|
-
|
|
9
|
-
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
# create a new project in the current directory
|
|
13
|
-
npx sv create
|
|
14
|
-
|
|
15
|
-
# create a new project in my-app
|
|
16
|
-
npx sv create my-app
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
To recreate this project with the same configuration:
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
# recreate this project
|
|
23
|
-
npx sv@0.12.5 create --template library --types ts --add tailwindcss="plugins:typography,forms" --install npm ./
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Developing
|
|
27
|
-
|
|
28
|
-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
npm run dev
|
|
32
|
-
|
|
33
|
-
# or start the server and open the app in a new browser tab
|
|
34
|
-
npm run dev -- --open
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
38
|
-
|
|
39
|
-
## Building
|
|
40
|
-
|
|
41
|
-
To build your library:
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
npm pack
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
To create a production version of your showcase app:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
npm run build
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
You can preview the production build with `npm run preview`.
|
|
54
|
-
|
|
55
|
-
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
56
|
-
|
|
57
|
-
## Publishing
|
|
58
|
-
|
|
59
|
-
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
|
|
60
|
-
|
|
61
|
-
To publish your library to [npm](https://www.npmjs.com):
|
|
62
|
-
|
|
63
|
-
```sh
|
|
64
|
-
npm publish
|
|
65
|
-
```
|
|
1
|
+
# Svelte library
|
|
2
|
+
|
|
3
|
+
Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
|
|
4
|
+
|
|
5
|
+
Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
|
|
6
|
+
|
|
7
|
+
## Creating a project
|
|
8
|
+
|
|
9
|
+
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
# create a new project in the current directory
|
|
13
|
+
npx sv create
|
|
14
|
+
|
|
15
|
+
# create a new project in my-app
|
|
16
|
+
npx sv create my-app
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To recreate this project with the same configuration:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
# recreate this project
|
|
23
|
+
npx sv@0.12.5 create --template library --types ts --add tailwindcss="plugins:typography,forms" --install npm ./
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Developing
|
|
27
|
+
|
|
28
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm run dev
|
|
32
|
+
|
|
33
|
+
# or start the server and open the app in a new browser tab
|
|
34
|
+
npm run dev -- --open
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
38
|
+
|
|
39
|
+
## Building
|
|
40
|
+
|
|
41
|
+
To build your library:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm pack
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To create a production version of your showcase app:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can preview the production build with `npm run preview`.
|
|
54
|
+
|
|
55
|
+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
56
|
+
|
|
57
|
+
## Publishing
|
|
58
|
+
|
|
59
|
+
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
|
|
60
|
+
|
|
61
|
+
To publish your library to [npm](https://www.npmjs.com):
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm publish
|
|
65
|
+
```
|
package/dist/actions/fbm.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
const FBM_VERTEX_SHADER_SOURCE = `
|
|
2
|
-
attribute vec4 aVertexPosition;
|
|
3
|
-
|
|
4
|
-
void main() {
|
|
5
|
-
gl_Position = aVertexPosition;
|
|
1
|
+
const FBM_VERTEX_SHADER_SOURCE = `
|
|
2
|
+
attribute vec4 aVertexPosition;
|
|
3
|
+
|
|
4
|
+
void main() {
|
|
5
|
+
gl_Position = aVertexPosition;
|
|
6
6
|
}`;
|
|
7
|
-
const FBM_FRAGMENT_SHADER_SOURCE = `
|
|
8
|
-
precision mediump float;
|
|
9
|
-
|
|
10
|
-
uniform vec2 u_resolution;
|
|
11
|
-
uniform float u_seed;
|
|
12
|
-
uniform float u_scale;
|
|
13
|
-
uniform int u_octaves;
|
|
14
|
-
uniform int u_warp;
|
|
15
|
-
|
|
16
|
-
const int maxOctaves = 20;
|
|
17
|
-
const int maxWarps = 5;
|
|
18
|
-
|
|
19
|
-
float rand(vec2 n) {
|
|
20
|
-
return fract(sin(dot(n.xy + u_seed, vec2(12.9898, 78.233))) * 43758.5453);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
float noise(vec2 p){
|
|
24
|
-
vec2 i = floor(p);
|
|
25
|
-
vec2 f = fract(p);
|
|
26
|
-
|
|
27
|
-
// Four corners in 2D of a tile
|
|
28
|
-
float a = rand(i);
|
|
29
|
-
float b = rand(i + vec2(1.0, 0.0));
|
|
30
|
-
float c = rand(i + vec2(0.0, 1.0));
|
|
31
|
-
float d = rand(i + vec2(1.0, 1.0));
|
|
32
|
-
|
|
33
|
-
vec2 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
|
|
34
|
-
|
|
35
|
-
return mix(a, b, u.x) +
|
|
36
|
-
(c - a)* u.y * (1.0 - u.x) +
|
|
37
|
-
(d - b) * u.x * u.y;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
float fbm( in vec2 x, in float H ) {
|
|
41
|
-
float v = 00.0000;
|
|
42
|
-
float a = 0.5;
|
|
43
|
-
vec2 shift = vec2(100);
|
|
44
|
-
// Rotate to reduce axial bias
|
|
45
|
-
mat2 rot = mat2(0.877, 0.479, -0.479, 0.877);
|
|
46
|
-
for (int i = 0; i < maxOctaves; ++i) {
|
|
47
|
-
v += a * noise(x);
|
|
48
|
-
x = rot * x * 2.0 + shift;
|
|
49
|
-
a *= 0.5;
|
|
50
|
-
if (i > u_octaves) break;
|
|
51
|
-
}
|
|
52
|
-
return v;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
void main() {
|
|
56
|
-
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
57
|
-
uv.x *= u_resolution.x / u_resolution.y;
|
|
58
|
-
|
|
59
|
-
float baseNoise = fbm(uv * u_scale, 1.2);
|
|
60
|
-
|
|
61
|
-
vec2 warp = uv;
|
|
62
|
-
for (int i = 0; i < maxWarps; ++i) {
|
|
63
|
-
warp += vec2(fbm(warp * 2.0, 1.0), fbm(warp * 4.0 + vec2(10.2), 1.0));
|
|
64
|
-
if (i > u_warp) break;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
baseNoise = fbm(warp * u_scale, 1.2);
|
|
68
|
-
|
|
69
|
-
gl_FragColor = vec4(vec3(baseNoise), 1.0);
|
|
7
|
+
const FBM_FRAGMENT_SHADER_SOURCE = `
|
|
8
|
+
precision mediump float;
|
|
9
|
+
|
|
10
|
+
uniform vec2 u_resolution;
|
|
11
|
+
uniform float u_seed;
|
|
12
|
+
uniform float u_scale;
|
|
13
|
+
uniform int u_octaves;
|
|
14
|
+
uniform int u_warp;
|
|
15
|
+
|
|
16
|
+
const int maxOctaves = 20;
|
|
17
|
+
const int maxWarps = 5;
|
|
18
|
+
|
|
19
|
+
float rand(vec2 n) {
|
|
20
|
+
return fract(sin(dot(n.xy + u_seed, vec2(12.9898, 78.233))) * 43758.5453);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
float noise(vec2 p){
|
|
24
|
+
vec2 i = floor(p);
|
|
25
|
+
vec2 f = fract(p);
|
|
26
|
+
|
|
27
|
+
// Four corners in 2D of a tile
|
|
28
|
+
float a = rand(i);
|
|
29
|
+
float b = rand(i + vec2(1.0, 0.0));
|
|
30
|
+
float c = rand(i + vec2(0.0, 1.0));
|
|
31
|
+
float d = rand(i + vec2(1.0, 1.0));
|
|
32
|
+
|
|
33
|
+
vec2 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
|
|
34
|
+
|
|
35
|
+
return mix(a, b, u.x) +
|
|
36
|
+
(c - a)* u.y * (1.0 - u.x) +
|
|
37
|
+
(d - b) * u.x * u.y;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
float fbm( in vec2 x, in float H ) {
|
|
41
|
+
float v = 00.0000;
|
|
42
|
+
float a = 0.5;
|
|
43
|
+
vec2 shift = vec2(100);
|
|
44
|
+
// Rotate to reduce axial bias
|
|
45
|
+
mat2 rot = mat2(0.877, 0.479, -0.479, 0.877);
|
|
46
|
+
for (int i = 0; i < maxOctaves; ++i) {
|
|
47
|
+
v += a * noise(x);
|
|
48
|
+
x = rot * x * 2.0 + shift;
|
|
49
|
+
a *= 0.5;
|
|
50
|
+
if (i > u_octaves) break;
|
|
51
|
+
}
|
|
52
|
+
return v;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
57
|
+
uv.x *= u_resolution.x / u_resolution.y;
|
|
58
|
+
|
|
59
|
+
float baseNoise = fbm(uv * u_scale, 1.2);
|
|
60
|
+
|
|
61
|
+
vec2 warp = uv;
|
|
62
|
+
for (int i = 0; i < maxWarps; ++i) {
|
|
63
|
+
warp += vec2(fbm(warp * 2.0, 1.0), fbm(warp * 4.0 + vec2(10.2), 1.0));
|
|
64
|
+
if (i > u_warp) break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
baseNoise = fbm(warp * u_scale, 1.2);
|
|
68
|
+
|
|
69
|
+
gl_FragColor = vec4(vec3(baseNoise), 1.0);
|
|
70
70
|
}`;
|
|
71
71
|
function loadShaders(gl, type, source) {
|
|
72
72
|
const shader = gl.createShader(type);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { page } from '$app/state'
|
|
3
|
-
import type { AnalyticsProps } from '../types/Analytics.js';
|
|
4
|
-
|
|
5
|
-
let { measurementId }: AnalyticsProps = $props();
|
|
6
|
-
|
|
7
|
-
const ANALYTICS_URL = $derived(`https://www.googletagmanager.com/gtag/js?id=${measurementId}`);
|
|
8
|
-
|
|
9
|
-
$effect(() => {
|
|
10
|
-
if (typeof gtag !== 'undefined') {
|
|
11
|
-
gtag('config', measurementId, {
|
|
12
|
-
page_title: document.title,
|
|
13
|
-
page_path: page.url.pathname,
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<svelte:head>
|
|
20
|
-
{#if measurementId}
|
|
21
|
-
<script async src={ANALYTICS_URL}></script>
|
|
22
|
-
<script>
|
|
23
|
-
window.dataLayer = window.dataLayer || [];
|
|
24
|
-
function gtag() { dataLayer.push(arguments); }
|
|
25
|
-
gtag('js', new Date());
|
|
26
|
-
</script>
|
|
27
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { page } from '$app/state'
|
|
3
|
+
import type { AnalyticsProps } from '../types/Analytics.js';
|
|
4
|
+
|
|
5
|
+
let { measurementId }: AnalyticsProps = $props();
|
|
6
|
+
|
|
7
|
+
const ANALYTICS_URL = $derived(`https://www.googletagmanager.com/gtag/js?id=${measurementId}`);
|
|
8
|
+
|
|
9
|
+
$effect(() => {
|
|
10
|
+
if (typeof gtag !== 'undefined') {
|
|
11
|
+
gtag('config', measurementId, {
|
|
12
|
+
page_title: document.title,
|
|
13
|
+
page_path: page.url.pathname,
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<svelte:head>
|
|
20
|
+
{#if measurementId}
|
|
21
|
+
<script async src={ANALYTICS_URL}></script>
|
|
22
|
+
<script>
|
|
23
|
+
window.dataLayer = window.dataLayer || [];
|
|
24
|
+
function gtag() { dataLayer.push(arguments); }
|
|
25
|
+
gtag('js', new Date());
|
|
26
|
+
</script>
|
|
27
|
+
{/if}
|
|
28
28
|
</svelte:head>
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { colorStyles } from "../styles/color.js";
|
|
3
|
-
import type { ButtonProps } from "../types/Button.js";
|
|
4
|
-
import { twMerge } from "tailwind-merge";
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
children = undefined,
|
|
8
|
-
class: className = "",
|
|
9
|
-
pill = false,
|
|
10
|
-
icon = false,
|
|
11
|
-
href = undefined,
|
|
12
|
-
color = undefined,
|
|
13
|
-
size = undefined,
|
|
14
|
-
...restProps
|
|
15
|
-
}: ButtonProps = $props();
|
|
16
|
-
|
|
17
|
-
function getSizeStyles(size?: number | string) {
|
|
18
|
-
if (typeof size === "number")
|
|
19
|
-
return `w-${size} h-${size}`;
|
|
20
|
-
return "";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let pillClass = "rounded-full";
|
|
24
|
-
let iconClass = "rounded-full p-2 flex-center";
|
|
25
|
-
let defaultClass = $derived(twMerge(
|
|
26
|
-
"text-white cursor-pointer px-2 py-1 transition-colors duration-300 rounded-md",
|
|
27
|
-
(pill ? pillClass : ""), (icon ? iconClass : ""), color ? colorStyles[color] : "", getSizeStyles(size)));
|
|
28
|
-
|
|
29
|
-
let combinedClass = $derived(twMerge(defaultClass, className));
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
{#if href}
|
|
33
|
-
<a class={combinedClass} {href} {...restProps}>
|
|
34
|
-
{@render children?.()}
|
|
35
|
-
</a>
|
|
36
|
-
{:else}
|
|
37
|
-
<button class={combinedClass} {...restProps}>
|
|
38
|
-
{@render children?.()}
|
|
39
|
-
</button>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { colorStyles } from "../styles/color.js";
|
|
3
|
+
import type { ButtonProps } from "../types/Button.js";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children = undefined,
|
|
8
|
+
class: className = "",
|
|
9
|
+
pill = false,
|
|
10
|
+
icon = false,
|
|
11
|
+
href = undefined,
|
|
12
|
+
color = undefined,
|
|
13
|
+
size = undefined,
|
|
14
|
+
...restProps
|
|
15
|
+
}: ButtonProps = $props();
|
|
16
|
+
|
|
17
|
+
function getSizeStyles(size?: number | string) {
|
|
18
|
+
if (typeof size === "number")
|
|
19
|
+
return `w-${size} h-${size}`;
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let pillClass = "rounded-full";
|
|
24
|
+
let iconClass = "rounded-full p-2 flex-center";
|
|
25
|
+
let defaultClass = $derived(twMerge(
|
|
26
|
+
"text-white cursor-pointer px-2 py-1 transition-colors duration-300 rounded-md",
|
|
27
|
+
(pill ? pillClass : ""), (icon ? iconClass : ""), color ? colorStyles[color] : "", getSizeStyles(size)));
|
|
28
|
+
|
|
29
|
+
let combinedClass = $derived(twMerge(defaultClass, className));
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if href}
|
|
33
|
+
<a class={combinedClass} {href} {...restProps}>
|
|
34
|
+
{@render children?.()}
|
|
35
|
+
</a>
|
|
36
|
+
{:else}
|
|
37
|
+
<button class={combinedClass} {...restProps}>
|
|
38
|
+
{@render children?.()}
|
|
39
|
+
</button>
|
|
40
40
|
{/if}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { FloatingInputProps } from "../types/FloatingInput.js";
|
|
3
|
-
import { twMerge } from "tailwind-merge";
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
children = undefined,
|
|
7
|
-
class: className = "",
|
|
8
|
-
labelClass = "",
|
|
9
|
-
divClass = "",
|
|
10
|
-
value = $bindable(),
|
|
11
|
-
onfocus = undefined,
|
|
12
|
-
onblur = undefined,
|
|
13
|
-
validInputRegex = undefined,
|
|
14
|
-
id = crypto.randomUUID(),
|
|
15
|
-
...restProps
|
|
16
|
-
}: FloatingInputProps = $props();
|
|
17
|
-
|
|
18
|
-
let isFocused = $state(false);
|
|
19
|
-
let touched = $state(false);
|
|
20
|
-
|
|
21
|
-
let hasContent = $derived(value !== undefined && value !== null && value.toString().length > 0);
|
|
22
|
-
let isValid = $derived(!touched || !validInputRegex || validInputRegex.test(value || ""));
|
|
23
|
-
|
|
24
|
-
let defaultClass = "z-20 w-full border rounded px-
|
|
25
|
-
let defaultLabelClass = "block text-
|
|
26
|
-
let defaultDivClass = "relative";
|
|
27
|
-
|
|
28
|
-
let originalLabelClass = "left-
|
|
29
|
-
let selectedLabelClass = "left-2 z-30
|
|
30
|
-
|
|
31
|
-
let invalidClass = "border-red-500 focus:ring-red-500";
|
|
32
|
-
|
|
33
|
-
let combinedLabelClass = $derived(twMerge(defaultLabelClass, isFocused || hasContent ? selectedLabelClass : originalLabelClass, labelClass));
|
|
34
|
-
let combinedClass = $derived(twMerge(defaultClass, className, isValid ? "" : invalidClass));
|
|
35
|
-
let combinedDivClass = $derived(twMerge(defaultDivClass, divClass));
|
|
36
|
-
|
|
37
|
-
function handleFocus(e: FocusEvent) {
|
|
38
|
-
isFocused = true;
|
|
39
|
-
onfocus?.(e);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function handleBlur(e: FocusEvent) {
|
|
43
|
-
isFocused = false;
|
|
44
|
-
touched = true;
|
|
45
|
-
onblur?.(e);
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<div class={combinedDivClass}>
|
|
50
|
-
<label for={id} class={combinedLabelClass}>
|
|
51
|
-
{@render children?.()}
|
|
52
|
-
</label>
|
|
53
|
-
<input
|
|
54
|
-
{id}
|
|
55
|
-
bind:value={value}
|
|
56
|
-
onfocus={handleFocus}
|
|
57
|
-
onblur={handleBlur}
|
|
58
|
-
class={combinedClass}
|
|
59
|
-
{...restProps}
|
|
60
|
-
/>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FloatingInputProps } from "../types/FloatingInput.js";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children = undefined,
|
|
7
|
+
class: className = "",
|
|
8
|
+
labelClass = "",
|
|
9
|
+
divClass = "",
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
onfocus = undefined,
|
|
12
|
+
onblur = undefined,
|
|
13
|
+
validInputRegex = undefined,
|
|
14
|
+
id = crypto.randomUUID(),
|
|
15
|
+
...restProps
|
|
16
|
+
}: FloatingInputProps = $props();
|
|
17
|
+
|
|
18
|
+
let isFocused = $state(false);
|
|
19
|
+
let touched = $state(false);
|
|
20
|
+
|
|
21
|
+
let hasContent = $derived(value !== undefined && value !== null && value.toString().length > 0);
|
|
22
|
+
let isValid = $derived(!touched || !validInputRegex || validInputRegex.test(value || ""));
|
|
23
|
+
|
|
24
|
+
let defaultClass = "z-20 bg-form-input-background text-main-text w-full border rounded px-2 pt-4 pb-1 text-xs outline-none focus:ring-2 focus:ring-blue-500 transition-all";
|
|
25
|
+
let defaultLabelClass = "block text-sub-text rounded-md text-sm font-medium mb-1 absolute transition-all duration-100 pointer-events-none";
|
|
26
|
+
let defaultDivClass = "relative";
|
|
27
|
+
|
|
28
|
+
let originalLabelClass = "left-2 top-1/2 transform -translate-y-1/2 z-0";
|
|
29
|
+
let selectedLabelClass = "left-2 z-30 top-0.5 text-[10px]";
|
|
30
|
+
|
|
31
|
+
let invalidClass = "border-red-500 focus:ring-red-500";
|
|
32
|
+
|
|
33
|
+
let combinedLabelClass = $derived(twMerge(defaultLabelClass, isFocused || hasContent ? selectedLabelClass : originalLabelClass, labelClass));
|
|
34
|
+
let combinedClass = $derived(twMerge(defaultClass, className, isValid ? "" : invalidClass));
|
|
35
|
+
let combinedDivClass = $derived(twMerge(defaultDivClass, divClass));
|
|
36
|
+
|
|
37
|
+
function handleFocus(e: FocusEvent) {
|
|
38
|
+
isFocused = true;
|
|
39
|
+
onfocus?.(e);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleBlur(e: FocusEvent) {
|
|
43
|
+
isFocused = false;
|
|
44
|
+
touched = true;
|
|
45
|
+
onblur?.(e);
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div class={combinedDivClass}>
|
|
50
|
+
<label for={id} class={combinedLabelClass}>
|
|
51
|
+
{@render children?.()}
|
|
52
|
+
</label>
|
|
53
|
+
<input
|
|
54
|
+
{id}
|
|
55
|
+
bind:value={value}
|
|
56
|
+
onfocus={handleFocus}
|
|
57
|
+
onblur={handleBlur}
|
|
58
|
+
class={combinedClass}
|
|
59
|
+
{...restProps}
|
|
60
|
+
/>
|
|
61
61
|
</div>
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { NavbarProps } from "../types/Navbar.js";
|
|
3
|
-
import { onMount } from "svelte";
|
|
4
|
-
import { twMerge } from "tailwind-merge";
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
children = undefined,
|
|
8
|
-
class: className = "",
|
|
9
|
-
classTop = "",
|
|
10
|
-
...restProps
|
|
11
|
-
}: NavbarProps = $props();
|
|
12
|
-
|
|
13
|
-
let defaultClass = "transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center";
|
|
14
|
-
|
|
15
|
-
let scrollY = $state(0);
|
|
16
|
-
|
|
17
|
-
let combinedClass = $derived(scrollY === 0
|
|
18
|
-
? twMerge(defaultClass, className, classTop)
|
|
19
|
-
: twMerge(defaultClass, className));
|
|
20
|
-
|
|
21
|
-
function onScroll() {
|
|
22
|
-
scrollY = window.scrollY;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
onMount(() => {
|
|
26
|
-
window.addEventListener('scroll', onScroll);
|
|
27
|
-
onScroll();
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
window.removeEventListener('scroll', onScroll);
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<nav class={combinedClass} {...restProps}>
|
|
36
|
-
{@render children?.()}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { NavbarProps } from "../types/Navbar.js";
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children = undefined,
|
|
8
|
+
class: className = "",
|
|
9
|
+
classTop = "",
|
|
10
|
+
...restProps
|
|
11
|
+
}: NavbarProps = $props();
|
|
12
|
+
|
|
13
|
+
let defaultClass = "transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center bg-main-background border-b-sub-background border-b";
|
|
14
|
+
|
|
15
|
+
let scrollY = $state(0);
|
|
16
|
+
|
|
17
|
+
let combinedClass = $derived(scrollY === 0
|
|
18
|
+
? twMerge(defaultClass, className, classTop)
|
|
19
|
+
: twMerge(defaultClass, className));
|
|
20
|
+
|
|
21
|
+
function onScroll() {
|
|
22
|
+
scrollY = window.scrollY;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
onMount(() => {
|
|
26
|
+
window.addEventListener('scroll', onScroll);
|
|
27
|
+
onScroll();
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
window.removeEventListener('scroll', onScroll);
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<nav class={combinedClass} {...restProps}>
|
|
36
|
+
{@render children?.()}
|
|
37
37
|
</nav>
|