{"id":20060680,"url":"https://github.com/ficusjs/ficusjs-component-extensions","last_synced_at":"2026-05-11T08:10:39.629Z","repository":{"id":103429103,"uuid":"429864143","full_name":"ficusjs/ficusjs-component-extensions","owner":"ficusjs","description":"Custom element and component extensions","archived":false,"fork":false,"pushed_at":"2023-10-30T16:20:14.000Z","size":2064,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-12T22:14:45.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ficusjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"ficusjs"}},"created_at":"2021-11-19T16:27:12.000Z","updated_at":"2021-12-01T20:10:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ffa888f8-2454-4af6-aaa7-7ce5ea5b7d01","html_url":"https://github.com/ficusjs/ficusjs-component-extensions","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.15384615384615385","last_synced_commit":"05c0c229fa28d114e7c7ea1ffce4a44081376269"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-component-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-component-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-component-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ficusjs%2Fficusjs-component-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ficusjs","download_url":"https://codeload.github.com/ficusjs/ficusjs-component-extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241488201,"owners_count":19970829,"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-13T13:16:20.393Z","updated_at":"2026-05-11T08:10:34.570Z","avatar_url":"https://github.com/ficusjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ficusjs"],"categories":[],"sub_categories":[],"readme":"# FicusJS component extensions\n\nFunctions for extending components.\n\nFor documentation visit [https://docs.ficusjs.org/extending-components/](https://docs.ficusjs.org/extending-components/)\n\n## Getting started\n\nThe `withBreakpointRender` function extends a component to render different content based on the current breakpoint.\n\n```js\n// import it with all other features\nimport { createCustomElement, withBreakpointRender } from 'https://cdn.skypack.dev/ficusjs@6'\n\n// import the renderer and html tagged template literal from the uhtml renderer\nimport { html, renderer } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/uhtml'\n\n// define a breakpoint configuration\nconst breakpointConfig = {\n  reactive: false,\n  breakpoints: {\n    992: { method: 'renderTablet' },\n    768: { method: 'renderMobile' },\n    1200: { method: 'renderDesktop' }\n  }\n}\n\n// create the component\ncreateCustomElement(\n  'breakpoint-component',\n  withBreakpointRender(breakpointConfig, {\n    renderer,\n    renderTablet () {\n      return html`\u003cspan\u003eBreakpoint render tablet\u003c/span\u003e`\n    },\n    renderMobile () {\n      return html`\u003cspan\u003eBreakpoint render mobile\u003c/span\u003e`\n    },\n    renderDesktop () {\n      return html`\u003cspan\u003eBreakpoint render desktop\u003c/span\u003e`\n    }\n  })\n)\n```\n\nThe `withLazyRender` function extends a component to render content lazily.\n\n```js\n// import it with all other features\nimport { createCustomElement, withLazyRender } from 'https://cdn.skypack.dev/ficusjs@6'\n\n// import the renderer and html tagged template literal from the uhtml renderer\nimport { html, renderer } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/uhtml'\n\n// as there is no initial content rendered, the `mounted` method\n// is triggered when the component is visible\ncreateCustomElement(\n  'lazy-component',\n  withLazyRender({\n    renderer,\n    render () {\n      return this.elementVisible\n        ? html`\u003cbutton type=\"button\"\u003eA styled button\u003c/button\u003e`\n        : ''\n    },\n    mounted () {\n      // when elementVisible changes this will be called so we can load extra stuff we need\n    }\n  })\n)\n\n// as there is initial rendered content, the `updated` method\n// is triggered when the component is visible\ncreateCustomElement(\n  'lazy-component-with-placeholder',\n  withLazyRender({\n    renderer,\n    render () {\n      return this.elementVisible\n        ? html`\u003cbutton type=\"button\"\u003eA styled button\u003c/button\u003e`\n        : '\u003cspan class=\"placeholder\"\u003e\u003c/span\u003e'\n    },\n    updated () {\n      // when elementVisible changes this will be called so we can load extra stuff we need\n    }\n  })\n)\n```\n\nThe `withStyles` function extends a component to add scoped styles.\n\n```js\n// import it with all other features\nimport { createCustomElement, withStyles } from 'https://cdn.skypack.dev/ficusjs@6'\n\n// import the renderer and html tagged template literal from the uhtml renderer\nimport { html, renderer } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/uhtml'\n\n// import the css tagged template literal\nimport { css } from 'https://cdn.skypack.dev/@ficusjs/renderers@5/css'\n\ncreateCustomElement(\n  'my-component',\n  withStyles({\n    renderer,\n    styles () {\n      return css`\n        my-component button {\n          background-color: yellow;\n          color: black;\n        }\n      `\n    },\n    render () {\n      return html`\u003cbutton type=\"button\"\u003eA styled button\u003c/button\u003e`\n    }\n  })\n)\n```\n\n## Installation\n\nFicusJS component extensions is part of [FicusJS](https://docs.ficusjs.org) but can also be installed independently in a number of ways.\n\n### CDN\n\nWe recommend using native ES modules in the browser.\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { withBreakpointRender, withLazyRender, withStyles } from 'https://cdn.skypack.dev/@ficusjs/component-extensions'\n\u003c/script\u003e\n```\n\nFicusJS component extensions is available on [Skypack](https://www.skypack.dev/view/@ficusjs/component-extensions).\n\n### NPM\n\nFicusJS component extensions works nicely with build tools such as Snowpack, Webpack or Rollup. If you are using a NodeJS tool, you can install the NPM package.\n\n```bash\nnpm install @ficusjs/component-extensions\n```\n\n### Available builds\n\nFicusJS component extensions only provides ES module builds. For legacy browsers or alternative modules such as CommonJS, it is recommended to use a build tool to transpile the code.\n\n## Development\n\nHow to set-up FicusJS component extensions for local development.\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/ficusjs/ficusjs-component-extensions.git\n```\n\n2. Change the working directory\n\n```bash\ncd ficusjs-component extensions\n```\n\n3. Install dependencies\n\n```bash\nnpm install\n```\n\n4. Run the local development server\n\n```bash\nnpm run dev\n```\n\nThat's it! Now open http://localhost:8080 to see a local app.\n\n## License\n\nThis project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details.\n\n## Contributing to FicusJS component extensions\n\nAny kind of positive contribution is welcome! Please help us to grow by contributing to the project.\n\nIf you wish to contribute, you can work on any features you think would enhance the library. After adding your code, please send us a Pull Request.\n\n\u003e Please read [CONTRIBUTING](CONTRIBUTING.md) for details on our [CODE OF CONDUCT](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.\n\n## Support\n\nWe all need support and motivation. FicusJS is not an exception. Please give this project a ⭐️ to encourage and show that you liked it. Don't forget to leave a star ⭐️ before you move away.\n\nIf you found the library helpful, please consider [sponsoring us](https://github.com/sponsors/ficusjs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-component-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fficusjs%2Fficusjs-component-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fficusjs%2Fficusjs-component-extensions/lists"}