Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Virtual components#65

Merged
chiefcll merged 4 commits into
mainfrom
virtualComponents
Aug 1, 2025
Merged

Virtual components#65
chiefcll merged 4 commits into
mainfrom
virtualComponents

Conversation

@chiefcll

@chiefcll chiefcll commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

I've tested VirtualGrid - going to push up the demo changes. Take a look at let me know what you think.

@chiefcll
chiefcll requested a review from thetarnav August 1, 2025 01:55

@thetarnav thetarnav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess since it's from sky then it's working.

Comment thread docs/primitives/virtualgrid.md Outdated
width={1620}
scroll="always"
autofocus
itemsPerRow={7}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this just columns?

Suggested change
itemsPerRow={7}
columns={7}

Comment thread docs/primitives/virtualgrid.md Outdated
import { VirtualGrid } from './components/VirtualGrid';

<VirtualGrid
id="BrowseGrid"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats id for?

Comment on lines +64 to +65
- `display: flex`, `flexWrap: wrap`, `gap: 30`
- `transition: { y: 250ms ease-out }`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `display: flex`, `flexWrap: wrap`, `gap: 30`
- `transition: { y: 250ms ease-out }`
- `display: "flex"`, `flexWrap: "wrap"`, `gap: 30`
- `transition: { y: {duration: 250, easing: 'ease-out'} }`

Comment thread docs/primitives/virtualgrid.md Outdated
- **onEndReached** (`() => void`): Callback triggered when selection moves near the end of the list.
- **children** (`(item: Accessor<T>, index: Accessor<number>) => JSX.Element`): Function that renders each item.
- **selected** (`number`): Initial selected index.
- **scrollToIndex** (`(index: number) => void`): Imperatively scrolls and focuses the item at the given index.

@thetarnav thetarnav Aug 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is scrollToIndex? its not a part of props type, nor the prop is used anywhere.

Comment thread src/utils.ts Outdated
}));
}

export const clamp = (value: number, min = 0, max = 100) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes 0 - 100 a good default?
if you read somewhere clamp(x) do you immediately know that its clamping the value between 0 and 100?
I'd prefer clamp(x, 0, 100) tbh.

Comment on lines +123 to +125
onLeft={/* @once */ lngp.chainFunctions(props.onLeft, rowOnLeft)}
onRight={/* @once */ lngp.chainFunctions(props.onRight, rowOnRight)}
forwardFocus={/* once */ lngp.onGridFocus(chainedOnSelectedChanged)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onLeft={/* @once */ lngp.chainFunctions(props.onLeft, rowOnLeft)}
onRight={/* @once */ lngp.chainFunctions(props.onRight, rowOnRight)}
forwardFocus={/* once */ lngp.onGridFocus(chainedOnSelectedChanged)}
onLeft={/* @once */ lngp.chainFunctions(props.onLeft, lngp.navigableHandleNavigation)}
onRight={/* @once */ lngp.chainFunctions(props.onRight, lngp.navigableHandleNavigation)}
forwardFocus={lngp.navigableForwardFocus}

Comment on lines +15 to +18
x: {
duration: 250,
easing: 'ease-out',
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the user-defined default?

Suggested change
x: {
duration: 250,
easing: 'ease-out',
},
x: true,


const rowStyles: lng.NodeStyles = {
display: 'flex',
gap: 30,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop the default gap width of 30?
Every user will have a different design system and different gaps for different components.
There is no point in trying to guess the default value for everyone.
Default gap of 0 is the most expected, as this is what you get with display: "flex", you change that el to Row and suddenly you have some random gap.

Comment thread src/primitives/VirtualGrid.tsx Outdated
Comment on lines +72 to +101
const onUp: lngp.KeyHandler = function () {
const perRow = itemsPerRow();
const selected = this.selected || 0;
if (selected < perRow) return false;

const newIndex = utils.clamp(selected - perRow, 0, items().length - 1);
const lastIdx = selected;
this.selected = newIndex;
const active = this.children[this.selected];
if (active instanceof lng.ElementNode) {
active.setFocus();
chainedOnSelectedChanged.call(this as lngp.NavigableElement, this.selected, this as lngp.NavigableElement, active, lastIdx);
}
};

const onDown: lngp.KeyHandler = function () {
const perRow = itemsPerRow();
const selected = this.selected || 0;

const newIndex = utils.clamp(selected + perRow, 0, items().length - 1);
if (newIndex !== selected) {
const lastIdx = selected;
this.selected = newIndex;
const active = this.children[this.selected];
if (active instanceof lng.ElementNode) {
active.setFocus();
chainedOnSelectedChanged.call(this as lngp.NavigableElement, this.selected, this as lngp.NavigableElement, active, lastIdx);
}
}
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be merged together.
Or the spatialHandleNavigation could be used.

@chiefcll

chiefcll commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

I think the spatial stuff is only in RC3 - so will change that around when we get to it.

@chiefcll
chiefcll merged commit 3a95d10 into main Aug 1, 2025
1 check failed
@chiefcll
chiefcll deleted the virtualComponents branch August 1, 2025 16:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants