{"id":28938170,"url":"https://github.com/alexwebgr/turbolight","last_synced_at":"2026-04-21T16:35:54.342Z","repository":{"id":299453716,"uuid":"1002909762","full_name":"alexwebgr/turbolight","owner":"alexwebgr","description":"A lightweight, vanilla JavaScript lightbox that works with Turbo Streams","archived":false,"fork":false,"pushed_at":"2025-06-17T16:23:53.000Z","size":6582,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-02T11:43:30.532Z","etag":null,"topics":["hotwire","hotwire-turbo","lightbox","rails"],"latest_commit_sha":null,"homepage":"https://alexwebgr.github.io/turbolight/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexwebgr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-16T10:30:48.000Z","updated_at":"2025-06-18T08:25:14.000Z","dependencies_parsed_at":"2025-06-16T17:32:54.961Z","dependency_job_id":null,"html_url":"https://github.com/alexwebgr/turbolight","commit_stats":null,"previous_names":["alexwebgr/turbolight"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/alexwebgr/turbolight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fturbolight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fturbolight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fturbolight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fturbolight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexwebgr","download_url":"https://codeload.github.com/alexwebgr/turbolight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexwebgr%2Fturbolight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32100468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hotwire","hotwire-turbo","lightbox","rails"],"created_at":"2025-06-22T22:07:06.528Z","updated_at":"2026-04-21T16:35:54.334Z","avatar_url":"https://github.com/alexwebgr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TurboLight\n\nFrustrated by the lack of support from existing lightbox plugins and disappointed I cannot use the original lightbox from [lokesh](https://github.com/lokesh/lightbox2) \nI created a new and shiny plugin with all the features and none of the dependencies!\nIt is lightweight, vanilla Javascript that works seamlessly with Turbo Streams and Rails but also as a standalone.\n\n## Features\n\n- 🪶 Lightweight with zero dependencies\n- 🚀 Turbo compatibility\n- 📱 Responsive design\n- ⌨️ Keyboard navigation\n- 📝 Caption support\n- 🔢 Counter display\n\n## Demo\nCheck out the live [demo](https://alexwebgr.github.io/turbolight/).\n\nThe npm package is available on the [registry](https://www.npmjs.com/package/turbolight)\n\n## Installation\n\n### For Rails Applications\n\n#### 1. Install\n\n```bash\nyarn add turbolight\n# or\nnpm install turbolight\n```\n\n#### 2. Import the module\n##### with importmap-rails\n\nIn your `config/importmap.rb`:\n\n```ruby\npin \"turbolight\", to: \"turbolight/dist/index.esm.js\"\n```\n\n##### with jsbundling\nIn your JavaScript file:\n\n```javascript\nimport TurboLight from \"turbolight\";\n\n// Or CommonJS require\nconst TurboLight = require('turbolight');\n```\n\n#### 3. Add CSS\n\nIn your `app/assets/stylesheets/application.scss`:\n\n```scss\n@import \"turbolight/dist/turbolight\";\n```\n\nOr in your `app/assets/stylesheets/application.css`:\n\n```css\n/*\n *= require turbolight/dist/turbolight\n */\n```\n\n#### 4. Add your HTML markup\n\n```html\n\u003c!-- Single image --\u003e\n\u003c%= link_to \"path/to/image.jpg\", data: { turbolight: \"gallery1\", title: \"The caption\" } do %\u003e\n    \u003c%= faw_icon 'regular', 'expand-arrows-alt' %\u003e\n\u003c% end %\u003e\n\n\u003c!-- Multiple images in a gallery --\u003e\n\u003c%= link_to \"path/to/image.jpg\", data: { turbolight: \"gallery2\", title: \"The caption\" } do %\u003e\n    \u003c%= faw_icon 'regular', 'expand-arrows-alt' %\u003e\n\u003c% end %\u003e\n\u003c%= link_to \"path/to/image.jpg\", data: { turbolight: \"gallery2\", title: \"The caption\" } do %\u003e\n    \u003c%= faw_icon 'regular', 'expand-arrows-alt' %\u003e\n\u003c% end %\u003e\n```\n\nWhat is [faw_icon](https://github.com/alexwebgr/faw_icon) you ask? It is a gem I have built around fontawesome icons.\n\n#### 5. Initialize TurboLight\n\n```javascript\n// Initialize with default options\nnew TurboLight();\n\n// Or with custom options\nnew TurboLight({\n  imageClass: 'custom-image-class',\n  captionClass: 'custom-caption-class',\n  // ... more options\n});\n```\n##### Using with Stimulus\n\nCreate a Stimulus controller for TurboLight. If you are going to be using the controller then you don't really to import in application.js as well. \n\n```javascript\n// app/javascript/controllers/turbo_light_controller.js\nimport { Controller } from \"@hotwired/stimulus\"\nimport TurboLight from \"turbolight\";\n\nlet turboLightInstance = null;\n\n// Connects to data-controller=\"turbo-light\"\nexport default class extends Controller {\n    connect() {\n        if (turboLightInstance) {\n            this.refreshLinks();\n        } else {\n            turboLightInstance = new TurboLight();\n        }\n    }\n\n    disconnect() {\n        if (turboLightInstance \u0026\u0026 turboLightInstance.isOpen) {\n            turboLightInstance.close();\n        }\n    }\n\n    refreshLinks() {\n        if (turboLightInstance) {\n            turboLightInstance.findLinks();\n        }\n    }\n}\n```\n\nThen register it in your controllers index:\n\n```javascript\n// app/javascript/controllers/index.js\nimport { application } from \"./application\"\nimport TurboLightController from \"./turbo_light_controller\"\napplication.register(\"turbo-light\", TurboLightController)\n```\n\n#### 6. Enjoy\nEnjoy the blazing fast performance.\n\n### Using as a standalone\n\n#### 1. Install \n```bash\nyarn add turbolight\n# or\nnpm install turbolight\n```\n\n#### 2. Import\nAdd the CSS to your page for styling the lightbox\n\n```html\n\u003clink rel=\"stylesheet\" href=\"node_modules/turbolight/dist/turbolight.css\"\u003e\n```\n\nOr import it in your CSS/SCSS file\n\n```css\n@import 'turbolight/dist/turbolight.css';\n```\nFor javascript there are a couple ways to do it \n\n```html\n  \u003cscript type=\"module\"\u003e\n    import TurboLight from './node_modules/turbolight/dist/index.esm.js';\n    const lightbox = new TurboLight();\n  \u003c/script\u003e\n```\nOr\n```html\n    \u003cscript src=\"node_modules/turbolight/dist/index.umd.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\n    document.addEventListener('DOMContentLoaded', function() {\n        new TurboLight.default();\n    });\n```\n\n## API Documentation\n\n### Constructor Options\n\n```javascript\nconst lightbox = new TurboLight({\n  // CSS class names for customization\n  overlayClass: 'turbo-light-overlay',\n  containerClass: 'turbo-light-container',\n  imageClass: 'turbo-light-image',\n  captionClass: 'turbo-light-caption',\n  counterClass: 'turbo-light-counter',\n  closeClass: 'turbo-light-close',\n  prevClass: 'turbo-light-prev',\n  nextClass: 'turbo-light-next',\n  activeClass: 'turbo-light-active',\n  loadingClass: 'turbo-light-loading'\n});\n```\n\n### Methods\n\n#### `init()`\n\nInitializes the lightbox by finding all links with `data-turbolight` attribute and setting up event listeners.\n\n```javascript\nlightbox.init();\n```\n\n#### `open(galleryName, index = 0)`\n\nOpens the lightbox for a specific gallery at the specified index.\n\n```javascript\n// Open the first image in \"gallery1\"\nlightbox.open('gallery1', 0);\n```\n\n#### `close()`\n\nCloses the currently open lightbox.\n\n```javascript\nlightbox.close();\n```\n\n#### `next()`\n\nShows the next image in the current gallery.\n\n```javascript\nlightbox.next();\n```\n\n#### `previous()`\n\nShows the previous image in the current gallery.\n\n```javascript\nlightbox.previous();\n```\n\n#### `showImage(index)`\n\nShows a specific image by index in the current gallery.\n\n```javascript\n// Show the third image (index 2) in the current gallery\nlightbox.showImage(2);\n```\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexwebgr%2Fturbolight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexwebgr%2Fturbolight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexwebgr%2Fturbolight/lists"}