{"id":26800423,"url":"https://github.com/clearwater-rb/clearwater-virtual_list","last_synced_at":"2025-03-29T20:17:15.409Z","repository":{"id":62555736,"uuid":"122791949","full_name":"clearwater-rb/clearwater-virtual_list","owner":"clearwater-rb","description":"Virtual list renderer for the Clearwater framework","archived":false,"fork":false,"pushed_at":"2018-04-02T03:43:11.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T03:04:09.232Z","etag":null,"topics":["clearwater","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clearwater-rb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-25T00:19:32.000Z","updated_at":"2018-04-02T03:43:10.000Z","dependencies_parsed_at":"2022-11-03T05:31:09.800Z","dependency_job_id":null,"html_url":"https://github.com/clearwater-rb/clearwater-virtual_list","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater-virtual_list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater-virtual_list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater-virtual_list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater-virtual_list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clearwater-rb","download_url":"https://codeload.github.com/clearwater-rb/clearwater-virtual_list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237437,"owners_count":20745348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clearwater","ruby"],"created_at":"2025-03-29T20:17:14.903Z","updated_at":"2025-03-29T20:17:15.396Z","avatar_url":"https://github.com/clearwater-rb.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clearwater::VirtualList\n\nRender a virtual list of Clearwater components where list items outside of the visible area of the page are not rendered. They are inserted just in time while scrolling and removed when they are no longer visible.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'clearwater-virtual_list'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install clearwater-virtual_list\n\n## Usage\n\nInside your Clearwater app:\n\n```ruby\nrequire 'clearwater/component'\nrequire 'clearwater/virtual_list'\n\nclass MyList\n  include Clearwater::Component\n  \n  def initialize(items: [], list_style:, item_style:)\n    # VirtualList will give you the items to render within the viewport\n    @items = items\n    \n    # Make sure you set your list container's style property to this value\n    @list_style = list_style\n    \n    # Make sure the list items' styles are set with this\n    @item_style = item_style\n  end\n  \n  def render\n    ul({ style: @list_style }, @items.map { |item|\n      li({ style: @item_style }, [\n        # ...\n      ])\n    })\n  end\nend\n\n# Define the virtual list component in terms of your regular list component\nMyVirtualList = Clearwater::VirtualList.create do |items:, list_style:, item_style:|\n  MyList.new(\n    items: items,\n    list_style: list_style,\n    item_style: item_style,\n  )\nend\n```\n\nUse the `items` and `item_height` keyword arguments to the component when using it:\n\n```ruby\nclass Layout\n  include Clearwater::Component\n\n  def render\n    div([\n      h1('My list of things'),\n      MyVirtualList.new(\n        items: all_the_things, # The full list of items\n        item_height: 100,      # The height of each item in pixels\n      ),\n    ])\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/clearwater-rb/clearwater-virtual_list. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Clearwater::VirtualList project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/clearwater-rb/clearwater-virtual_list/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearwater-rb%2Fclearwater-virtual_list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclearwater-rb%2Fclearwater-virtual_list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearwater-rb%2Fclearwater-virtual_list/lists"}