@tableslayer/ui 0.1.3 → 0.1.4
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/package.json +2 -13
- package/src/lib/components/Avatar/Avatar.svelte +82 -0
- package/src/lib/components/Avatar/AvatarFileInput.svelte +85 -0
- package/src/lib/components/Avatar/AvatarPopover.svelte +34 -0
- package/src/lib/components/Avatar/index.ts +4 -0
- package/src/lib/components/Avatar/types.ts +24 -0
- package/src/lib/components/BrushSizeSlider/BrushSizeSlider.svelte +174 -0
- package/src/lib/components/BrushSizeSlider/index.ts +1 -0
- package/src/lib/components/Button/Button.svelte +182 -0
- package/src/lib/components/Button/ConfirmActionButton.svelte +98 -0
- package/src/lib/components/Button/IconButton.svelte +121 -0
- package/src/lib/components/Button/RadioButton.svelte +93 -0
- package/src/lib/components/Button/index.ts +5 -0
- package/src/lib/components/Button/types.ts +54 -0
- package/src/lib/components/CardFan/CardFan.svelte +165 -0
- package/src/lib/components/CardFan/index.ts +2 -0
- package/src/lib/components/CardFan/types.ts +6 -0
- package/src/lib/components/CodeBlock/Code.svelte +7 -0
- package/src/lib/components/CodeBlock/CodeBlock.svelte +102 -0
- package/src/lib/components/CodeBlock/index.ts +3 -0
- package/src/lib/components/CodeBlock/types.ts +10 -0
- package/src/lib/components/ColorMode/ColorMode.svelte +8 -0
- package/src/lib/components/ColorMode/index.ts +2 -0
- package/src/lib/components/ColorMode/types.ts +12 -0
- package/src/lib/components/ColorPicker/ColorPicker.svelte +838 -0
- package/src/lib/components/ColorPicker/ColorPickerSwatch.svelte +32 -0
- package/src/lib/components/ColorPicker/index.ts +3 -0
- package/src/lib/components/ColorPicker/types.ts +51 -0
- package/src/lib/components/ContextMenu/ContextMenu.svelte +86 -0
- package/src/lib/components/ContextMenu/index.ts +2 -0
- package/src/lib/components/ContextMenu/types.ts +15 -0
- package/src/lib/components/DrawingSliders/DrawingSliders.svelte +379 -0
- package/src/lib/components/DrawingSliders/index.ts +1 -0
- package/src/lib/components/Editor/Editor.svelte +825 -0
- package/src/lib/components/Editor/index.ts +1 -0
- package/src/lib/components/FogSliders/FogSliders.svelte +33 -0
- package/src/lib/components/FogSliders/index.ts +1 -0
- package/src/lib/components/Hr/Hr.svelte +15 -0
- package/src/lib/components/Hr/index.ts +1 -0
- package/src/lib/components/Icon/Icon.svelte +6 -0
- package/src/lib/components/Icon/index.ts +2 -0
- package/src/lib/components/Icon/types.ts +20 -0
- package/src/lib/components/Input/DualInputSlider.svelte +126 -0
- package/src/lib/components/Input/FileInput.svelte +176 -0
- package/src/lib/components/Input/FormControl.svelte +150 -0
- package/src/lib/components/Input/FormError.svelte +37 -0
- package/src/lib/components/Input/Input.svelte +56 -0
- package/src/lib/components/Input/InputCheckbox.svelte +99 -0
- package/src/lib/components/Input/InputSlider.svelte +86 -0
- package/src/lib/components/Input/Label.svelte +19 -0
- package/src/lib/components/Input/index.ts +9 -0
- package/src/lib/components/Input/types.ts +39 -0
- package/src/lib/components/Link/Link.svelte +41 -0
- package/src/lib/components/Link/LinkBox.svelte +20 -0
- package/src/lib/components/Link/LinkOverlay.svelte +23 -0
- package/src/lib/components/Link/index.ts +4 -0
- package/src/lib/components/Link/types.ts +17 -0
- package/src/lib/components/Loading/Loader.svelte +60 -0
- package/src/lib/components/Loading/Skeleton.svelte +9 -0
- package/src/lib/components/Loading/index.ts +2 -0
- package/src/lib/components/Logo/Logo.svelte +16 -0
- package/src/lib/components/Logo/index.ts +1 -0
- package/src/lib/components/MarkerTooltip/MarkerTooltip.svelte +435 -0
- package/src/lib/components/MarkerTooltip/index.ts +1 -0
- package/src/lib/components/Menu/SelectorMenu.svelte +280 -0
- package/src/lib/components/Menu/index.ts +2 -0
- package/src/lib/components/Menu/types.ts +17 -0
- package/src/lib/components/MyCounterButton.svelte +11 -0
- package/src/lib/components/Panel/index.ts +2 -0
- package/src/lib/components/Panel/panel.svelte +18 -0
- package/src/lib/components/Panel/types.ts +8 -0
- package/src/lib/components/PersistButton/PersistButton.svelte +100 -0
- package/src/lib/components/PersistButton/index.ts +1 -0
- package/src/lib/components/Popover/Popover.svelte +81 -0
- package/src/lib/components/Popover/index.ts +2 -0
- package/src/lib/components/Popover/types.ts +19 -0
- package/src/lib/components/PropsTable/PropsTable.svelte +107 -0
- package/src/lib/components/RadialMenu/EffectPreview.svelte +36 -0
- package/src/lib/components/RadialMenu/EffectPreviewScene.svelte +194 -0
- package/src/lib/components/RadialMenu/RadialMenu.svelte +503 -0
- package/src/lib/components/RadialMenu/RadialMenuItem.svelte +176 -0
- package/src/lib/components/RadialMenu/index.ts +2 -0
- package/src/lib/components/RadialMenu/types.ts +35 -0
- package/src/lib/components/Select/Select.svelte +342 -0
- package/src/lib/components/Select/index.ts +2 -0
- package/src/lib/components/Select/types.ts +22 -0
- package/src/lib/components/Spacer/Spacer.svelte +14 -0
- package/src/lib/components/Spacer/index.ts +2 -0
- package/src/lib/components/Spacer/types.ts +5 -0
- package/src/lib/components/Stage/components/AnnotationLayer/AnnotationLayer.svelte +445 -0
- package/src/lib/components/Stage/components/AnnotationLayer/AnnotationMaterial.svelte +167 -0
- package/src/lib/components/Stage/components/AnnotationLayer/types.ts +196 -0
- package/src/lib/components/Stage/components/CursorLayer/CursorLayer.svelte +148 -0
- package/src/lib/components/Stage/components/CursorLayer/cursor.svg +26 -0
- package/src/lib/components/Stage/components/CursorLayer/index.ts +2 -0
- package/src/lib/components/Stage/components/CursorLayer/types.ts +23 -0
- package/src/lib/components/Stage/components/DrawingLayer/DrawingMaterial.svelte +364 -0
- package/src/lib/components/Stage/components/DrawingLayer/types.ts +65 -0
- package/src/lib/components/Stage/components/EdgeOverlayLayer/EdgeOverlayLayer.svelte +72 -0
- package/src/lib/components/Stage/components/EdgeOverlayLayer/types.ts +34 -0
- package/src/lib/components/Stage/components/FogLayer/FogLayer.svelte +75 -0
- package/src/lib/components/Stage/components/FogLayer/types.ts +51 -0
- package/src/lib/components/Stage/components/FogOfWarLayer/FogOfWarLayer.svelte +249 -0
- package/src/lib/components/Stage/components/FogOfWarLayer/FogOfWarMaterial.svelte +200 -0
- package/src/lib/components/Stage/components/FogOfWarLayer/types.ts +116 -0
- package/src/lib/components/Stage/components/GridLayer/GridLayer.svelte +20 -0
- package/src/lib/components/Stage/components/GridLayer/GridMaterial.svelte +69 -0
- package/src/lib/components/Stage/components/GridLayer/types.ts +79 -0
- package/src/lib/components/Stage/components/LayerInput/LayerInput.svelte +300 -0
- package/src/lib/components/Stage/components/MapLayer/MapLayer.svelte +196 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/GifDataSource.ts +265 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/IMapDataSource.ts +55 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/ImageDataSource.ts +87 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/VideoDataSource.ts +150 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/dataSourceFactory.ts +48 -0
- package/src/lib/components/Stage/components/MapLayer/dataSources/index.ts +16 -0
- package/src/lib/components/Stage/components/MapLayer/types.ts +58 -0
- package/src/lib/components/Stage/components/MarkerLayer/MarkerLayer.svelte +398 -0
- package/src/lib/components/Stage/components/MarkerLayer/MarkerToken.svelte +262 -0
- package/src/lib/components/Stage/components/MarkerLayer/types.ts +126 -0
- package/src/lib/components/Stage/components/MeasurementLayer/MeasurementLayer.svelte +364 -0
- package/src/lib/components/Stage/components/MeasurementLayer/MeasurementManager.svelte +473 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/BaseMeasurement.ts +427 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/BeamMeasurement.ts +105 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/CircleMeasurement.ts +98 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/ConeMeasurement.ts +163 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/LineMeasurement.ts +102 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/RectangleMeasurement.ts +120 -0
- package/src/lib/components/Stage/components/MeasurementLayer/measurements/index.ts +7 -0
- package/src/lib/components/Stage/components/MeasurementLayer/types.ts +94 -0
- package/src/lib/components/Stage/components/MeasurementLayer/utils/canvasDrawing.ts +357 -0
- package/src/lib/components/Stage/components/MeasurementLayer/utils/distanceCalculations.ts +170 -0
- package/src/lib/components/Stage/components/ParticleSystem/ParticleSystem.svelte +220 -0
- package/src/lib/components/Stage/components/ParticleSystem/particles/atlases/ash.png +0 -0
- package/src/lib/components/Stage/components/ParticleSystem/particles/atlases/leaves.png +0 -0
- package/src/lib/components/Stage/components/ParticleSystem/particles/atlases/rain.png +0 -0
- package/src/lib/components/Stage/components/ParticleSystem/particles/atlases/snow.png +0 -0
- package/src/lib/components/Stage/components/ParticleSystem/rng.js +20 -0
- package/src/lib/components/Stage/components/ParticleSystem/types.ts +95 -0
- package/src/lib/components/Stage/components/PerformanceDebugger/PerformanceDebugger.svelte +144 -0
- package/src/lib/components/Stage/components/PerformanceDebugger/index.ts +1 -0
- package/src/lib/components/Stage/components/PerformanceOverlay/PerformanceOverlay.svelte +208 -0
- package/src/lib/components/Stage/components/PerformanceOverlay/index.ts +1 -0
- package/src/lib/components/Stage/components/PointerInputManager/PointerInputManager.svelte +201 -0
- package/src/lib/components/Stage/components/Scene/Scene.svelte +651 -0
- package/src/lib/components/Stage/components/Scene/luts.ts +24 -0
- package/src/lib/components/Stage/components/Scene/types.ts +225 -0
- package/src/lib/components/Stage/components/Stage/Stage.svelte +332 -0
- package/src/lib/components/Stage/components/Stage/types.ts +136 -0
- package/src/lib/components/Stage/components/WeatherLayer/WeatherLayer.svelte +135 -0
- package/src/lib/components/Stage/components/WeatherLayer/presets/AshPreset.ts +71 -0
- package/src/lib/components/Stage/components/WeatherLayer/presets/LeavesPreset.ts +70 -0
- package/src/lib/components/Stage/components/WeatherLayer/presets/RainPreset.ts +68 -0
- package/src/lib/components/Stage/components/WeatherLayer/presets/SnowPreset.ts +70 -0
- package/src/lib/components/Stage/components/WeatherLayer/presets/index.ts +6 -0
- package/src/lib/components/Stage/components/WeatherLayer/types.ts +35 -0
- package/src/lib/components/Stage/helpers/clippingPlaneStore.svelte.ts +28 -0
- package/src/lib/components/Stage/helpers/debugState.svelte.ts +18 -0
- package/src/lib/components/Stage/helpers/grid.ts +548 -0
- package/src/lib/components/Stage/helpers/lazyBrush.ts +171 -0
- package/src/lib/components/Stage/helpers/performanceMetrics.svelte.ts +220 -0
- package/src/lib/components/Stage/helpers/utils.ts +21 -0
- package/src/lib/components/Stage/index.ts +49 -0
- package/src/lib/components/Stage/shaders/AnnotationEffects.frag +1070 -0
- package/src/lib/components/Stage/shaders/Annotations.frag +29 -0
- package/src/lib/components/Stage/shaders/Drawing.frag +83 -0
- package/src/lib/components/Stage/shaders/Drawing.vert +5 -0
- package/src/lib/components/Stage/shaders/Fog.frag +147 -0
- package/src/lib/components/Stage/shaders/FractalNoise.frag +96 -0
- package/src/lib/components/Stage/shaders/GridShader.frag +174 -0
- package/src/lib/components/Stage/shaders/Overlay.frag +23 -0
- package/src/lib/components/Stage/shaders/Overlay.vert +0 -0
- package/src/lib/components/Stage/shaders/Particles.frag +27 -0
- package/src/lib/components/Stage/shaders/Particles.vert +51 -0
- package/src/lib/components/Stage/shaders/ToolOutline.frag +59 -0
- package/src/lib/components/Stage/shaders/default.vert +8 -0
- package/src/lib/components/Stage/types.ts +4 -0
- package/src/lib/components/Table/Table.svelte +16 -0
- package/src/lib/components/Table/Td.svelte +17 -0
- package/src/lib/components/Table/Th.svelte +18 -0
- package/src/lib/components/Table/index.ts +4 -0
- package/src/lib/components/Table/types.ts +14 -0
- package/src/lib/components/Text/Text.svelte +23 -0
- package/src/lib/components/Text/index.ts +2 -0
- package/src/lib/components/Text/types.ts +12 -0
- package/src/lib/components/Title/Title.svelte +54 -0
- package/src/lib/components/Title/index.ts +2 -0
- package/src/lib/components/Title/types.ts +9 -0
- package/src/lib/components/Toast/Toast.svelte +155 -0
- package/src/lib/components/Toast/index.ts +5 -0
- package/src/lib/components/Toast/toastCookie.ts +24 -0
- package/src/lib/components/Toast/types.ts +6 -0
- package/src/lib/components/ToolTip/ToolTip.svelte +70 -0
- package/src/lib/components/ToolTip/index.ts +2 -0
- package/src/lib/components/ToolTip/types.ts +14 -0
- package/src/lib/components/index.ts +32 -0
- package/src/lib/components/types.ts +0 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/styles/globals.css +108 -0
- package/src/lib/styles/normalize.css +9 -0
- package/src/lib/styles/reset.css +133 -0
- package/src/lib/styles/utilities.css +179 -0
- package/src/lib/styles/vars.css +1103 -0
- package/src/lib/types/awareness.ts +17 -0
- package/src/lib/utils/rle.ts +217 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
|
|
3
|
+
uniform vec2 uStart;
|
|
4
|
+
uniform vec2 uEnd;
|
|
5
|
+
uniform float uBrushSize;
|
|
6
|
+
uniform vec2 uTextureSize;
|
|
7
|
+
uniform int uShapeType;
|
|
8
|
+
uniform vec3 uOutlineColor;
|
|
9
|
+
uniform float uOutlineThickness;
|
|
10
|
+
uniform float uOutlineOpacity;
|
|
11
|
+
|
|
12
|
+
varying vec2 vUv;
|
|
13
|
+
|
|
14
|
+
// Re-use the distance functions from Drawing.frag
|
|
15
|
+
float isInsideEllipse(vec2 p, vec2 a, vec2 b) {
|
|
16
|
+
vec2 center = (a + b) / 2.0;
|
|
17
|
+
vec2 radii = abs(b - a) / 2.0;
|
|
18
|
+
vec2 p0 = p - center;
|
|
19
|
+
float value = (p0.x * p0.x) / (radii.x * radii.x) + (p0.y * p0.y) / (radii.y * radii.y);
|
|
20
|
+
vec2 scaledP = vec2(p0.x / radii.x, p0.y / radii.y);
|
|
21
|
+
float dist = (length(scaledP) - 1.0) * min(radii.x, radii.y);
|
|
22
|
+
return dist;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
float distanceToRectangle(vec2 p, vec2 a, vec2 b) {
|
|
26
|
+
vec2 rectMin = vec2(min(a.x, b.x), min(a.y, b.y));
|
|
27
|
+
vec2 rectMax = vec2(max(a.x, b.x), max(a.y, b.y));
|
|
28
|
+
vec2 closest = vec2(clamp(p.x, rectMin.x, rectMax.x), clamp(p.y, rectMin.y, rectMax.y));
|
|
29
|
+
return length(p - closest);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
float distanceToLine(vec2 p, vec2 a, vec2 b) {
|
|
33
|
+
vec2 pa = p - a;
|
|
34
|
+
vec2 ba = b - a;
|
|
35
|
+
float t = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
|
|
36
|
+
return length(pa - ba * t);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void main() {
|
|
40
|
+
vec2 pixelPos = vUv * uTextureSize;
|
|
41
|
+
float dist;
|
|
42
|
+
float outlineWidth = uOutlineThickness;
|
|
43
|
+
|
|
44
|
+
if(uShapeType == 1) { // Brush
|
|
45
|
+
dist = distanceToLine(pixelPos, uStart, uEnd);
|
|
46
|
+
float inner = smoothstep(uBrushSize - outlineWidth, uBrushSize, dist);
|
|
47
|
+
float outer = smoothstep(uBrushSize, uBrushSize + outlineWidth, dist);
|
|
48
|
+
float outline = inner - outer;
|
|
49
|
+
gl_FragColor = vec4(uOutlineColor, outline * uOutlineOpacity);
|
|
50
|
+
} else if(uShapeType == 2) { // Rectangle
|
|
51
|
+
dist = distanceToRectangle(pixelPos, uStart, uEnd);
|
|
52
|
+
float outline = smoothstep(0.0, outlineWidth, dist) - smoothstep(outlineWidth, outlineWidth * 2.0, dist);
|
|
53
|
+
gl_FragColor = vec4(uOutlineColor, outline * uOutlineOpacity);
|
|
54
|
+
} else if(uShapeType == 3) { // Ellipse
|
|
55
|
+
dist = isInsideEllipse(pixelPos, uStart, uEnd);
|
|
56
|
+
float outline = smoothstep(0.0, outlineWidth, dist) - smoothstep(outlineWidth, outlineWidth * 2.0, dist);
|
|
57
|
+
gl_FragColor = vec4(uOutlineColor, outline * uOutlineOpacity);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableProps } from './types';
|
|
3
|
+
let { children, ...restProps }: TableProps = $props();
|
|
4
|
+
let tableClasses = $derived(['table', restProps.class ?? '']);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<table {...restProps} class={tableClasses}>
|
|
8
|
+
{@render children()}
|
|
9
|
+
</table>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.table {
|
|
13
|
+
width: 100%;
|
|
14
|
+
border-collapse: collapse;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TdProps } from './types';
|
|
3
|
+
let { children, ...restProps }: TdProps = $props();
|
|
4
|
+
let tdClasses = $derived(['td', restProps.class ?? '']);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<td {...restProps} class={tdClasses}>
|
|
8
|
+
{@render children()}
|
|
9
|
+
</td>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.td {
|
|
13
|
+
text-align: left;
|
|
14
|
+
padding: var(--size-1) var(--size-3);
|
|
15
|
+
border-bottom: var(--borderThin);
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ThProps } from './types';
|
|
3
|
+
let { children, ...restProps }: ThProps = $props();
|
|
4
|
+
let thClasses = $derived(['th', restProps.class ?? '']);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<th {...restProps} class={thClasses}>
|
|
8
|
+
{@render children()}
|
|
9
|
+
</th>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.th {
|
|
13
|
+
text-align: left;
|
|
14
|
+
font-weight: var(--font-weight-6);
|
|
15
|
+
padding: var(--size-1) var(--size-3);
|
|
16
|
+
border-bottom: var(--borderThin);
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLTableAttributes, HTMLThAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
export type TableProps = {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
} & HTMLTableAttributes;
|
|
7
|
+
|
|
8
|
+
export type ThProps = {
|
|
9
|
+
children: Snippet;
|
|
10
|
+
} & HTMLThAttributes;
|
|
11
|
+
|
|
12
|
+
export type TdProps = {
|
|
13
|
+
children: Snippet;
|
|
14
|
+
} & HTMLThAttributes;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TextProps } from './types';
|
|
3
|
+
let { children, as = 'p', size = '1rem', color = 'var(--fg)', weight = 400, ...restProps }: TextProps = $props();
|
|
4
|
+
let titleClasses = $derived(['text', restProps.class ?? '']);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svelte:element
|
|
8
|
+
this={as}
|
|
9
|
+
{...restProps}
|
|
10
|
+
class={titleClasses}
|
|
11
|
+
style="--textFontWeight: {weight}; --textColor: {color}; --textSize: {size}"
|
|
12
|
+
>
|
|
13
|
+
{@render children()}
|
|
14
|
+
</svelte:element>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
.text {
|
|
18
|
+
line-height: 1.5;
|
|
19
|
+
font-size: var(--textSize);
|
|
20
|
+
color: var(--textColor);
|
|
21
|
+
font-weight: var(--textFontWeight);
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
export type TextProps = {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
as?: 'p' | 'span';
|
|
7
|
+
size?: string;
|
|
8
|
+
weight?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
pretty?: boolean;
|
|
12
|
+
} & HTMLAttributes<HTMLHeadingElement>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TitleProps } from './types';
|
|
3
|
+
let { children, as = 'p', size, style, ...restProps }: TitleProps = $props();
|
|
4
|
+
let titleClasses = $derived(['title', `title-${size}`, restProps.class ?? '']);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svelte:element this={as} {...restProps} class={titleClasses} {style}>
|
|
8
|
+
{@render children()}
|
|
9
|
+
</svelte:element>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.title {
|
|
13
|
+
font-family: var(--font-serif);
|
|
14
|
+
font-variation-settings:
|
|
15
|
+
'wght' 600,
|
|
16
|
+
'TAIL' 100,
|
|
17
|
+
'ROUN' 50;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.title-xs {
|
|
21
|
+
font-size: 1.25rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.title-sm {
|
|
25
|
+
font-size: 1.5rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.title-md {
|
|
29
|
+
font-size: 2.5rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.title-lg {
|
|
33
|
+
font-size: 3rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.title-xl {
|
|
37
|
+
font-size: 4.5rem;
|
|
38
|
+
font-feature-settings: 'ss03' 1;
|
|
39
|
+
}
|
|
40
|
+
@media (max-width: 768px) {
|
|
41
|
+
.title-lg {
|
|
42
|
+
font-size: 1.25rem;
|
|
43
|
+
}
|
|
44
|
+
.title-md {
|
|
45
|
+
font-size: 1.25rem;
|
|
46
|
+
}
|
|
47
|
+
.title-sm {
|
|
48
|
+
font-size: 1.25rem;
|
|
49
|
+
}
|
|
50
|
+
.title-xl {
|
|
51
|
+
font-size: 1.25rem;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
export type TitleProps = {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
as: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'p';
|
|
7
|
+
size: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
style?: string;
|
|
9
|
+
} & HTMLAttributes<HTMLHeadingElement>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { ToastDataProps } from './types';
|
|
3
|
+
import { flip } from 'svelte/animate';
|
|
4
|
+
import { fly } from 'svelte/transition';
|
|
5
|
+
import { IconX } from '@tabler/icons-svelte';
|
|
6
|
+
import { Icon, Loader } from '../';
|
|
7
|
+
import { page } from '$app/state';
|
|
8
|
+
const {
|
|
9
|
+
elements: { content, title, description, close },
|
|
10
|
+
helpers,
|
|
11
|
+
states: { toasts },
|
|
12
|
+
actions: { portal }
|
|
13
|
+
} = createToaster<ToastDataProps>({ hover: 'pause-all' });
|
|
14
|
+
|
|
15
|
+
let isHovered = $state(false);
|
|
16
|
+
let leaveTimeout: ReturnType<typeof setTimeout>;
|
|
17
|
+
|
|
18
|
+
const handleMouseEnter = () => {
|
|
19
|
+
if (leaveTimeout) {
|
|
20
|
+
clearTimeout(leaveTimeout);
|
|
21
|
+
}
|
|
22
|
+
isHovered = true;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const handleMouseLeave = () => {
|
|
26
|
+
leaveTimeout = setTimeout(() => {
|
|
27
|
+
isHovered = false;
|
|
28
|
+
}, 1000);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const addToast = helpers.addToast;
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts">
|
|
35
|
+
import { checkToastCookie } from './toastCookie';
|
|
36
|
+
$effect(() => {
|
|
37
|
+
if (page.url) {
|
|
38
|
+
checkToastCookie();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
import { createToaster, melt } from '@melt-ui/svelte';
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div
|
|
45
|
+
use:portal
|
|
46
|
+
role="alert"
|
|
47
|
+
class={['toasts', isHovered && 'toasts--isHovered']}
|
|
48
|
+
onmouseenter={handleMouseEnter}
|
|
49
|
+
onmouseleave={handleMouseLeave}
|
|
50
|
+
>
|
|
51
|
+
{#each $toasts as { id, data }, index (id)}
|
|
52
|
+
<div
|
|
53
|
+
use:melt={$content(id)}
|
|
54
|
+
animate:flip={{ duration: 500 }}
|
|
55
|
+
in:fly={{ duration: 150, y: '100%' }}
|
|
56
|
+
out:fly={{ duration: 150, y: '100%' }}
|
|
57
|
+
data-testid="toast"
|
|
58
|
+
class="toast"
|
|
59
|
+
style="z-index: index; visibility: {index > $toasts.length - 6 || isHovered
|
|
60
|
+
? 'visible'
|
|
61
|
+
: 'hidden'} ; transform: {index === $toasts.length - 1 || isHovered
|
|
62
|
+
? 'scale(1) translateY(0)'
|
|
63
|
+
: `scale(${1 - 0.05 * ($toasts.length - 1 - index)}) translateY(${-12 * ($toasts.length - 1 - index)}px)`};"
|
|
64
|
+
>
|
|
65
|
+
<div>
|
|
66
|
+
<div class="toast__title">
|
|
67
|
+
<p use:melt={$title(id)} class="toast__titleText">
|
|
68
|
+
{data.title}
|
|
69
|
+
</p>
|
|
70
|
+
{#if data.type === 'loading'}
|
|
71
|
+
<Loader />
|
|
72
|
+
{:else}
|
|
73
|
+
<div class={['toast__titleDot', `toast__titleDot--${data.type}`]}></div>
|
|
74
|
+
{/if}
|
|
75
|
+
</div>
|
|
76
|
+
{#if data.body}
|
|
77
|
+
<div use:melt={$description(id)}>
|
|
78
|
+
{data.body}
|
|
79
|
+
</div>
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
<button use:melt={$close(id)} aria-label="Close notification"><Icon Icon={IconX} /></button>
|
|
83
|
+
</div>
|
|
84
|
+
{/each}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
:global(.light) {
|
|
89
|
+
--toastDotSuccess: var(--green-200);
|
|
90
|
+
--toastDotDanger: var(--yellow-200);
|
|
91
|
+
}
|
|
92
|
+
:global(.dark) {
|
|
93
|
+
--toastDotSuccess: var(--green-600);
|
|
94
|
+
--toastDotDanger: var(--yellow-600);
|
|
95
|
+
}
|
|
96
|
+
.toasts {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
gap: var(--size-2); /* Reduced gap to allow overlapping look */
|
|
100
|
+
width: 300px;
|
|
101
|
+
position: fixed;
|
|
102
|
+
right: var(--size-8);
|
|
103
|
+
bottom: var(--size-8);
|
|
104
|
+
z-index: 2;
|
|
105
|
+
}
|
|
106
|
+
.toast {
|
|
107
|
+
position: fixed;
|
|
108
|
+
right: var(--size-8);
|
|
109
|
+
bottom: var(--size-8);
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
align-items: start;
|
|
113
|
+
background: var(--fg);
|
|
114
|
+
color: var(--bg);
|
|
115
|
+
gap: var(--size-2);
|
|
116
|
+
width: 300px;
|
|
117
|
+
padding: var(--size-2);
|
|
118
|
+
border-radius: var(--radius-2);
|
|
119
|
+
box-shadow: var(--shadow-2);
|
|
120
|
+
border: 1px solid var(--bg);
|
|
121
|
+
transition:
|
|
122
|
+
transform 0.3s ease-in-out,
|
|
123
|
+
opacity 0.3s ease-in-out;
|
|
124
|
+
}
|
|
125
|
+
.toast__title {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: start;
|
|
128
|
+
gap: var(--size-2);
|
|
129
|
+
}
|
|
130
|
+
.toast__titleText {
|
|
131
|
+
font-weight: var(--font-weight-6);
|
|
132
|
+
}
|
|
133
|
+
.toasts.toasts--isHovered .toast {
|
|
134
|
+
position: static;
|
|
135
|
+
transition: none;
|
|
136
|
+
}
|
|
137
|
+
.toast__titleDot {
|
|
138
|
+
width: var(--size-2);
|
|
139
|
+
height: var(--size-2);
|
|
140
|
+
min-width: var(--size-2);
|
|
141
|
+
min-height: var(--size-2);
|
|
142
|
+
margin-top: var(--size-1);
|
|
143
|
+
border-radius: 50%;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.toast__titleDot--info {
|
|
147
|
+
background: var(--contrastHigh);
|
|
148
|
+
}
|
|
149
|
+
.toast__titleDot--success {
|
|
150
|
+
background: var(--toastDotSuccess);
|
|
151
|
+
}
|
|
152
|
+
.toast__titleDot--danger {
|
|
153
|
+
background: var(--toastDotDanger);
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import { addToast } from '../';
|
|
3
|
+
|
|
4
|
+
export const setToastCookie = (
|
|
5
|
+
event: RequestEvent,
|
|
6
|
+
{ title, type, body }: { title: string; type: string; body?: string }
|
|
7
|
+
) => {
|
|
8
|
+
event.cookies.set('toast', JSON.stringify({ title, type, body }), {
|
|
9
|
+
path: '/',
|
|
10
|
+
httpOnly: false,
|
|
11
|
+
sameSite: 'lax',
|
|
12
|
+
maxAge: 5
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const checkToastCookie = () => {
|
|
17
|
+
const toastCookie = document.cookie.split('; ').find((row) => row.startsWith('toast='));
|
|
18
|
+
|
|
19
|
+
if (toastCookie) {
|
|
20
|
+
const toastData = JSON.parse(decodeURIComponent(toastCookie.split('=')[1]));
|
|
21
|
+
addToast({ data: { title: toastData.title, type: toastData.type } });
|
|
22
|
+
document.cookie = 'toast=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createTooltip, melt } from '@melt-ui/svelte';
|
|
3
|
+
import { fade } from 'svelte/transition';
|
|
4
|
+
import type { ToolTipProps } from './types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
positioning = { placement: 'top' },
|
|
9
|
+
defaultOpen = false,
|
|
10
|
+
openDelay = 0,
|
|
11
|
+
closeDelay = 0,
|
|
12
|
+
closeOnPointerDown = false,
|
|
13
|
+
forceVisible = true,
|
|
14
|
+
disableHoverableContent = false,
|
|
15
|
+
toolTipContent
|
|
16
|
+
}: ToolTipProps = $props();
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
elements: { trigger, content, arrow },
|
|
20
|
+
states: { open }
|
|
21
|
+
} = createTooltip({
|
|
22
|
+
disableHoverableContent,
|
|
23
|
+
positioning,
|
|
24
|
+
defaultOpen,
|
|
25
|
+
openDelay,
|
|
26
|
+
closeDelay,
|
|
27
|
+
closeOnPointerDown,
|
|
28
|
+
forceVisible
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="trigger" use:melt={$trigger}>
|
|
33
|
+
{@render children()}
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
{#if $open}
|
|
37
|
+
<div use:melt={$content} transition:fade={{ duration: 100 }} class="tooltip">
|
|
38
|
+
<div use:melt={$arrow}></div>
|
|
39
|
+
{@render toolTipContent()}
|
|
40
|
+
</div>
|
|
41
|
+
{/if}
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
:global(.dark) {
|
|
45
|
+
color-scheme: dark;
|
|
46
|
+
--tooltip-bg: var(--fg);
|
|
47
|
+
--tooltip-color: var(--bg);
|
|
48
|
+
}
|
|
49
|
+
:global(.light) {
|
|
50
|
+
color-scheme: light;
|
|
51
|
+
--tooltip-bg: var(--fg);
|
|
52
|
+
--tooltip-color: var(--bg);
|
|
53
|
+
}
|
|
54
|
+
.tooltip {
|
|
55
|
+
padding: var(--size-1) var(--size-2);
|
|
56
|
+
background: var(--tooltip-bg);
|
|
57
|
+
color: var(--tooltip-color);
|
|
58
|
+
border-radius: var(--radius-1);
|
|
59
|
+
box-shadow: var(--shadow-1);
|
|
60
|
+
z-index: 1000;
|
|
61
|
+
text-align: center;
|
|
62
|
+
text-wrap: balance;
|
|
63
|
+
}
|
|
64
|
+
.trigger {
|
|
65
|
+
max-width: 100px;
|
|
66
|
+
display: block;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type ToolTipProps = {
|
|
3
|
+
children: Snippet;
|
|
4
|
+
positioning?: {
|
|
5
|
+
placement: 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
};
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
openDelay?: number;
|
|
9
|
+
closeDelay?: number;
|
|
10
|
+
closeOnPointerDown?: boolean;
|
|
11
|
+
forceVisible?: boolean;
|
|
12
|
+
disableHoverableContent?: boolean;
|
|
13
|
+
toolTipContent: Snippet;
|
|
14
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export * from './Avatar';
|
|
2
|
+
export * from './BrushSizeSlider';
|
|
3
|
+
export * from './Button';
|
|
4
|
+
export * from './CardFan';
|
|
5
|
+
export * from './CodeBlock';
|
|
6
|
+
export * from './ColorMode';
|
|
7
|
+
export * from './ColorPicker';
|
|
8
|
+
export * from './ContextMenu';
|
|
9
|
+
export * from './DrawingSliders';
|
|
10
|
+
export * from './Editor';
|
|
11
|
+
export * from './FogSliders';
|
|
12
|
+
export * from './Hr';
|
|
13
|
+
export * from './Icon';
|
|
14
|
+
export * from './Input';
|
|
15
|
+
export * from './Link';
|
|
16
|
+
export * from './Loading';
|
|
17
|
+
export * from './Logo';
|
|
18
|
+
export * from './Menu';
|
|
19
|
+
export { default as MyCounterButton } from './MyCounterButton.svelte';
|
|
20
|
+
export * from './Panel';
|
|
21
|
+
export * from './PersistButton';
|
|
22
|
+
export * from './Popover';
|
|
23
|
+
export { default as PropsTable } from './PropsTable/PropsTable.svelte';
|
|
24
|
+
export * from './RadialMenu';
|
|
25
|
+
export * from './Select';
|
|
26
|
+
export * from './Spacer';
|
|
27
|
+
export * from './Stage';
|
|
28
|
+
export * from './Table';
|
|
29
|
+
export * from './Text';
|
|
30
|
+
export * from './Title';
|
|
31
|
+
export * from './Toast';
|
|
32
|
+
export * from './ToolTip';
|
|
File without changes
|
package/src/lib/index.ts
ADDED