{"id":13630654,"url":"https://github.com/rafaelrinaldi/data-components","last_synced_at":"2025-03-25T14:33:06.436Z","repository":{"id":138512080,"uuid":"51414472","full_name":"rafaelrinaldi/data-components","owner":"rafaelrinaldi","description":":recycle: Tiny component structure for web applications","archived":false,"fork":false,"pushed_at":"2020-05-25T21:37:38.000Z","size":109,"stargazers_count":101,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-17T17:19:31.984Z","etag":null,"topics":["components","custom-elements","html-attributes"],"latest_commit_sha":null,"homepage":"https://git.io/v2SZ4","language":"JavaScript","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/rafaelrinaldi.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}},"created_at":"2016-02-10T01:37:01.000Z","updated_at":"2023-07-03T09:41:47.000Z","dependencies_parsed_at":"2023-03-16T19:15:23.697Z","dependency_job_id":null,"html_url":"https://github.com/rafaelrinaldi/data-components","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelrinaldi%2Fdata-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelrinaldi%2Fdata-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelrinaldi%2Fdata-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelrinaldi%2Fdata-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaelrinaldi","download_url":"https://codeload.github.com/rafaelrinaldi/data-components/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245480698,"owners_count":20622355,"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":["components","custom-elements","html-attributes"],"created_at":"2024-08-01T22:01:52.581Z","updated_at":"2025-03-25T14:33:06.084Z","avatar_url":"https://github.com/rafaelrinaldi.png","language":"JavaScript","funding_links":["https://github.com/sponsors/rafaelrinaldi"],"categories":["JavaScript"],"sub_categories":[],"readme":"[demo-url]: https://rafaelrinaldi.github.io/data-components\n[dist-url]: https://raw.githubusercontent.com/rafaelrinaldi/data-components/master/dist/index.min.js\n[index]: https://github.com/rafaelrinaldi/data-components/blob/master/index.js\n[manifest]: https://github.com/rafaelrinaldi/data-components/blob/master/package.json\n[spa]: https://en.wikipedia.org/wiki/Single-page_application\n[url]: http://rinaldi.io\n\n# data-components\n\n\u003e Tiny component structure for web applications\n\n## Sponsors\n\nThank you to all the sponsors for this project:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003ca href=\"https://github.com/lucasmotta\"\u003e\n        \u003cimg src=\"https://avatars.githubusercontent.com/u/76673?v=3\" width=\"100px;\" alt=\"\"/\u003e\n        \u003cbr /\u003e\n        \u003csub\u003eLucas Motta\u003c/sub\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n[→ Sponsor my open source work](https://github.com/sponsors/rafaelrinaldi)\n\n## Install\n\n```sh\n$ npm install data-components --save\n```\n\n\u003csup\u003eOr you can simply copy and paste the [minified standalone version that lives under `dist/`][dist-url]\u003c/sup\u003e\n\n## Features\n\n* No need for a module bundler, it works in all browsers\n* [Zero dependencies][manifest]\n* No magic under the hood, [see it for yourself][index]\n* Small (1.2 KB minified)\n\n## Motivation\n\nThere are plenty of options to architect a web application out there but most of them often assume that you're working on a [SPA][spa]. That alone will add a lot of stuff that you might not want at all. Data binding, custom messaging system and virtual DOM to name a few.\n\nSometimes you just need something simple to kick things off without having to worry about naming conventions and programming paradigms. That's how this library was born.\n\n## Usage\n\nLet's implement the simplest todo list app.\n\n```html\n\u003c!-- Create our todo list element passing some initial values --\u003e\n\u003cul data-component=\"todo\" data-values=\"foo,bar\"\u003e\u003c/ul\u003e\n\n\u003c!-- Let's use a input field to read the user input --\u003e\n\u003cinput data-component=\"input\" placeholder=\"What to do?\"\u003e\n```\n\nOk, now that we have our markup in place, let's implement the application.\n\n```js\n// Todo component\nclass Todo {\n  constructor(el, options) {\n    this.el = el;\n    // Read from initial values\n    this.todos = options.values.split(',');\n    this.render();\n  }\n\n  // Add items to the list\n  add(todo) {\n    this.todos.push(todo);\n    this.render();\n  }\n\n  // Render the list to the DOM\n  render() {\n    this.el.innerHTML = this.todos.map(todo =\u003e `\u003cli\u003e${todo}\u003c/li\u003e`).join('');\n  }\n}\n\n// User input component\nclass Input {\n  constructor(el, options, sandbox) {\n    const todo = sandbox.get('todo');\n\n    // Submit value to \"todo\" component when hitting the enter key\n    el.addEventListener('keydown', e =\u003e {\n      if (e.keyCode === 13) {\n        todo.add(el.value);\n        el.value = '';\n        el.focus();\n      }\n    });\n  }\n}\n\n// Bootstrap components (UMD build exposes `components()`)\ncomponents({\n  todo: Todo,\n  input: Input\n});\n```\n\n![demo](./demo.gif)\n\nIt works with just a few lines of code :tada:\n\n[Check out the demo page][demo-url] for a slightly more complex example.\n\n## More\n\nFor more detailed instructions on how the project works and how to use it, please [check the user guide](/GUIDE.md).\n\n## License\n\nMIT © [Rafael Rinaldi][url]\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://buymeacoff.ee/rinaldi\" title=\"Buy me a coffee\"\u003eBuy me a ☕\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelrinaldi%2Fdata-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaelrinaldi%2Fdata-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelrinaldi%2Fdata-components/lists"}