From e818d718c9dbf09781f29383e944a6936bb088a4 Mon Sep 17 00:00:00 2001 From: Piyush Tilokani <2021.piyush.tilokani@ves.ac.in> Date: Mon, 14 Oct 2024 01:14:18 +0530 Subject: [PATCH 1/3] convert VirtualizedList stories helpers file to TS --- ...js => VirtualizedList.stories.helpers.tsx} | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) rename packages/core/src/components/VirtualizedList/__stories__/{VirtualizedList.stories.helpers.js => VirtualizedList.stories.helpers.tsx} (59%) diff --git a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.js b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx similarity index 59% rename from packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.js rename to packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx index 4aa265d882..c2e8367b7d 100644 --- a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.js +++ b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx @@ -2,8 +2,19 @@ import React from "react"; import { Tip } from "vibe-storybook-components"; -export const generateItems = (defaultItemSize = 30, itemsCount, layout) => { - const items = []; +interface Item { + value: string; + size: number; + id: number; + height: number; +} + +export const generateItems = ( + defaultItemSize: number = 30, + itemsCount: number, + layout: string +): Item[] => { + const items: Item[] = []; const isVertical = layout !== "horizontal"; for (let i = 0; i < itemsCount; i++) { const size = (i > 0 && i % 15) === 0 ? defaultItemSize * 2 : defaultItemSize; @@ -12,9 +23,9 @@ export const generateItems = (defaultItemSize = 30, itemsCount, layout) => { return items; }; -export const TipItemRenderer = () => ( +export const TipItemRenderer: React.FC = () => ( - Please make sure you inject the style parameter of the itemRenderer function to the item {"element's"} - wrapper style. + Please make sure you inject the style parameter of the itemRenderer function to the item{" "} + {"element's"} wrapper style. ); From 7b3090dbd5a091ff3ce7a9620a303ac95487dcad Mon Sep 17 00:00:00 2001 From: Piyush Tilokani <2021.piyush.tilokani@ves.ac.in> Date: Sat, 19 Oct 2024 01:18:45 +0530 Subject: [PATCH 2/3] use existing type VirtualizedListItem instead of creating a new type --- .../VirtualizedList.stories.helpers.tsx | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx index c2e8367b7d..1ecdd3991d 100644 --- a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx +++ b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx @@ -2,30 +2,21 @@ import React from "react"; import { Tip } from "vibe-storybook-components"; -interface Item { - value: string; - size: number; - id: number; - height: number; -} - -export const generateItems = ( - defaultItemSize: number = 30, - itemsCount: number, - layout: string -): Item[] => { - const items: Item[] = []; +export const generateItems = (defaultItemSize: number = 30, itemsCount: number, layout: string) => { + const items: { value: string; size: number; id: number; height: number }[] = []; const isVertical = layout !== "horizontal"; + for (let i = 0; i < itemsCount; i++) { const size = (i > 0 && i % 15) === 0 ? defaultItemSize * 2 : defaultItemSize; items.push({ value: `Item ${i}`, size, id: i, height: isVertical ? size : 30 }); } + return items; }; export const TipItemRenderer: React.FC = () => ( - Please make sure you inject the style parameter of the itemRenderer function to the item{" "} - {"element's"} wrapper style. + Please make sure you inject the style parameter of the itemRenderer function to the item {"element's"} + wrapper style. ); From 0391fb9eecd4a7eb65cb8d0585c9e400a01808ef Mon Sep 17 00:00:00 2001 From: Piyush Tilokani <112542519+Piyush-Tilokani@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:01:19 +0530 Subject: [PATCH 3/3] Update VirtualizedList.stories.helpers.tsx --- .../__stories__/VirtualizedList.stories.helpers.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx index 1ecdd3991d..47d5acd5c8 100644 --- a/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx +++ b/packages/core/src/components/VirtualizedList/__stories__/VirtualizedList.stories.helpers.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Tip } from "vibe-storybook-components"; -export const generateItems = (defaultItemSize: number = 30, itemsCount: number, layout: string) => { +export const generateItems = (defaultItemSize = 30, itemsCount: number, layout: string) => { const items: { value: string; size: number; id: number; height: number }[] = []; const isVertical = layout !== "horizontal";