@elyndra/vue-bgs 1.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.
- package/package.json +54 -0
- package/src/Dots/Dots.test.ts +15 -0
- package/src/Dots/Dots.vue +57 -0
- package/src/Dots/index.ts +1 -0
- package/src/GridLines/GridLines.test.ts +15 -0
- package/src/GridLines/GridLines.vue +57 -0
- package/src/GridLines/index.ts +1 -0
- package/src/MovingLines/MovingLines.test.ts +15 -0
- package/src/MovingLines/MovingLines.vue +57 -0
- package/src/MovingLines/index.ts +1 -0
- package/src/Puffs/Puffs.test.ts +15 -0
- package/src/Puffs/Puffs.vue +57 -0
- package/src/Puffs/index.ts +1 -0
- package/src/index.ts +5 -0
- package/src/internal/styles.ts +12 -0
- package/src/types.ts +42 -0
- package/src/vue.d.ts +8 -0
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elyndra/vue-bgs",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "Elyndra backgrounds components for Vue",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"elyndra",
|
|
11
|
+
"ui",
|
|
12
|
+
"front-end",
|
|
13
|
+
"framework",
|
|
14
|
+
"scifi",
|
|
15
|
+
"sci-fi",
|
|
16
|
+
"science-fiction",
|
|
17
|
+
"vue"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://elyndra.dev",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Gabox301/elyndra.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Gabox301/elyndra/issues"
|
|
26
|
+
},
|
|
27
|
+
"funding": "https://github.com/sponsors/romelperez",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"files": [
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./src/index.ts"
|
|
34
|
+
},
|
|
35
|
+
"types": "./src/index.ts",
|
|
36
|
+
"module": "./src/index.ts",
|
|
37
|
+
"main": "./src/index.ts",
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"vue": "3"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@elyndra/animated": "^1.2.0",
|
|
43
|
+
"@elyndra/animator": "^1.2.0",
|
|
44
|
+
"@elyndra/bgs": "^1.2.0",
|
|
45
|
+
"@elyndra/tools": "^1.2.0",
|
|
46
|
+
"@elyndra/vue-animated": "^1.2.0",
|
|
47
|
+
"@elyndra/vue-animator": "^1.2.0",
|
|
48
|
+
"@elyndra/vue-tools": "^1.2.0",
|
|
49
|
+
"tslib": "2.8.1"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc --noEmit -p tsconfig.json && vue-tsc --noEmit -p tsconfig.json"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { Dots } from './index.js';
|
|
4
|
+
|
|
5
|
+
test('Should render canvas element with elyndra class', async () => {
|
|
6
|
+
const wrapper = mount(Dots, {
|
|
7
|
+
props: { color: 'cyan' },
|
|
8
|
+
});
|
|
9
|
+
await flushPromises();
|
|
10
|
+
|
|
11
|
+
const element = wrapper.element as HTMLElement;
|
|
12
|
+
expect(element.tagName).toBe('CANVAS');
|
|
13
|
+
expect(element.classList.contains('elyndra-bgs-dots')).toBe(true);
|
|
14
|
+
wrapper.unmount();
|
|
15
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { createBackgroundDots } from '@elyndra/bgs';
|
|
3
|
+
import { cx } from '@elyndra/tools';
|
|
4
|
+
import { useAnimator } from '@elyndra/vue-animator';
|
|
5
|
+
import { mergeRefs } from '@elyndra/vue-tools';
|
|
6
|
+
import { watch } from 'vue';
|
|
7
|
+
import { positionedStyle } from '../internal/styles.js';
|
|
8
|
+
import type { DotsProps } from '../types.js';
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<DotsProps>(), {
|
|
11
|
+
// Vue boolean-casts absent props with a Boolean type to `false`.
|
|
12
|
+
// `positioned` defaults to `true`, so it gets an `undefined` default
|
|
13
|
+
// which skips the cast.
|
|
14
|
+
positioned: undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const getAnimator = useAnimator();
|
|
18
|
+
const canvasBox: { current: HTMLCanvasElement | null } = { current: null };
|
|
19
|
+
// The props object stays live, so the vanilla background always reads the
|
|
20
|
+
// latest settings, same as the per-render ref update in React/Preact and the
|
|
21
|
+
// Solid proxy.
|
|
22
|
+
const settingsRef: { current: DotsProps } = { current: props };
|
|
23
|
+
|
|
24
|
+
const setCanvasRef = (value: unknown): void => {
|
|
25
|
+
const element = value as HTMLCanvasElement | null;
|
|
26
|
+
canvasBox.current = element;
|
|
27
|
+
mergeRefs(props.elementRef)(element);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
watch(
|
|
31
|
+
() => [canvasBox.current, getAnimator?.()] as const,
|
|
32
|
+
([canvas, animator], _previous, onCleanup) => {
|
|
33
|
+
if (!canvas) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const background = createBackgroundDots({
|
|
38
|
+
canvas,
|
|
39
|
+
animator: animator?.node,
|
|
40
|
+
settingsRef,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onCleanup(() => background.cancel());
|
|
44
|
+
},
|
|
45
|
+
{ immediate: true, flush: 'post' },
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<canvas
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
:ref="setCanvasRef"
|
|
53
|
+
:id="props.id"
|
|
54
|
+
:class="cx('elyndra-bgs-dots', props.className)"
|
|
55
|
+
:style="{ ...((props.positioned ?? true) ? positionedStyle : null), ...props.style }"
|
|
56
|
+
/>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Dots } from './Dots.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { GridLines } from './index.js';
|
|
4
|
+
|
|
5
|
+
test('Should render canvas element with elyndra class', async () => {
|
|
6
|
+
const wrapper = mount(GridLines, {
|
|
7
|
+
props: { color: 'cyan' },
|
|
8
|
+
});
|
|
9
|
+
await flushPromises();
|
|
10
|
+
|
|
11
|
+
const element = wrapper.element as HTMLElement;
|
|
12
|
+
expect(element.tagName).toBe('CANVAS');
|
|
13
|
+
expect(element.classList.contains('elyndra-bgs-gridlines')).toBe(true);
|
|
14
|
+
wrapper.unmount();
|
|
15
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { createBackgroundGridLines } from '@elyndra/bgs';
|
|
3
|
+
import { cx } from '@elyndra/tools';
|
|
4
|
+
import { useAnimator } from '@elyndra/vue-animator';
|
|
5
|
+
import { mergeRefs } from '@elyndra/vue-tools';
|
|
6
|
+
import { watch } from 'vue';
|
|
7
|
+
import { positionedStyle } from '../internal/styles.js';
|
|
8
|
+
import type { GridLinesProps } from '../types.js';
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<GridLinesProps>(), {
|
|
11
|
+
// Vue boolean-casts absent props with a Boolean type to `false`.
|
|
12
|
+
// `positioned` defaults to `true`, so it gets an `undefined` default
|
|
13
|
+
// which skips the cast.
|
|
14
|
+
positioned: undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const getAnimator = useAnimator();
|
|
18
|
+
const canvasBox: { current: HTMLCanvasElement | null } = { current: null };
|
|
19
|
+
// The props object stays live, so the vanilla background always reads the
|
|
20
|
+
// latest settings, same as the per-render ref update in React/Preact and the
|
|
21
|
+
// Solid proxy.
|
|
22
|
+
const settingsRef: { current: GridLinesProps } = { current: props };
|
|
23
|
+
|
|
24
|
+
const setCanvasRef = (value: unknown): void => {
|
|
25
|
+
const element = value as HTMLCanvasElement | null;
|
|
26
|
+
canvasBox.current = element;
|
|
27
|
+
mergeRefs(props.elementRef)(element);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
watch(
|
|
31
|
+
() => [canvasBox.current, getAnimator?.()] as const,
|
|
32
|
+
([canvas, animator], _previous, onCleanup) => {
|
|
33
|
+
if (!canvas) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const background = createBackgroundGridLines({
|
|
38
|
+
canvas,
|
|
39
|
+
animator: animator?.node,
|
|
40
|
+
settingsRef,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onCleanup(() => background.cancel());
|
|
44
|
+
},
|
|
45
|
+
{ immediate: true, flush: 'post' },
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<canvas
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
:ref="setCanvasRef"
|
|
53
|
+
:id="props.id"
|
|
54
|
+
:class="cx('elyndra-bgs-gridlines', props.className)"
|
|
55
|
+
:style="{ ...((props.positioned ?? true) ? positionedStyle : null), ...props.style }"
|
|
56
|
+
/>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as GridLines } from './GridLines.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { MovingLines } from './index.js';
|
|
4
|
+
|
|
5
|
+
test('Should render canvas element with elyndra class', async () => {
|
|
6
|
+
const wrapper = mount(MovingLines, {
|
|
7
|
+
props: { color: 'cyan' },
|
|
8
|
+
});
|
|
9
|
+
await flushPromises();
|
|
10
|
+
|
|
11
|
+
const element = wrapper.element as HTMLElement;
|
|
12
|
+
expect(element.tagName).toBe('CANVAS');
|
|
13
|
+
expect(element.classList.contains('elyndra-bgs-movinglines')).toBe(true);
|
|
14
|
+
wrapper.unmount();
|
|
15
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { createBackgroundMovingLines } from '@elyndra/bgs';
|
|
3
|
+
import { cx } from '@elyndra/tools';
|
|
4
|
+
import { useAnimator } from '@elyndra/vue-animator';
|
|
5
|
+
import { mergeRefs } from '@elyndra/vue-tools';
|
|
6
|
+
import { watch } from 'vue';
|
|
7
|
+
import { positionedStyle } from '../internal/styles.js';
|
|
8
|
+
import type { MovingLinesProps } from '../types.js';
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<MovingLinesProps>(), {
|
|
11
|
+
// Vue boolean-casts absent props with a Boolean type to `false`.
|
|
12
|
+
// `positioned` defaults to `true`, so it gets an `undefined` default
|
|
13
|
+
// which skips the cast.
|
|
14
|
+
positioned: undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const getAnimator = useAnimator();
|
|
18
|
+
const canvasBox: { current: HTMLCanvasElement | null } = { current: null };
|
|
19
|
+
// The props object stays live, so the vanilla background always reads the
|
|
20
|
+
// latest settings, same as the per-render ref update in React/Preact and the
|
|
21
|
+
// Solid proxy.
|
|
22
|
+
const settingsRef: { current: MovingLinesProps } = { current: props };
|
|
23
|
+
|
|
24
|
+
const setCanvasRef = (value: unknown): void => {
|
|
25
|
+
const element = value as HTMLCanvasElement | null;
|
|
26
|
+
canvasBox.current = element;
|
|
27
|
+
mergeRefs(props.elementRef)(element);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
watch(
|
|
31
|
+
() => [canvasBox.current, getAnimator?.()] as const,
|
|
32
|
+
([canvas, animator], _previous, onCleanup) => {
|
|
33
|
+
if (!canvas) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const background = createBackgroundMovingLines({
|
|
38
|
+
canvas,
|
|
39
|
+
animator: animator?.node,
|
|
40
|
+
settingsRef,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onCleanup(() => background.cancel());
|
|
44
|
+
},
|
|
45
|
+
{ immediate: true, flush: 'post' },
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<canvas
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
:ref="setCanvasRef"
|
|
53
|
+
:id="props.id"
|
|
54
|
+
:class="cx('elyndra-bgs-movinglines', props.className)"
|
|
55
|
+
:style="{ ...((props.positioned ?? true) ? positionedStyle : null), ...props.style }"
|
|
56
|
+
/>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MovingLines } from './MovingLines.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { flushPromises, mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { Puffs } from './index.js';
|
|
4
|
+
|
|
5
|
+
test('Should render canvas element with elyndra class', async () => {
|
|
6
|
+
const wrapper = mount(Puffs, {
|
|
7
|
+
props: { color: 'cyan', quantity: 10 },
|
|
8
|
+
});
|
|
9
|
+
await flushPromises();
|
|
10
|
+
|
|
11
|
+
const element = wrapper.element as HTMLElement;
|
|
12
|
+
expect(element.tagName).toBe('CANVAS');
|
|
13
|
+
expect(element.classList.contains('elyndra-bgs-puffs')).toBe(true);
|
|
14
|
+
wrapper.unmount();
|
|
15
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { createBackgroundPuffs } from '@elyndra/bgs';
|
|
3
|
+
import { cx } from '@elyndra/tools';
|
|
4
|
+
import { useAnimator } from '@elyndra/vue-animator';
|
|
5
|
+
import { mergeRefs } from '@elyndra/vue-tools';
|
|
6
|
+
import { watch } from 'vue';
|
|
7
|
+
import { positionedStyle } from '../internal/styles.js';
|
|
8
|
+
import type { PuffsProps } from '../types.js';
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<PuffsProps>(), {
|
|
11
|
+
// Vue boolean-casts absent props with a Boolean type to `false`.
|
|
12
|
+
// `positioned` defaults to `true`, so it gets an `undefined` default
|
|
13
|
+
// which skips the cast.
|
|
14
|
+
positioned: undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const getAnimator = useAnimator();
|
|
18
|
+
const canvasBox: { current: HTMLCanvasElement | null } = { current: null };
|
|
19
|
+
// The props object stays live, so the vanilla background always reads the
|
|
20
|
+
// latest settings, same as the per-render ref update in React/Preact and the
|
|
21
|
+
// Solid proxy.
|
|
22
|
+
const settingsRef: { current: PuffsProps } = { current: props };
|
|
23
|
+
|
|
24
|
+
const setCanvasRef = (value: unknown): void => {
|
|
25
|
+
const element = value as HTMLCanvasElement | null;
|
|
26
|
+
canvasBox.current = element;
|
|
27
|
+
mergeRefs(props.elementRef)(element);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
watch(
|
|
31
|
+
() => [canvasBox.current, getAnimator?.()] as const,
|
|
32
|
+
([canvas, animator], _previous, onCleanup) => {
|
|
33
|
+
if (!canvas) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const background = createBackgroundPuffs({
|
|
38
|
+
canvas,
|
|
39
|
+
animator: animator?.node,
|
|
40
|
+
settingsRef,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onCleanup(() => background.cancel());
|
|
44
|
+
},
|
|
45
|
+
{ immediate: true, flush: 'post' },
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<canvas
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
:ref="setCanvasRef"
|
|
53
|
+
:id="props.id"
|
|
54
|
+
:class="cx('elyndra-bgs-puffs', props.className)"
|
|
55
|
+
:style="{ ...((props.positioned ?? true) ? positionedStyle : null), ...props.style }"
|
|
56
|
+
/>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Puffs } from './Puffs.vue';
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
import type {
|
|
3
|
+
CreateBackgroundDotsSettings,
|
|
4
|
+
CreateBackgroundGridLinesSettings,
|
|
5
|
+
CreateBackgroundMovingLinesSettings,
|
|
6
|
+
CreateBackgroundPuffsSettings,
|
|
7
|
+
} from '@elyndra/bgs';
|
|
8
|
+
import type { ElementRef } from '@elyndra/vue-tools';
|
|
9
|
+
|
|
10
|
+
interface DotsProps extends CreateBackgroundDotsSettings {
|
|
11
|
+
elementRef?: ElementRef<HTMLCanvasElement>;
|
|
12
|
+
id?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
positioned?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface GridLinesProps extends CreateBackgroundGridLinesSettings {
|
|
19
|
+
elementRef?: ElementRef<HTMLCanvasElement>;
|
|
20
|
+
id?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
positioned?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface MovingLinesProps extends CreateBackgroundMovingLinesSettings {
|
|
27
|
+
elementRef?: ElementRef<HTMLCanvasElement>;
|
|
28
|
+
id?: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
style?: CSSProperties;
|
|
31
|
+
positioned?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PuffsProps extends CreateBackgroundPuffsSettings {
|
|
35
|
+
elementRef?: ElementRef<HTMLCanvasElement>;
|
|
36
|
+
id?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
positioned?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type { DotsProps, ElementRef, GridLinesProps, MovingLinesProps, PuffsProps };
|
package/src/vue.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// In-repo ambient types for `.vue` imports (tests only). The published
|
|
2
|
+
// package ships the `.vue` sources and consumers get full prop inference
|
|
3
|
+
// from their own Vue setup.
|
|
4
|
+
declare module '*.vue' {
|
|
5
|
+
import type { DefineComponent } from 'vue';
|
|
6
|
+
const Component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
|
|
7
|
+
export default Component;
|
|
8
|
+
}
|