{"id":13806401,"url":"https://github.com/chialab/dna","last_synced_at":"2025-04-06T06:06:48.263Z","repository":{"id":8606932,"uuid":"59031079","full_name":"chialab/dna","owner":"chialab","description":"🧬 Progressive Web Components.","archived":false,"fork":false,"pushed_at":"2024-12-12T09:15:36.000Z","size":11663,"stargazers_count":49,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-28T18:08:57.639Z","etag":null,"topics":["custom-elements","shadow-dom","virtual-dom","webcomponents"],"latest_commit_sha":null,"homepage":"http://chialab.github.io/dna/","language":"TypeScript","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/chialab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-17T14:44:05.000Z","updated_at":"2025-03-27T02:52:31.000Z","dependencies_parsed_at":"2023-12-22T13:27:38.368Z","dependency_job_id":"99ec238c-8844-4d1b-a061-ce1322f6b852","html_url":"https://github.com/chialab/dna","commit_stats":{"total_commits":1954,"total_committers":11,"mean_commits":"177.63636363636363","dds":"0.047594677584442135","last_synced_commit":"7ea5ddfbd9a5530faeb6a269a1cdba895b4a8d3b"},"previous_names":[],"tags_count":313,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fdna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fdna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fdna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chialab%2Fdna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chialab","download_url":"https://codeload.github.com/chialab/dna/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441042,"owners_count":20939239,"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":["custom-elements","shadow-dom","virtual-dom","webcomponents"],"created_at":"2024-08-04T01:01:11.300Z","updated_at":"2025-04-06T06:06:48.230Z","avatar_url":"https://github.com/chialab.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Libraries"],"sub_categories":["Class Based"],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://chialab.github.io/dna/\"\u003e\n        \u003cimg alt=\"DNA logo\" width=\"144\" height=\"144\" src=\"https://raw.githack.com/chialab/dna/main/logo.svg\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eDNA\u003c/strong\u003e • Progressive Web Components\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@chialab/dna\"\u003e\u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/v/@chialab/dna.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\nDNA aims to unleash the true power of [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements) through a declarative definition API, with builtin elements extension support and a simpler composition mechanism (yes, it does not use ShadowDOM).\n\n### Customized built-in elements\n\nDNA simplifies and encourages the use of customized built-in elements, which inherit methods and properties from standard HTML, preserving usability and accessibility features.\n\n### Properties, states and attributes\n\nDNA offers `@property` and `@state` decorators for adding reactivity to a component's class fields, ensuring that any changes are reflected in the component's template. These properties and states can be monitored, synchronized with attributes, and trigger change events.\n\n### Listeners and async events\n\nDNA uses event delegation for listening to events from a component's elements or slotted contents, offering the `@listen` decorator to streamline the process. Events can be asynchronous and dispatched from the component's class.\n\n### Slots\n\nDNA uses [**Quantum**](https://chialab.github.io/quantum/) instead of ShadowDOM to render slotted children, simplifying the usage of custom elements inside forms and providing a more flexible management of slotted contents. Unlike ShadowDOM, Quantum also works for built-in elements, allowing you to use \u003cslot\u003e even inside buttons.\n\n## Get the library\n\nInstall via NPM:\n\n```\nnpm i @chialab/dna\n```\n\n```\nyarn add @chialab/dna\n```\n\n## Define a Component\n\n```tsx\nimport { Component, customElement, listen, property } from '@chialab/dna';\n\n@customElement('hello-world')\nclass HelloWorld extends Component {\n    // define an observed property\n    @property() name: string = '';\n\n    render() {\n        return (\n            \u003c\u003e\n                \u003cinput\n                    name=\"firstName\"\n                    value={this.name}\n                /\u003e\n                \u003ch1\u003eHello {this.name || 'World'}!\u003c/h1\u003e\n            \u003c/\u003e\n        );\n    }\n\n    // delegate an event\n    @listen('change', 'input[name=\"firstName\"]')\n    private onChange(event: Event, target: HTMLInputElement) {\n        this.name = target.value;\n    }\n}\n```\n\nThen use the element in your HTML:\n\n```html\n\u003chello-world\u003e\u003c/hello-world\u003e\n```\n\n## Development\n\n[![Build status](https://github.com/chialab/dna/workflows/Main/badge.svg)](https://github.com/chialab/dna/actions?query=workflow%3AMain)\n[![codecov](https://codecov.io/gh/chialab/dna/branch/main/graph/badge.svg)](https://codecov.io/gh/chialab/dna)\n\n### Build the project\n\nInstall the dependencies and run the `build` script:\n\n```\nyarn install\n```\n\n```\nyarn build\n```\n\nThis will generate the bundles in the `dist` folder, as well as the declaration files.\n\n### Test the project\n\nRun the `test` script:\n\n```\nyarn test\n```\n\n---\n\n## License\n\n**DNA** is released under the [MIT](https://github.com/chialab/dna/blob/main/LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchialab%2Fdna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchialab%2Fdna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchialab%2Fdna/lists"}