{"id":15526098,"url":"https://github.com/zachleat/announcement-banner","last_synced_at":"2025-10-09T23:38:32.371Z","repository":{"id":57262821,"uuid":"316385883","full_name":"zachleat/announcement-banner","owner":"zachleat","description":"An announcement banner web component.","archived":false,"fork":false,"pushed_at":"2023-11-17T20:10:02.000Z","size":26,"stargazers_count":51,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-11T01:50:31.050Z","etag":null,"topics":["web-components"],"latest_commit_sha":null,"homepage":"https://zachleat.github.io/announcement-banner/demo.html","language":"HTML","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/zachleat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-11-27T02:58:02.000Z","updated_at":"2025-07-12T08:43:37.000Z","dependencies_parsed_at":"2024-10-02T11:00:54.008Z","dependency_job_id":null,"html_url":"https://github.com/zachleat/announcement-banner","commit_stats":null,"previous_names":["zachleat/announcement-banner","zachleat/herald-of-the-dog"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zachleat/announcement-banner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fannouncement-banner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fannouncement-banner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fannouncement-banner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fannouncement-banner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachleat","download_url":"https://codeload.github.com/zachleat/announcement-banner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachleat%2Fannouncement-banner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002311,"owners_count":26083340,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["web-components"],"created_at":"2024-10-02T11:00:48.062Z","updated_at":"2025-10-09T23:38:32.349Z","avatar_url":"https://github.com/zachleat.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# announcement-banner\n\nA reusable announcement bar banner component. If you don’t need a _Hide_ or _Close_ button on the banner (and to save the user preference), you don’t need this (just use CSS)!\n\n* [Demo](https://zachleat.github.io/announcement-banner/demo.html)\n* Read more at [_Ruthlessly Eliminating Layout Shift on Netlify.com_](https://www.zachleat.com/web/layout-shift/)\n\nFeatures:\n\n* Hyperlink to a thing.\n* Limited visual style (bring your own theme)\n* JavaScript not required.\n* Close preference saved to local storage for future page loads\n* Frameworkless: Web component\n* No CLS (cumulative layout shift):\n  * Even when opted in to closed by default\n  * Even when JavaScript fails\n  * Even when JavaScript succeeds but runs after render\n* Use the `key` attribute (v1.0.5+) (or backwards compatible with `data-banner-key` 1.0.3+) to set your own storage key for comparison (defaults to the first link URL).\n\n## Installation\n\n1. Install from [npm](https://www.npmjs.com/package/@zachleat/announcement-banner): `npm install @zachleat/announcement-banner --save`\n2. Inline helper script into your `\u003chead\u003e`\n\n```js\n// Inline this into your \u003chead\u003e\n\n// The current banner CTA URL\nlet latestBannerUrl = \"YOUR_URL\";\nlet savedKey = localStorage.getItem(\"banner--cta-url\");\n\n// Hide if the banner URL is the same as the saved preference banner URL\nif(savedKey === latestBannerUrl) {\n  document.documentElement.classList.add(\"banner--hide\");\n}\n```\n\n3. Add `banner.css` and `banner.js` to your build CSS and JS.\n4. Add the markup:\n\n```html\n\u003cannouncement-banner\u003e\n  \u003ca href=\"YOUR_URL\"\u003eYOUR_TEXT\u003c/a\u003e\n  \u003cbutton type=\"button\" data-banner-close\u003eClose\u003c/button\u003e\n\u003c/announcement-banner\u003e\n```\n\n## Changelog\n\n* `v1.0.6` npm package name changed from `herald-of-the-dog` to `@zachleat/announcement-banner`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachleat%2Fannouncement-banner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachleat%2Fannouncement-banner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachleat%2Fannouncement-banner/lists"}