diff --git a/src/components/generators/CardGenerator.astro b/src/components/generators/CardGenerator.astro index 42c340e..e88277e 100644 --- a/src/components/generators/CardGenerator.astro +++ b/src/components/generators/CardGenerator.astro @@ -1,188 +1,272 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
- - +
+
+ + +
+
- -
- - -
-
- - -
+

-
- -
+
+
+
+ + +
+ +
+ +
diff --git a/src/components/generators/CoinGenerator.astro b/src/components/generators/CoinGenerator.astro index be3a60b..dc79e6a 100644 --- a/src/components/generators/CoinGenerator.astro +++ b/src/components/generators/CoinGenerator.astro @@ -1,148 +1,200 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
- - 1 +
+
+ + 1 +
+ +
+ 120 +
- -
- 120 + +
+
+
+ + + +
-
-
-
- - - - -
- -
- -
+
+ +
diff --git a/src/components/generators/ListGenerator.astro b/src/components/generators/ListGenerator.astro index b36bfa9..c724dcb 100644 --- a/src/components/generators/ListGenerator.astro +++ b/src/components/generators/ListGenerator.astro @@ -1,179 +1,251 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
- - +
+
+ + +
+ +
+
+ + +
+ +
-
-
- - -
- + + +
+
+
+ +
-
- - -
-
- - -
- -
- -
+
+ +
diff --git a/src/components/generators/LotteryGenerator.astro b/src/components/generators/LotteryGenerator.astro index 6952ccf..dba76b1 100644 --- a/src/components/generators/LotteryGenerator.astro +++ b/src/components/generators/LotteryGenerator.astro @@ -1,116 +1,224 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
- - +
+
+ + +
+
+ + +
+
+ + +
-
- - + + + +
+
+
+
-
- - + +
+
-
- - - -
-
- -
- -
- -
diff --git a/src/components/generators/NumberGenerator.astro b/src/components/generators/NumberGenerator.astro index 4200483..5ac6594 100644 --- a/src/components/generators/NumberGenerator.astro +++ b/src/components/generators/NumberGenerator.astro @@ -1,126 +1,182 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); --- -
-
-
- - +
+
+
+ + +
+
+ + +
-
- - + + + +
+ + {T.copied}
-
- - -
- - {T.copied} -
- -
- -
+
+ +
diff --git a/src/components/generators/PasswordGenerator.astro b/src/components/generators/PasswordGenerator.astro index 129acfd..3fd261a 100644 --- a/src/components/generators/PasswordGenerator.astro +++ b/src/components/generators/PasswordGenerator.astro @@ -1,123 +1,227 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
-
- - 16 -
- -
464
+
+
+
+ + 16 +
+ +
+ 464 +
+
+
+ { + [ + { id: "pg-upper", label: T.uppercase }, + { id: "pg-lower", label: T.lowercase }, + { id: "pg-digits", label: T.digits }, + { id: "pg-symbols", label: T.symbols }, + ].map(({ id, label }) => ( + + )) + } +
-
- {[ - { id: 'pg-upper', label: T.uppercase }, - { id: 'pg-lower', label: T.lowercase }, - { id: 'pg-digits', label: T.digits }, - { id: 'pg-symbols', label: T.symbols }, - ].map(({ id, label }) => ( - - ))} + + + +
+ + {T.copied}
-
- - -
- - {T.copied} -
- -
- -
+
+ +
diff --git a/src/components/generators/UuidGenerator.astro b/src/components/generators/UuidGenerator.astro index 1948870..b3b56e4 100644 --- a/src/components/generators/UuidGenerator.astro +++ b/src/components/generators/UuidGenerator.astro @@ -1,191 +1,263 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
-
-
- -
- {[ - { value: 'uuid', label: 'UUID v4' }, - { value: 'hex', label: 'Hex' }, - { value: 'base64', label: 'Base64' }, - ].map(({ value, label }) => ( -
-
- -
- - -
+
+
-
- -
-
- - -
- -
- -
diff --git a/src/components/generators/WheelSpinner.astro b/src/components/generators/WheelSpinner.astro index 166a2ac..b255ca6 100644 --- a/src/components/generators/WheelSpinner.astro +++ b/src/components/generators/WheelSpinner.astro @@ -1,332 +1,436 @@ --- -import { useT } from '../../i18n/translations'; -const isRu = Astro.url.pathname.startsWith('/ru'); -const T = useT(isRu ? 'ru' : 'en'); +import { useT } from "../../i18n/translations"; +const isRu = Astro.url.pathname.startsWith("/ru"); +const T = useT(isRu ? "ru" : "en"); ---
- - -
-
- - -
- -
- - -
-
- - - + +
+
+ + +
+
- -
+ +
+
+ + + +
- - + +
+ +
diff --git a/src/lib/client/animations.ts b/src/lib/client/animations.ts new file mode 100644 index 0000000..123714c --- /dev/null +++ b/src/lib/client/animations.ts @@ -0,0 +1,10 @@ +export function popElement(el: HTMLElement) { + el.style.transform = 'scale(1.18)'; + el.style.opacity = '0.7'; + requestAnimationFrame(() => + requestAnimationFrame(() => { + el.style.transform = 'scale(1)'; + el.style.opacity = '1'; + }) + ); +} diff --git a/src/lib/client/clipboard.ts b/src/lib/client/clipboard.ts new file mode 100644 index 0000000..d4fc76a --- /dev/null +++ b/src/lib/client/clipboard.ts @@ -0,0 +1,25 @@ +export class CopyFeedback { + private timer: ReturnType | null = null; + + constructor( + private copyIcon: HTMLElement, + private checkIcon: HTMLElement, + private duration = 1500 + ) {} + + showCopied() { + this.copyIcon.classList.add('hidden'); + this.checkIcon.classList.remove('hidden'); + if (this.timer) clearTimeout(this.timer); + this.timer = setTimeout(() => this.revert(), this.duration); + } + + revert() { + this.checkIcon.classList.add('hidden'); + this.copyIcon.classList.remove('hidden'); + } + + cleanup() { + if (this.timer) clearTimeout(this.timer); + } +} diff --git a/src/lib/client/validation.ts b/src/lib/client/validation.ts new file mode 100644 index 0000000..4f873e6 --- /dev/null +++ b/src/lib/client/validation.ts @@ -0,0 +1,16 @@ +export function createErrorDisplay(errorEl: HTMLElement) { + return { + show(msg: string) { + errorEl.textContent = msg; + errorEl.classList.remove('hidden'); + }, + clear() { + errorEl.textContent = ''; + errorEl.classList.add('hidden'); + }, + }; +} + +export function isInteger(val: string): boolean { + return /^-?\d+$/.test(val.trim()); +}