{"id":23689992,"url":"https://github.com/webcomponenthelpers/brick","last_synced_at":"2026-05-18T02:03:49.141Z","repository":{"id":96636314,"uuid":"156293518","full_name":"WebComponentHelpers/Brick","owner":"WebComponentHelpers","description":"Custom elements generator using tagged literals","archived":false,"fork":false,"pushed_at":"2020-08-22T18:21:12.000Z","size":96,"stargazers_count":0,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-29T07:56:49.827Z","etag":null,"topics":["generator","literals","web-components","webcomponents","webcomponents-framework"],"latest_commit_sha":null,"homepage":"","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/WebComponentHelpers.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,"zenodo":null}},"created_at":"2018-11-05T22:45:39.000Z","updated_at":"2020-10-24T16:42:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"64a3d669-8026-48cd-a0b3-8c7b75a6be74","html_url":"https://github.com/WebComponentHelpers/Brick","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WebComponentHelpers/Brick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebComponentHelpers%2FBrick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebComponentHelpers%2FBrick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebComponentHelpers%2FBrick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebComponentHelpers%2FBrick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebComponentHelpers","download_url":"https://codeload.github.com/WebComponentHelpers/Brick/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebComponentHelpers%2FBrick/sbom","scorecard":{"id":150213,"data":{"date":"2025-08-11","repo":{"name":"github.com/WebComponentHelpers/Brick","commit":"974bd909cce77dc3e4a45c0bb59a47eb51a96216"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T10:26:12.473Z","repository_id":96636314,"created_at":"2025-08-16T10:26:12.473Z","updated_at":"2025-08-16T10:26:12.473Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708043,"owners_count":26031932,"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-06T02:00:05.630Z","response_time":65,"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":["generator","literals","web-components","webcomponents","webcomponents-framework"],"created_at":"2024-12-30T01:57:50.125Z","updated_at":"2025-10-07T01:45:26.521Z","avatar_url":"https://github.com/WebComponentHelpers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Brick\n\nThis is a webcomponent generator, it uses string literals to generate an HTML template and a mixin.\nOne can then add the mixin (and so the generated template) to the HTMLElement class when extending.\n\nIt is inspired by [lit-element](https://github.com/Polymer/lit-element) with one big difference: **it does not include virtual-dom**,\nIt is thus as extremely lightweight. Web-components do not really need the complexity of a v-dom and there are other effective, light soulution to exchange/update  data,\nfor example one could use Events or you can have a look at this repo: [App-State and Data Binding Using Proxy](https://github.com/WebComponentHelpers/ImperaJS).\n\n\n\n# Features \n\n - It is **FAST and light**, less than 3kB minified (and 1kB gzip). \u003c!--, try out the [benchmark test comparison with lit-html]().--\u003e\n - Supports **imports of styles** and in general of ```\u003ctemplate\u003e```. Gives a pattern to import shared styles (like a ```normalize```) from templates, cutting on parsing time.\n - Supports **server-side rendering** out of the box, as opposed to lit-element (where because of interaction between elements is usually needed to incapsulate custom-elements one inside the other).\n - Supports automatic dom element-ID retrival, **no more shadowRoot.GetElementByID(\"...\")**. \n - Supports automatic reflection of atributes to properties, but is not intended to exchange rich data (like objects) see [here](https://developers.google.com/web/fundamentals/web-components/best-practices#do-not-reflect-rich-data-properties-to-attributes) for best practices.\n - Supports **inheritance** from other custom-elements and configuration of shadowRoot\n - Light and elegant syntax :rainbow:\n\n\n# Install\n\n```bash\nnpm i brick-element\n```\n\n\n## Import it in your code\n\nIf you are using a builder like webpack then you can import it like below.\n\n```javascript\nimport {brick, templateme, dfn} from \"brick-element\"  \n\n// brick - is a mixins generator\n// templateme - is a template generator\n// dfn - is a shortcut for customElements.define function\n\n```\n\nOtherwise need to give the full path.\n\n## Define your element\n\n```javascript\nlet brick_mixin = brick`\n\t\u003ch1\u003e Hello World \u003c/h1\u003e\n`;\n\n\ncustomElements.define(\"hello-x\",class extends brick_mixin(HTMLElement){});\n// or same would be:\n// dfn(\"hello-x\",class extends mixin(HTMLElement){});\n\n```\n\nNow this is [tagged literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), \nthis means that you can add expression into it (similarly to lit-elemet) and they will be executed.\n\n**Brick supports:** ```number, string, array of strings and \u003ctemplate\u003e``` as input placeholders like this:\n```javascript\n\nlet world = \"World\";\nlet  arr = [\"Hello\",\"World\"];\n\n\nlet brick_mixin = brick`\n        \u003ch1\u003e Hello ${world} \u003c/h1\u003e\n\t\u003ch1\u003e ${arr} \u003c/h1\u003e\n\t${template_previosly_defined}\n`;\n\nclass helloWorld extends brick_mixin(HTMLElement){}\n```\n\n## Configure ShadowRoot\n\nSupports shadow root configuration options:```mode:'open','closed'``` and ```delegatesFocus:true,false``` as follows:\n```javascript\nlet config = {\n\tshadowRoot: {\n\t\tmode: \"open\",    \t\t// closed\n\t\tdelegatesFocus : false \t\t// true\n\t}\n}\n\nclass exampleComponent extends brick_mixin(HTMLElement, config){}\n\n```\ndefault values are **mode=\"open\"** and **delegatesFocus=false**.\n\n## Inheritance \n\nSupports inheritance from another custom element by passing a configuration object as above, the template and attributes of the child class will be added to the one of the parent:\n```javascript\nlet hello_mixin = brick`\n        \u003ch1\u003e Hello \u003c/h1\u003e\n`;\n\n// definition of parent class\nclass onlyHello extends hello_mixin(HTMLElement){}\n\nlet world_mixin = brick`\n        \u003ch2\u003e World \u003c/h1\u003e\n`;\n\nlet config = {\n\tinherit : true   // default false\n}\n\n// definition of child class\nclass helloWorld extends world_mixin(onlyHello, config) {}\n\n``` \n## Automatic ID assignment to shadowRoot\n\nTo define an intrinsic ID one can use the symbol prefix **#-** in a string before the ID name, like this:\n\n```javascript\nlet mixin = brick`\n\t\u003cbutton ${\"#-btn\"}\u003e \u003c/button\u003e\n`;\n\ndfn(\"button-x\",class extends mixin(HTMLElement){\n\tconstructor(){\n\t    super();\n\t    this.ids.btn.onclick = this.my_onclick_function; \n\t}\n});\n\n```\n\nHere **ids** is an object that has been automatically attached to ```this``` that will contain as key all objects names whose ID is specified as above.\n\n## Automatic reflection of atributes to properties\n\nA list of attribute can be defined to be reflected to object property. You can  add a string containing this list anywhere in the template tag. \nThis list of attribute string must follow a special formatting: **\"|*\"** to start the list, **\"*|\"** when the list is finished and **\"|\"** to separate items,\nlike shown below. This will add a property to the custom-element that has the same name as specified in the item list. Also, when the attribute \nis changed from HTML, or the property is changed from JS, a method is fired (if defined by you) for that specific attribute name, the function name\nis by convention the attribute name prefixed by the word \"update_\" as for example: **update_attributeName**. \nIf this function is not the defined then this call is ignored.\n\n```html\n\nlet mixin = brick`\n\t\u003cstyle\u003e\n\t\t:host[red] \u003e button { /* once the attribute red is added to the element*/\n\t\t\tbackground-color:red;\n\t\t}\n\t\t:host[green] \u003e button { /* once the attribute red is added to the element*/\n\t\t\tbackground-color:green;\n\t\t}\n\t\u003c/style\u003e\n\t\u003cbutton ${\"#-btn\"}\u003e \u003c/button\u003e\n\n\t${\"|* red | green *|\"} \u003c!-- Attributes names definition --\u003e\n`;\n```\n```javascript\ndfn(\"button-x\",class extends mixin(HTMLElement){\n\t\n\tupdate_red(new_value){\n\t\tconsole.log(\"Attribute 'red' has changed\");\n\t}\n}\n```\n\n## Template generation helper\n\n**templateme** is a template generator via tagged literals, it uses the same syntax of **brick**, so it supports automatic ID assignment and \nattribute to property reflection. It creates automatically a template with the defined content and adds it to the document. Once this template \nis included into a brick-element then all the properties and attribute will be forwarded to it. This is usefull to share styles like a normalize for example.\n\n```javascript\n//defining the template\nlet template = templateme`\n\t\u003cbutton ${\"#-btn\"}\u003e \u003c/button\u003e\n`;\n\n//adding the template to a brick element\nlet mixin = brick`\n\t${template}\n`;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcomponenthelpers%2Fbrick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebcomponenthelpers%2Fbrick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcomponenthelpers%2Fbrick/lists"}