{"id":14990163,"url":"https://github.com/daviddarnes/storage-form","last_synced_at":"2025-04-12T02:05:50.081Z","repository":{"id":213708363,"uuid":"730102853","full_name":"daviddarnes/storage-form","owner":"daviddarnes","description":"A Web Component that allows you to submit data to local storage","archived":false,"fork":false,"pushed_at":"2024-04-15T17:12:15.000Z","size":18,"stargazers_count":31,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T02:05:42.708Z","etag":null,"topics":["component","components","customelement","customelements","webcomponent","webcomponents"],"latest_commit_sha":null,"homepage":"https://daviddarnes.github.io/storage-form/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/daviddarnes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"buy_me_a_coffee":"daviddarnes"}},"created_at":"2023-12-11T08:01:58.000Z","updated_at":"2025-03-03T19:20:41.000Z","dependencies_parsed_at":"2023-12-22T15:45:09.424Z","dependency_job_id":"8f363a4b-fb5d-4081-b923-6c736ad0b3e0","html_url":"https://github.com/daviddarnes/storage-form","commit_stats":null,"previous_names":["daviddarnes/storage-form"],"tags_count":4,"template":false,"template_full_name":"daviddarnes/component-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviddarnes%2Fstorage-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviddarnes%2Fstorage-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviddarnes%2Fstorage-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviddarnes%2Fstorage-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daviddarnes","download_url":"https://codeload.github.com/daviddarnes/storage-form/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505862,"owners_count":21115354,"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":["component","components","customelement","customelements","webcomponent","webcomponents"],"created_at":"2024-09-24T14:19:38.531Z","updated_at":"2025-04-12T02:05:50.050Z","avatar_url":"https://github.com/daviddarnes.png","language":"HTML","readme":"# `storage-form`\n\nA Web Component that allows you to submit data to local storage.\n\n**[Demo](https://daviddarnes.github.io/storage-form/demo.html)** | **[Further reading](https://darn.es/storage-form-web-component/)**\n\n## Examples\n\nGeneral usage example:\n\n```html\n\u003cscript type=\"module\" src=\"storage-form.js\"\u003e\u003c/script\u003e\n\n\u003cstorage-form\u003e\n  \u003cform\u003e\n    \u003clabel\u003e\n      Example\n      \u003cinput type=\"text\" name=\"example\" value=\"value\" /\u003e\n    \u003c/label\u003e\n    \u003cbutton\u003eSubmit\u003c/button\u003e\n  \u003c/form\u003e\n\u003c/storage-form\u003e\n```\n\nExample of submitting with `change` event instead of a submit button. Use case for light/dark mode:\n\n```html\n\u003cscript type=\"module\" src=\"storage-form.js\"\u003e\u003c/script\u003e\n\n\u003cstorage-form\u003e\n  \u003cform\u003e\n    \u003clabel\u003e\n      \u003cinput type=\"radio\" name=\"theme\" value=\"dark\" /\u003e\n      \u003cspan\u003eDark mode\u003c/span\u003e\n    \u003c/label\u003e\n    \u003clabel\u003e\n      \u003cinput type=\"radio\" name=\"theme\" value=\"light\" /\u003e\n      \u003cspan\u003eLight mode\u003c/span\u003e\n    \u003c/label\u003e\n    \u003clabel\u003e\n      \u003cinput type=\"radio\" name=\"theme\" value=\"\" checked /\u003e\n      \u003cspan\u003eDefault mode\u003c/span\u003e\n    \u003c/label\u003e\n    \u003cbr /\u003e\n    \u003clabel\u003e\n      \u003cinput type=\"hidden\" name=\"contrast\" value /\u003e\n      \u003cinput type=\"checkbox\" name=\"contrast\" value=\"true\" /\u003e\n      \u003cspan\u003eHigh contrast\u003c/span\u003e\n    \u003c/label\u003e\n  \u003c/form\u003e\n\u003c/storage-form\u003e\n```\n\nExample of hooking into `storage` event:\n\n```html\n\u003cscript type=\"module\" src=\"storage-form.js\"\u003e\u003c/script\u003e\n\n\u003cstorage-form\u003e\n  \u003cform\u003e\n    \u003clabel\u003e\n      Update the\n      \u003ccode\u003eoutput\u003c/code\u003e\n      by checking the box\n      \u003cinput type=\"hidden\" name=\"output\" value /\u003e\n      \u003cinput type=\"checkbox\" name=\"output\" value=\"updated\" /\u003e\n    \u003c/label\u003e\n  \u003c/form\u003e\n\u003c/storage-form\u003e\n\n\u003coutput\u003e\u003c/output\u003e\n\u003cscript\u003e\n  const updatePage = () =\u003e {\n    document.querySelector(\"output\").innerHTML = JSON.stringify(\n      window.localStorage\n    );\n  };\n  window.addEventListener(\"storage\", updatePage);\n  updatePage();\n\u003c/script\u003e\n```\n\n## Features\n\nThis Web Component allows you to:\n\n- Use regular form elements to manipulate data in local storage\n- Invoke a `storage` event on the page to hook into elsewhere on the page\n- Maintain the forms state, using local storage, when the page is refreshed or reloaded\n- Optionally submit the form on the forms `change` event by omitting the forms submit button/input element\n\n## Installation\n\nYou have a few options (choose one of these):\n\n1. Install via [npm](https://www.npmjs.com/package/@daviddarnes/storage-form): `npm install @daviddarnes/storage-form`\n1. [Download the source manually from GitHub](https://github.com/daviddarnes/storage-form/releases) into your project.\n1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)\n\n### Usage\n\nMake sure you include the `\u003cscript\u003e` in your project (choose one of these):\n\n```html\n\u003c!-- Host yourself --\u003e\n\u003cscript type=\"module\" src=\"storage-form.js\"\u003e\u003c/script\u003e\n```\n\n```html\n\u003c!-- 3rd party CDN, not recommended for production use --\u003e\n\u003cscript\n  type=\"module\"\n  src=\"https://www.unpkg.com/@daviddarnes/storage-form@2.0.1/storage-form.js\"\n\u003e\u003c/script\u003e\n```\n\n```html\n\u003c!-- 3rd party CDN, not recommended for production use --\u003e\n\u003cscript\n  type=\"module\"\n  src=\"https://esm.sh/@daviddarnes/storage-form@2.0.1\"\n\u003e\u003c/script\u003e\n```\n\n## Credit\n\nWith thanks to the following people:\n\n- [Zach Leatherman](https://zachleat.com) for inspiring this [Web Component repo template](https://github.com/daviddarnes/component-template)\n- [Nathan Knowler](https://knowler.dev) for proposing a solution to the `updateForm()` method\n","funding_links":["https://buymeacoffee.com/daviddarnes"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviddarnes%2Fstorage-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaviddarnes%2Fstorage-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviddarnes%2Fstorage-form/lists"}