Skip to content

Commit 352c79a

Browse files
committed
main 🧊 add to index
1 parent 6effeea commit 352c79a

File tree

14 files changed

+157
-150
lines changed

14 files changed

+157
-150
lines changed

Diff for: ‎packages/core/src/bundle/hooks/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './useClipboard/useClipboard';
1010
export * from './useConst/useConst';
1111
export * from './useConst/useConst';
1212
export * from './useCookie/useCookie';
13+
export * from './useCookies/useCookies';
1314
export * from './useCounter/useCounter';
1415
export * from './useCssVar/useCssVar';
1516
export * from './useDebounceCallback/useDebounceCallback';
+80-80
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
export class Pointer {
2-
x;
3-
y;
4-
constructor(x, y) {
5-
this.x = x;
6-
this.y = y;
7-
}
8-
update(point) {
9-
this.x = point.x;
10-
this.y = point.y;
11-
}
12-
getDifferenceTo(point) {
13-
return new Pointer(this.x - point.x, this.y - point.y);
14-
}
15-
getDistanceTo(point) {
16-
const diff = this.getDifferenceTo(point);
17-
return Math.sqrt(diff.x ** 2 + diff.y ** 2);
18-
}
19-
getAngleTo(point) {
20-
const diff = this.getDifferenceTo(point);
21-
return Math.atan2(diff.y, diff.x);
22-
}
23-
equalsTo(point) {
24-
return this.x === point.x && this.y === point.y;
25-
}
26-
moveByAngle(
2+
x;
3+
y;
4+
constructor(x, y) {
5+
this.x = x;
6+
this.y = y;
7+
}
8+
update(point) {
9+
this.x = point.x;
10+
this.y = point.y;
11+
}
12+
getDifferenceTo(point) {
13+
return new Pointer(this.x - point.x, this.y - point.y);
14+
}
15+
getDistanceTo(point) {
16+
const diff = this.getDifferenceTo(point);
17+
return Math.sqrt(diff.x ** 2 + diff.y ** 2);
18+
}
19+
getAngleTo(point) {
20+
const diff = this.getDifferenceTo(point);
21+
return Math.atan2(diff.y, diff.x);
22+
}
23+
equalsTo(point) {
24+
return this.x === point.x && this.y === point.y;
25+
}
26+
moveByAngle(
2727
// The angle in radians
28-
angle,
28+
angle,
2929
// How much the point should be moved
30-
distance) {
31-
// Rotate the angle based on the browser coordinate system ([0,0] in the top left)
32-
const angleRotated = angle + Math.PI / 2;
33-
this.x += Math.sin(angleRotated) * distance;
34-
this.y -= Math.cos(angleRotated) * distance;
35-
return this;
36-
}
30+
distance
31+
) {
32+
// Rotate the angle based on the browser coordinate system ([0,0] in the top left)
33+
const angleRotated = angle + Math.PI / 2;
34+
this.x += Math.sin(angleRotated) * distance;
35+
this.y -= Math.cos(angleRotated) * distance;
36+
return this;
37+
}
3738
}
3839
export class Paint {
39-
pointer;
40-
brush;
41-
radius;
42-
smooth = false;
43-
points = [];
44-
lines = [];
45-
constructor({ x, y, radius, smooth }) {
46-
this.smooth = smooth;
47-
this.pointer = new Pointer(x, y);
48-
this.brush = new Pointer(x, y);
49-
this.radius = radius;
50-
this.points = [];
51-
this.lines = [];
52-
}
53-
getBrushCoordinates() {
54-
return {
55-
x: this.brush.x,
56-
y: this.brush.y
57-
};
58-
}
59-
getPointerCoordinates() {
60-
return {
61-
x: this.pointer.x,
62-
y: this.pointer.y
63-
};
40+
pointer;
41+
brush;
42+
radius;
43+
smooth = false;
44+
points = [];
45+
lines = [];
46+
constructor({ x, y, radius, smooth }) {
47+
this.smooth = smooth;
48+
this.pointer = new Pointer(x, y);
49+
this.brush = new Pointer(x, y);
50+
this.radius = radius;
51+
this.points = [];
52+
this.lines = [];
53+
}
54+
getBrushCoordinates() {
55+
return {
56+
x: this.brush.x,
57+
y: this.brush.y
58+
};
59+
}
60+
getPointerCoordinates() {
61+
return {
62+
x: this.pointer.x,
63+
y: this.pointer.y
64+
};
65+
}
66+
update(point) {
67+
if (this.pointer.equalsTo(point)) return false;
68+
this.pointer.update(point);
69+
if (!this.smooth) {
70+
this.brush.update(point);
71+
this.points.push(this.getBrushCoordinates());
72+
return true;
6473
}
65-
update(point) {
66-
if (this.pointer.equalsTo(point))
67-
return false;
68-
this.pointer.update(point);
69-
if (!this.smooth) {
70-
this.brush.update(point);
71-
this.points.push(this.getBrushCoordinates());
72-
return true;
73-
}
74-
const distance = this.pointer.getDistanceTo(this.brush);
75-
const angle = this.pointer.getAngleTo(this.brush);
76-
const isOutside = Math.round((distance - this.radius) * 10) / 10 > 0;
77-
if (isOutside) {
78-
const angleRotated = angle + Math.PI / 2;
79-
this.brush.update({
80-
x: this.brush.x + Math.sin(angleRotated) * (distance - this.radius),
81-
y: this.brush.y - Math.cos(angleRotated) * (distance - this.radius)
82-
});
83-
this.points.push(this.getBrushCoordinates());
84-
return true;
85-
}
86-
return false;
74+
const distance = this.pointer.getDistanceTo(this.brush);
75+
const angle = this.pointer.getAngleTo(this.brush);
76+
const isOutside = Math.round((distance - this.radius) * 10) / 10 > 0;
77+
if (isOutside) {
78+
const angleRotated = angle + Math.PI / 2;
79+
this.brush.update({
80+
x: this.brush.x + Math.sin(angleRotated) * (distance - this.radius),
81+
y: this.brush.y - Math.cos(angleRotated) * (distance - this.radius)
82+
});
83+
this.points.push(this.getBrushCoordinates());
84+
return true;
8785
}
86+
return false;
87+
}
8888
}

Diff for: ‎packages/core/src/bundle/utils/helpers/cookie.js

+18-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
export const getCookies = () => Object.fromEntries(document.cookie.split('; ').map((cookie) => {
2-
const [key, ...value] = cookie.split('=');
3-
const decodedValue = decodeURIComponent(value.join('='));
4-
return [key, decodedValue];
5-
}));
1+
export const getCookies = () =>
2+
Object.fromEntries(
3+
document.cookie.split('; ').map((cookie) => {
4+
const [key, ...value] = cookie.split('=');
5+
const decodedValue = decodeURIComponent(value.join('='));
6+
return [key, decodedValue];
7+
})
8+
);
69
export const removeCookie = (key, options = {}) => {
7-
document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${options.path ? `; path=${options.path}` : ''}${options.domain ? `; domain=${options.domain}` : ''}${options.maxAge ? `; max-age=0` : ''}${options.expires ? `; expires=Thu, 01 Jan 1970 00:00:00 GMT` : ''}${options.secure ? `; secure` : ''}${options.sameSite ? `; samesite=${options.sameSite}` : ''}`;
10+
document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${options.path ? `; path=${options.path}` : ''}${options.domain ? `; domain=${options.domain}` : ''}${options.maxAge ? `; max-age=0` : ''}${options.expires ? `; expires=Thu, 01 Jan 1970 00:00:00 GMT` : ''}${options.secure ? `; secure` : ''}${options.sameSite ? `; samesite=${options.sameSite}` : ''}`;
811
};
912
export const setCookie = (key, value, options = {}) => {
10-
const cookie = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];
11-
if (options.path)
12-
cookie.push(`path=${options.path}`);
13-
if (options.domain)
14-
cookie.push(`domain=${options.domain}`);
15-
if (typeof options.maxAge === 'number')
16-
cookie.push(`max-age=${options.maxAge}`);
17-
if (options.expires)
18-
cookie.push(`expires=${options.expires.toUTCString()}`);
19-
if (options.secure)
20-
cookie.push(`secure`);
21-
if (options.httpOnly)
22-
cookie.push(`httpOnly`);
23-
if (options.sameSite)
24-
cookie.push(`samesite=${options.sameSite}`);
25-
document.cookie = cookie.join('; ');
13+
const cookie = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];
14+
if (options.path) cookie.push(`path=${options.path}`);
15+
if (options.domain) cookie.push(`domain=${options.domain}`);
16+
if (typeof options.maxAge === 'number') cookie.push(`max-age=${options.maxAge}`);
17+
if (options.expires) cookie.push(`expires=${options.expires.toUTCString()}`);
18+
if (options.secure) cookie.push(`secure`);
19+
if (options.httpOnly) cookie.push(`httpOnly`);
20+
if (options.sameSite) cookie.push(`samesite=${options.sameSite}`);
21+
document.cookie = cookie.join('; ');
2622
};

