Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add autofix.yml #767

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: [main, alpha, beta]

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
autofix:
name: autofix
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Tools
uses: tanstack/config/.github/setup@main
- name: Fix formatting
run: pnpm prettier:write
- name: Apply fixes
uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a
with:
commit-message: 'ci: apply automated fixes'
80 changes: 41 additions & 39 deletions packages/lit-virtual/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,36 @@ Efficiently virtualize only the visible DOM nodes within massive scrollable elem
`@tanstack/lit-virtual` utilizes [Reactive Controllers](https://lit.dev/docs/composition/controllers/) to create the virtualizer and integrate it with the element lifecycle:

```ts
import { LitElement } from 'lit';
import { VirtualizerController } from '@tanstack/lit-virtual';
import { Ref, createRef } from 'lit/directives/ref.js';
import { LitElement } from 'lit'
import { VirtualizerController } from '@tanstack/lit-virtual'
import { Ref, createRef } from 'lit/directives/ref.js'

class MyVirtualElement extends LitElement {
private virtualizerController: VirtualizerController<HTMLDivElement, Element>;
private scrollElementRef: Ref<HTMLDivElement> = createRef();

constructor() {
super();
this.virtualizerController = new VirtualizerController(this, {
getScrollElement: () => this.scrollElementRef.value,
count: 10000,
estimateSize: () => 35,
overscan: 5,
});
}

render() {
const virtualizer = this.virtualizerController.getVirtualizer();
const virtualItems = virtualizer.getVirtualItems();

return html`
<div class="list scroll-container" ${ref(this.scrollElementRef)}>
${virtualItems.map(item => html`<div class="item">${item.index}</div>`)}
</div>
`;
}
private virtualizerController: VirtualizerController<HTMLDivElement, Element>
private scrollElementRef: Ref<HTMLDivElement> = createRef()

constructor() {
super()
this.virtualizerController = new VirtualizerController(this, {
getScrollElement: () => this.scrollElementRef.value,
count: 10000,
estimateSize: () => 35,
overscan: 5,
})
}

render() {
const virtualizer = this.virtualizerController.getVirtualizer()
const virtualItems = virtualizer.getVirtualItems()

return html`
<div class="list scroll-container" ${ref(this.scrollElementRef)}>
${virtualItems.map(
(item) => html`<div class="item">${item.index}</div>`,
)}
</div>
`
}
}
```

Expand All @@ -45,21 +47,21 @@ Note that a [Ref](https://lit.dev/docs/templates/directives/#ref) is attached to
You can also create a virtualizer controller that attaches to the Window:

```ts
import { WindowVirtualizerController } from '@tanstack/lit-virtual';
import { WindowVirtualizerController } from '@tanstack/lit-virtual'

class MyWindowVirtualElement extends LitElement {
private windowVirtualizerController: WindowVirtualizerController;

constructor() {
super();
this.windowVirtualizerController = new WindowVirtualizerController(this, {
count: this.data.length,
estimateSize: () => 350,
overscan: 5,
});
}

// Implement render and other lifecycle methods as needed
private windowVirtualizerController: WindowVirtualizerController

constructor() {
super()
this.windowVirtualizerController = new WindowVirtualizerController(this, {
count: this.data.length,
estimateSize: () => 350,
overscan: 5,
})
}

// Implement render and other lifecycle methods as needed
}
```

Expand Down
8 changes: 1 addition & 7 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@ export const branchConfigs = {
main: {
prerelease: false,
},
next: {
prerelease: true,
},
beta: {
prerelease: true,
},
alpha: {
prerelease: true,
},
rc: {
beta: {
prerelease: true,
},
}
Expand Down