Skip to content

Commit

Permalink
fix: virtualization examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgarciadev committed Dec 1, 2024
1 parent c096fe4 commit 2b2b91f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,35 @@ const generateItems = (n) => {
return dataset;
};

const ListboxWrapper = ({children}) => (
<div className="w-full max-w-[260px] border-small px-1 py-2 rounded-small border-default-200 dark:border-default-100">
{children}
</div>
);

export default function App() {
const items = generateItems(1000);

return (
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Listbox
isVirtualized
label={"Select from 10000 items"}
placeholder="Select..."
virtualization={{
maxListboxHeight: 400,
itemHeight: 40,
}}
>
{items.map((item, index) => (
<ListboxItem key={index} value={item.value}>
{item.label}
</ListboxItem>
))}
</Listbox>
<ListboxWrapper>
<Listbox
isVirtualized
className="max-w-xs"
label={"Select from 10000 items"}
placeholder="Select..."
virtualization={{
maxListboxHeight: 400,
itemHeight: 40,
}}
>
{items.map((item, index) => (
<ListboxItem key={index} value={item.value}>
{item.label}
</ListboxItem>
))}
</Listbox>
</ListboxWrapper>
</div>
);
}
39 changes: 24 additions & 15 deletions apps/docs/content/components/listbox/virtualization.raw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,35 @@ const generateItems = (n) => {
return dataset;
};

const ListboxWrapper = ({children}) => (
<div className="w-full max-w-[260px] border-small px-1 py-2 rounded-small border-default-200 dark:border-default-100">
{children}
</div>
);

export default function App() {
const items = generateItems(1000);

return (
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Listbox
isVirtualized
label={"Select from 1000 items"}
placeholder="Select..."
virtualization={{
maxListboxHeight: 400,
itemHeight: 40,
}}
>
{items.map((item, index) => (
<ListboxItem key={index} value={item.value}>
{item.label}
</ListboxItem>
))}
</Listbox>
<ListboxWrapper>
<Listbox
isVirtualized
className="max-w-xs"
label={"Select from 1000 items"}
placeholder="Select..."
virtualization={{
maxListboxHeight: 400,
itemHeight: 40,
}}
>
{items.map((item, index) => (
<ListboxItem key={index} value={item.value}>
{item.label}
</ListboxItem>
))}
</Listbox>
</ListboxWrapper>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function App() {
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Select
isVirtualized
className="max-w-xs"
itemHeight={40}
label={"Select from 1000 items"}
maxListboxHeight={400}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function App() {
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Select
isVirtualized
className="max-w-xs"
label={"Select from 1000 items"}
maxListboxHeight={400}
placeholder="Select..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export default function App() {

return (
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Select isVirtualized label={"Select from 10000 items"} placeholder="Select...">
<Select
isVirtualized
className="max-w-xs"
label={"Select from 10000 items"}
placeholder="Select..."
>
{items.map((item, index) => (
<SelectItem key={index} value={item.value}>
{item.label}
Expand Down
7 changes: 6 additions & 1 deletion apps/docs/content/components/select/virtualization.raw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export default function App() {

return (
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
<Select isVirtualized label={"Select from 1000 items"} placeholder="Select...">
<Select
isVirtualized
className="max-w-xs"
label={"Select from 1000 items"}
placeholder="Select..."
>
{items.map((item, index) => (
<SelectItem key={index} value={item.value}>
{item.label}
Expand Down

0 comments on commit 2b2b91f

Please sign in to comment.