Skip to content

Commit

Permalink
convert VirtualizedList stories helpers file to TS (#2531)
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush-Tilokani authored Oct 20, 2024
1 parent bca2c68 commit 0871d5f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
import React from "react";
import { Tip } from "vibe-storybook-components";

export const generateItems = (defaultItemSize = 30, itemsCount, layout) => {
const items = [];
export const generateItems = (defaultItemSize = 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 = () => (
export const TipItemRenderer: React.FC = () => (
<Tip title="Are your list items not rendered correctly?">
Please make sure you inject the style parameter of the <code>itemRenderer</code> function to the item {"element's"}
wrapper style.
Expand Down

0 comments on commit 0871d5f

Please sign in to comment.