Diff for: ‎packages/core/src/hooks/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './useClipboard/useClipboard';
1010
export * from './useConst/useConst';
1111
export * from './useConst/useConst';
1212
export * from './useCookie/useCookie';
13+
export * from './useCookies/useCookies';
1314
export * from './useCounter/useCounter';
1415
export * from './useCssVar/useCssVar';
1516
export * from './useDebounceCallback/useDebounceCallback';

Diff for: ‎packages/core/src/hooks/useBluetooth/useBluetooth.demo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Demo = () => {
4545
</button>
4646
{error && (
4747
<p>
48-
Errors: <code className='block p-5 whitespace-pre'>{error}</code>
48+
Errors: <code className='block whitespace-pre p-5'>{error}</code>
4949
</p>
5050
)}
5151
</>

Diff for: ‎packages/core/src/hooks/useCookies/useCookies.demo.tsx

+26-26
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@ import { useCookie } from '../useCookie/useCookie';
22
import { useCookies } from './useCookies';
33

44
const POKEMONS = [
5-
{ name: 'Pikachu', index: 25 },
6-
{ name: 'Bulbasaur', index: 1 },
7-
{ name: 'Charmander', index: 4 },
8-
{ name: 'Squirtle', index: 7 },
9-
{ name: 'Jigglypuff', index: 39 },
10-
{ name: 'Gengar', index: 94 },
11-
{ name: 'Mewtwo', index: 150 },
12-
{ name: 'Mew', index: 151 },
13-
{ name: 'Charizard', index: 6 },
14-
{ name: 'Blastoise', index: 9 },
15-
{ name: 'Venusaur', index: 3 },
5+
{ name: 'Pikachu', index: 25 },
6+
{ name: 'Bulbasaur', index: 1 },
7+
{ name: 'Charmander', index: 4 },
8+
{ name: 'Squirtle', index: 7 },
9+
{ name: 'Jigglypuff', index: 39 },
10+
{ name: 'Gengar', index: 94 },
11+
{ name: 'Mewtwo', index: 150 },
12+
{ name: 'Mew', index: 151 },
13+
{ name: 'Charizard', index: 6 },
14+
{ name: 'Blastoise', index: 9 },
15+
{ name: 'Venusaur', index: 3 }
1616
];
1717

1818
const Demo = () => {
19-
const pokemonsCookie = useCookie('pokemon', POKEMONS[0]);
20-
const cookies = useCookies<{ name: string, id: number }>();
19+
const pokemonsCookie = useCookie('pokemon', POKEMONS[0]);
20+
const cookies = useCookies<{ name: string; id: number }>();
2121

22-
return (
23-
<div>
24-
<div>Cookies</div>
25-
<pre>{JSON.stringify(cookies.value, null, 2)}</pre>
22+
return (
23+
<div>
24+
<div>Cookies</div>
25+
<pre>{JSON.stringify(cookies.value, null, 2)}</pre>
2626

27-
<button onClick={() => pokemonsCookie.set(POKEMONS[Math.floor(Math.random() * POKEMONS.length)])}>
28-
Change user
29-
</button>
30-
<button onClick={cookies.clear}>
31-
Clear
32-
</button>
33-
</div>
34-
);
27+
<button
28+
onClick={() => pokemonsCookie.set(POKEMONS[Math.floor(Math.random() * POKEMONS.length)])}
29+
>
30+
Change user
31+
</button>
32+
<button onClick={cookies.clear}>Clear</button>
33+
</div>
34+
);
3535
};
3636

37-
export default Demo;
37+
export default Demo;

Diff for: ‎packages/core/src/hooks/usePointerLock/usePointerLock.demo.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const Demo = () => {
3636
);
3737

3838
return (
39-
<div className='flex h-32 items-center justify-center perspective-normal'>
39+
<div className='perspective-normal flex h-32 items-center justify-center'>
4040
<div
41-
className='relative h-[100px] w-[100px] cursor-all-scroll transform-3d'
41+
className='transform-3d relative h-[100px] w-[100px] cursor-all-scroll'
4242
style={{ transform: `rotateY(calc(-45 * 1deg))` }}
4343
onMouseDownCapture={lock}
4444
onMouseUpCapture={unlock}

Diff for: ‎packages/core/src/hooks/useScroll/useScroll.demo.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ const Demo = () => {
2121
<div className='flex gap-10'>
2222
<div ref={scrollRef} className='h-[300px] w-full overflow-scroll rounded-lg bg-zinc-800'>
2323
<div className='relative h-[400px] w-[500px]'>
24-
<div className='absolute top-0 left-0 bg-zinc-600 p-1'>TopLeft</div>
24+
<div className='absolute left-0 top-0 bg-zinc-600 p-1'>TopLeft</div>
2525
<div className='absolute bottom-0 left-0 bg-zinc-600 p-1'>BottomLeft</div>
26-
<div className='absolute top-0 right-0 bg-zinc-600 p-1'>TopRight</div>
27-
<div className='absolute right-0 bottom-0 bg-zinc-600 p-1'>BottomRight</div>
28-
<div className='absolute top-1/3 left-1/3 bg-zinc-600 p-1'>Scroll Me</div>
26+
<div className='absolute right-0 top-0 bg-zinc-600 p-1'>TopRight</div>
27+
<div className='absolute bottom-0 right-0 bg-zinc-600 p-1'>BottomRight</div>
28+
<div className='absolute left-1/3 top-1/3 bg-zinc-600 p-1'>Scroll Me</div>
2929
</div>
3030
</div>
3131

Diff for: ‎packages/core/src/hooks/useScrollIntoView/useScrollIntoView.demo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Demo = () => {
66
return (
77
<div
88
ref={scrollIntoView.ref}
9-
className='m-2 w-full rounded-md border border-gray-300 p-15 text-center'
9+
className='p-15 m-2 w-full rounded-md border border-gray-300 text-center'
1010
>
1111
<p>Scroll into view block</p>
1212
<p>

Diff for: ‎packages/docs/app/.vitepress/theme/global.css

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
@import 'tailwindcss';
22
@custom-variant dark (&:where(.dark, .dark *));
33

4-
54
:root {
65
--vp-home-hero-name-color: transparent;
7-
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #61DAFB, #205DAE);
8-
6+
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #61dafb, #205dae);
7+
98
--vp-c-bg: #ffffff;
109

11-
--vp-c-brand-1: #61DAFB;
10+
--vp-c-brand-1: #61dafb;
1211
--vp-c-brand-2: #4ca8c6;
1312
--vp-c-brand-3: #5fc6e9;
1413
}

Diff for: ‎packages/docs/src/components/api.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ props.apiParameters.forEach((parameter, index) => {
3838

3939
<template>
4040
<div v-for="group in groups" :key="group.id">
41-
<h3 v-if="group.parameters.length">Parameters</h3>
41+
<h3 v-if="group.parameters.length">
42+
Parameters
43+
</h3>
4244
<table v-if="group.parameters.length">
4345
<thead>
4446
<tr>

Diff for: ‎packages/docs/src/components/demo.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ onUnmounted(() => {
3030

3131
<template>
3232
<div class="relative mb-2 rounded-lg bg-[var(--vp-code-block-bg)] p-6">
33-
<p class="absolute top-0 right-2 text-xs font-medium transition-colors">
33+
<p class="absolute right-2 top-0 text-xs font-medium transition-colors">
3434
<a :href="sourceLink" target="_blank">source</a>
3535
</p>
3636
<div ref="demoRef" />

0 commit comments

Comments
 (0)