From 5b60394dfa526eee7a091687e5324ae44355a8ab Mon Sep 17 00:00:00 2001 From: JulienAuvo Date: Wed, 26 Mar 2025 15:04:41 +0300 Subject: [PATCH 01/16] fix: Check Lint / lint --- .../lib/fragments/Header/Header.stories.ts | 58 ++++++++++--------- .../lib/ui/Connection/Connection.stories.ts | 40 +++++++------ .../src/lib/ui/Drawer/Drawer.stories.ts | 30 +++++----- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/infrastructure/eid-wallet/src/lib/fragments/Header/Header.stories.ts b/infrastructure/eid-wallet/src/lib/fragments/Header/Header.stories.ts index 4b268e0b..9f8acb01 100644 --- a/infrastructure/eid-wallet/src/lib/fragments/Header/Header.stories.ts +++ b/infrastructure/eid-wallet/src/lib/fragments/Header/Header.stories.ts @@ -1,35 +1,39 @@ -import Header from "./Header.svelte"; +import Header from './Header.svelte' export default { - title: "Fragments/Header", - component: Header, - tags: ["autodocs"], - render: (args: any) => ({ - Component: Header, - props: args, - }), -}; + title: 'Fragments/Header', + component: Header, + tags: ['autodocs'], + render: (args: { + title: string + isBackRequired: boolean + isUserLoggedIn: boolean + }) => ({ + Component: Header, + props: args, + }), +} export const Primary = { - args: { - title: "Create PIN", - isBackRequired: false, - isUserLoggedIn: false, - }, -}; + args: { + title: 'Create PIN', + isBackRequired: false, + isUserLoggedIn: false, + }, +} export const Secondary = { - args: { - title: "Create PIN", - isBackRequired: true, - isUserLoggedIn: false, - }, -}; + args: { + title: 'Create PIN', + isBackRequired: true, + isUserLoggedIn: false, + }, +} export const Tertiary = { - args: { - title: "Create PIN", - isBackRequired: true, - isUserLoggedIn: true, - }, -}; + args: { + title: 'Create PIN', + isBackRequired: true, + isUserLoggedIn: true, + }, +} diff --git a/infrastructure/eid-wallet/src/lib/ui/Connection/Connection.stories.ts b/infrastructure/eid-wallet/src/lib/ui/Connection/Connection.stories.ts index 45bd158f..37213545 100644 --- a/infrastructure/eid-wallet/src/lib/ui/Connection/Connection.stories.ts +++ b/infrastructure/eid-wallet/src/lib/ui/Connection/Connection.stories.ts @@ -1,22 +1,26 @@ -import Connection from "./Connection.svelte"; +import Connection from './Connection.svelte' export default { - title: "UI/Connection", - component: Connection, - tags: ["autodocs"], - render: (args: any) => ({ - Component: Connection, - props: args, - }), -}; + title: 'UI/Connection', + component: Connection, + tags: ['autodocs'], + render: (args: { + imgSrc: string + connectionName: string + lastConnected: string + onClick: () => void + }) => ({ + Component: Connection, + props: args, + }), +} export const Primary = { - args: { - imgSrc: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRGPvo_J4nWlDM0kxFW0rsfR5UeOOC6uMvpfQ&s", - connectionName: "Facebook.com", - lastConnected: - new Date().toDateString() + ", " + new Date().toLocaleTimeString(), - onClick: () => alert("Disconnected!"), - }, -}; + args: { + imgSrc: + 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRGPvo_J4nWlDM0kxFW0rsfR5UeOOC6uMvpfQ&s', + connectionName: 'Facebook.com', + lastConnected: `${new Date().toDateString()}, ${new Date().toLocaleTimeString()}`, + onClick: () => alert('Disconnected!'), + }, +} diff --git a/infrastructure/eid-wallet/src/lib/ui/Drawer/Drawer.stories.ts b/infrastructure/eid-wallet/src/lib/ui/Drawer/Drawer.stories.ts index 27e56c93..0d14da23 100644 --- a/infrastructure/eid-wallet/src/lib/ui/Drawer/Drawer.stories.ts +++ b/infrastructure/eid-wallet/src/lib/ui/Drawer/Drawer.stories.ts @@ -1,19 +1,19 @@ -import Drawer from "./Drawer.svelte"; -import { InnerContent } from "./Drawer.stories.snippet.svelte"; +import Drawer from './Drawer.svelte' +import { InnerContent } from './Drawer.stories.snippet.svelte' export default { - title: "UI/Drawer", - component: Drawer, - tags: ["autodocs"], - render: (args: any) => ({ - Component: Drawer, - props: args, - }), -}; + title: 'UI/Drawer', + component: Drawer, + tags: ['autodocs'], + render: (args: { isPaneOpen: boolean; children: any }) => ({ + Component: Drawer, + props: args, + }), +} export const Default = { - args: { - isPaneOpen: true, - children: InnerContent, - }, -}; + args: { + isPaneOpen: true, + children: InnerContent, + }, +} From 772032bdefdb21b80048088a6f5a9adbe41d745b Mon Sep 17 00:00:00 2001 From: JulienAuvo Date: Wed, 26 Mar 2025 15:04:48 +0300 Subject: [PATCH 02/16] fix: Check Lint / lint --- .../src/lib/ui/InputPin/InputPin.stories.ts | 48 ++++++++--------- .../src/lib/ui/InputPin/InputPin.svelte | 36 ++++++------- .../src/lib/ui/Selector/Selector.svelte | 51 +++++++++---------- 3 files changed, 67 insertions(+), 68 deletions(-) diff --git a/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.stories.ts b/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.stories.ts index 6ac3044c..dd734a00 100644 --- a/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.stories.ts +++ b/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.stories.ts @@ -1,31 +1,31 @@ -import InputPin from "./InputPin.svelte"; +import InputPin from './InputPin.svelte' export default { - title: "UI/InputPin", - component: InputPin, - tags: ["autodocs"], - render: (args: any) => ({ - Component: InputPin, - props: args, - }), -}; + title: 'UI/InputPin', + component: InputPin, + tags: ['autodocs'], + render: (args: { size: number; variant: string; isError: boolean }) => ({ + Component: InputPin, + props: args, + }), +} export const Default = { - args: { - size: 4, - }, -}; + args: { + size: 4, + }, +} export const Small = { - args: { - size: 4, - variant: "sm", - }, -}; + args: { + size: 4, + variant: 'sm', + }, +} -export const Error = { - args: { - size: 4, - isError: true, - }, -}; +export const isError = { + args: { + size: 4, + isError: true, + }, +} diff --git a/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.svelte b/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.svelte index 1de92ba4..365126e9 100644 --- a/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.svelte +++ b/infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.svelte @@ -69,18 +69,17 @@ // If there is a value in the current pin, just clear it and stay on the same input pins[i] = '' return - } else { - // If the current input is already empty, move to the previous input - newIndex = (currentIndex - 1 + items.length) % items.length } + // If the current input is already empty, move to the previous input + newIndex = (currentIndex - 1 + items.length) % items.length + } + + // When a number is typed, replace the current digit with the typed number + if (regx.test(e.key)) { + pins[i] = e.key + newIndex = (currentIndex + 1) % items.length } else { - // When a number is typed, replace the current digit with the typed number - if (regx.test(e.key)) { - pins[i] = e.key - newIndex = (currentIndex + 1) % items.length - } else { - return - } + return } // Set focus to the new input if it’s needed @@ -91,16 +90,17 @@ return new Array(size) } - const createValueSlot = (arr: any[]) => { - return arr.reduce((obj, item) => { - return { - ...obj, - [item]: '', - } - }, {}) + const createValueSlot = (arr: number[]) => { + return arr.reduce( + (obj, item) => { + obj[item] = '' + return obj + }, + {} as Record + ) } - let uniqueId = 'input' + Math.random().toString().split('.')[1] + let uniqueId = `input${Math.random().toString().split('.')[1]}` const cBase = 'relative w-full margin-x-[auto] flex justify-start items-center gap-[10px] flex-row flex-nowrap select-none' diff --git a/infrastructure/eid-wallet/src/lib/ui/Selector/Selector.svelte b/infrastructure/eid-wallet/src/lib/ui/Selector/Selector.svelte index 794ed300..c3f93c4d 100644 --- a/infrastructure/eid-wallet/src/lib/ui/Selector/Selector.svelte +++ b/infrastructure/eid-wallet/src/lib/ui/Selector/Selector.svelte @@ -1,28 +1,29 @@