Skip to content

feat(Core.Components):Add Scrollable component and its gallery. #114

Merged
TeseySTD merged 7 commits intoRazorConsole:mainfrom
TeseySTD:feat/scrollable
Nov 15, 2025
Merged

feat(Core.Components):Add Scrollable component and its gallery. #114
TeseySTD merged 7 commits intoRazorConsole:mainfrom
TeseySTD:feat/scrollable

Conversation

@TeseySTD
Copy link
Member

Overview

As I mentioned in #111 issue, I'd like to add scroll ability to some components like Tables and Lists.

In this pull request I implemented a simple wrapper component, that enables item scrolling for any data collection with any rendering, not bound to any component at all.

What was done

  1. Scrollable component, that adds ability to scroll through items and render limited count.
Parameter Type Default Description
Items IReadOnlyList<TItem> Array.Empty<TItem>() Full data source.
PageSize int 1 Items shown at once.
ChildContent RenderFragment<ScrollContext<TItem>> Markup for the visible page.
ScrollOffset int 0 Two-way – start index of current page.
ScrollOffsetChanged EventCallback<int> Fired when offset changes.

Component provide the children its context, where is the keyboard callback and some info

Member Type Description
this[int i] TItem Visible item at index i.
Count int Visible items count.
GetEnumerator() Enables foreach.
KeyDownEventHandler Func<KeyboardEventArgs,Task> Attach via @onkeydown.
CurrentOffset int Same as ScrollOffset.
PagesCount int Total pages: PageSize >= Items.Count ? 1 : Items.Count - PageSize + 1.
  1. Gallery example to that component, with list and table:
gallery example
  1. Documentation in design docs and the website.
  2. Changed the HtmlListElementTranslator - add in ol element data-offset attribute to render the correct number using offset.
    Here is the example:
<Scrollable Items="@AlphabetData" PageSize="4">
  <ol data-offset="@context.CurrentOffset" @onkeydown="context.KeyDownEventHandler">
      @foreach (var item in context)
      {
          <li>
              <Markup Content=@($"{item.Letter}") Foreground="@item.Color"/>
          </li>
      }
  </ol>
</Scrollable>

P.S. I'm not sure if the api of the component made well - maybe there is the simpler solution, idk. Also, if code quality is bad somewhere - write about it, and I'll try to fix that.

Signed-off-by: Skoreyko Misha <150385054+TeseySTD@users.noreply.github.com>
Updated ordered list to use 'start' attribute for correct numbering.

Signed-off-by: Skoreyko Misha <150385054+TeseySTD@users.noreply.github.com>
…ode.

Signed-off-by: Skoreyko Misha <150385054+TeseySTD@users.noreply.github.com>
@TeseySTD TeseySTD merged commit eb1d27d into RazorConsole:main Nov 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants