{"id":18358826,"url":"https://github.com/uppercod/preact-tag","last_synced_at":"2025-04-06T13:31:38.653Z","repository":{"id":57329559,"uuid":"145934537","full_name":"UpperCod/preact-tag","owner":"UpperCod","description":"This small library(\u003c520 bytes umd/gzip) allows to encapsulate the use of components based on Preact and CustomElements.","archived":false,"fork":false,"pushed_at":"2018-08-26T16:32:15.000Z","size":23,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-22T00:44:20.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jsfiddle.net/uppercod/zusc3jbL/9/","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/UpperCod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-24T02:53:45.000Z","updated_at":"2020-02-14T17:05:53.000Z","dependencies_parsed_at":"2022-09-14T22:23:01.650Z","dependency_job_id":null,"html_url":"https://github.com/UpperCod/preact-tag","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpreact-tag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpreact-tag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpreact-tag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fpreact-tag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/preact-tag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247488538,"owners_count":20946957,"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":[],"created_at":"2024-11-05T22:19:37.825Z","updated_at":"2025-04-06T13:31:38.313Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# preact-tag\n\nThis small library(\u003c520 bytes umd/gzip) allows to encapsulate the use of components based on **Preact** and **CustomElements**.\n\n### JS\n```js\nimport {h,Component} from \"preact\";\nimport register from \"preact-tag\";\n\nregister(\n   \"preact-tag\",\n   class extends Component{\n       static get props(){\n           return [\"title\"];\n       }\n       render(props){\n           \u003cdiv\u003e\n               \u003ch1\u003ehello {props.title}\u003c/h1\u003e\n           \u003c/div\u003e\n       }\n   }\n);\n```\n\n### HTML\n\n```html\n\u003cpreact-tag title=\"web component\"\u003e\u003c/preact-tag\u003e\n```\n\nBy adding the static method `props` to the component created on the basis of `preact.Component`, you can recover and know the mutations of the properties associated with **CustomElement**.\n\n## prefijo json-{prop}\n\nAny property within the **CustomElement** can be parsed by `JSON.parse`, simply by prefixing the property with the prefix **json-**, then you can use it with `this.props.json\u003cprop\u003e`, by default preact-tag, applies camelCase format, to normalize the name of the property.\n\n```js\nimport {h,Component} from \"preact\";\nimport register from \"preact-tag\";\n\nregister(\n   \"preact-tag\",\n   class extends Component{\n       static get props(){\n           return [\"json-list-users\", \"json-checked\"];\n       }\n       render(props){\n           \u003cdiv\u003e\n               {props.jsonListUsers.map(({name})=\u003e\u003cdiv\u003e\n                   \u003ch1\u003e{name}\u003c/h1\u003e \n               \u003c/div\u003e)}\n               \u003cinput type=\"checkbox\" checked={props.jsonChecked}/\u003e  \n           \u003c/div\u003e\n       }\n   }\n);\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fpreact-tag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fpreact-tag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fpreact-tag/lists"}