{"id":14990395,"url":"https://github.com/hotforfeature/origami","last_synced_at":"2025-04-06T09:08:20.489Z","repository":{"id":19306459,"uuid":"86743483","full_name":"hotforfeature/origami","owner":"hotforfeature","description":"Angular + Polymer","archived":false,"fork":false,"pushed_at":"2023-01-03T19:01:33.000Z","size":2776,"stargazers_count":161,"open_issues_count":24,"forks_count":33,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-04-14T19:52:51.218Z","etag":null,"topics":["angular","angular2","material-design","polymer","polymer2","webcomponents"],"latest_commit_sha":null,"homepage":null,"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/hotforfeature.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-30T20:00:37.000Z","updated_at":"2024-03-22T16:05:46.000Z","dependencies_parsed_at":"2023-01-13T20:17:46.348Z","dependency_job_id":null,"html_url":"https://github.com/hotforfeature/origami","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotforfeature%2Forigami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotforfeature%2Forigami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotforfeature%2Forigami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotforfeature%2Forigami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hotforfeature","download_url":"https://codeload.github.com/hotforfeature/origami/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457801,"owners_count":20941906,"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":["angular","angular2","material-design","polymer","polymer2","webcomponents"],"created_at":"2024-09-24T14:20:03.513Z","updated_at":"2025-04-06T09:08:20.469Z","avatar_url":"https://github.com/hotforfeature.png","language":"TypeScript","readme":"# Origami\n\n_Origami is the art of folding paper with angles to form beautiful creations._\n\nAngular + Polymer\n\n[![NPM Package](https://badge.fury.io/js/%40codebakery%2Forigami.svg)](https://www.npmjs.com/package/@codebakery/origami)\n\n[![Test Status](https://saucelabs.com/browser-matrix/codebakery-origami.svg)](https://saucelabs.com/open_sauce/user/codebakery-origami)\n\n## Summary\n\n[Angular and custom elements are BFFs](https://custom-elements-everywhere.com/). With Polymer, there are a few gaps that Origami fills. The library is divided into several modules that can be imported individually to address these gaps.\n\n- [Angular Form Support](forms/README.md)\n- [ShadyCSS Support](styles/README.md#shadycss)\n- [Style Modules](styles/README.md#style-modules)\n- [Polymer `\u003ctemplate\u003e` Stamping](templates/README.md)\n- [Polyfill Utilities](polyfills/README.md)\n\nTo setup Origami, follow these steps:\n\n1. [Install and import](#install) `OrigamiModule`\n2. Set up [polyfills](#polyfills)\n3. [Prepare dependencies](#prepare-dependencies-es5-only) if targeting ES5\n4. Read the [Usage Summary](#usage-summary)\n\n## Install\n\n\u003e Upgrading from Origami v2? Follow [this guide](UPGRADE.md).\n\n```sh\nnpm install @codebakery/origami\n```\n\nImport each module as described in the links above, or if you need all of the modules you can simply import `OrigamiModule`. Include `CUSTOM_ELEMENTS_SCHEMA` to enable custom elements in Angular templates.\n\n```ts\nimport { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { BrowserModule } from '@angular/platform-browser';\nimport { RouterModule } from '@angular/router';\n// If @angular/router is not used, import modules individually\n// and use IncludeStylesNoRouterModule instead of IncludeStylesModule.\nimport { OrigamiModule } from '@codebakery/origami';\nimport { AppComponent } from './app.component';\n\n@NgModule({\n  imports: [BrowserModule, FormsModule, RouterModule, OrigamiModule],\n  declarations: [AppComponent],\n  schemas: [CUSTOM_ELEMENTS_SCHEMA],\n  bootstrap: [AppComponent]\n})\nexport class AppModule {}\n```\n\n## Polyfills\n\n[Polyfills](polyfills/README.md) are needed to support browsers that do not support all webcomponent features. To quickly set up polyfills, use the Origami CLI.\n\n```sh\nnpm install @webcomponents/webcomponentsjs\n./node_modules/.bin/origami polyfill\n```\n\n### Wait for WebComponentsReady\n\nSome imports (such as Polymer's `TemplateStamp` mixin) have side effects that require certain features to be immediately available. For example, `TemplateStamp` expects `HTMLTemplateElement` to be defined. These imports should be deferred until after `webcomponentsReady()` resolves.\n\n```ts\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\nimport { webcomponentsReady } from '@codebakery/origami/polyfills';\n\nwebcomponentsReady()\n  .then(() =\u003e {\n    // requires \"module\": \"esnext\" in tsconfig.json \"compilerOptions\" and\n    // \"angularCompilerOptions\": {\n    //   \"entryModule\": \"app/app.module#AppModule\"\n    // }\n    return import('./app/app.module');\n  })\n  .then(({ AppModule }) =\u003e {\n    platformBrowserDynamic().bootstrapModule(AppModule);\n  });\n```\n\n## Prepare Dependencies (ES5 only)\n\nAngular will not transpile `node_modules/`, and a common pattern among webcomponents is to be distributed as ES2015 classes. Use Origami's CLI to effeciently transpile dependencies to ES5 or back to ES2015 before building.\n\nExample:\n\n```sh\norigami prepare es5 node_modules/{@polymer/*,@vaadin/*,@webcomponents/shadycss}\n\n# to restore to ES2015\norigami prepare es2015 node_modules/{@polymer/*,@vaadin/*,@webcomponents/shadycss}\n\n# for more info\norigami --help\n```\n\n\u003e Note that `@webcomponents/webcomponentsjs` should _not_ be transpiled. However, `@webcomponents/shadycss` _should_ be if it's used.\n\nThe CLI can also restore the previous ES2015 files for projects that compile to both targets.\n\nIt is recommended to add a script before `ng build` and `ng serve` tasks in `package.json`.\n\n```json\n{\n  \"scripts\": {\n    \"prepare:es5\": \"origami prepare es5 node_modules/{@polymer/*,@vaadin/*,@webcomponents/shadycss}\",\n    \"prepare:es2015\": \"origami prepare es2015 node_modules/{@polymer/*,@vaadin/*,@webcomponents/shadycss}\",\n    \"start\": \"npm run prepare:es5 \u0026\u0026 ng serve es5App\",\n    \"start:es2015\": \"npm run prepare:es2015 \u0026\u0026 ng serve es2015App\",\n    \"build\": \"npm run prepare:es5 \u0026\u0026 ng build es5App --prod\",\n    \"build:es2015\": \"npm run prepare:es2015 \u0026\u0026 ng build es2015App --prod\"\n  }\n}\n```\n\n## Usage Summary\n\n### [Angular Form Support](forms/README.md)\n\nAdd the `origami` attribute to any custom element using `[ngModel]`, `[formControl]` or `[formControlName]`.\n\n\u003e Requires the `@angular/forms` module.\n\n```ts\nimport { Component } from '@angular/core';\nimport '@polymer/paper-input/paper-input';\n\n@Component({\n  selector: 'app-component',\n  template: `\n    \u003cdiv\u003eAngular value: {{value}}\u003c/div\u003e\n    \u003cpaper-input [(ngModel)]=\"value\" origami\u003e\u003c/paper-input\u003e\n  `\n})\nexport class AppComponent {\n  value: string;\n}\n```\n\n### [ShadyCSS Support](styles/README.md#shadycss)\n\nEnables the use of CSS custom properties in Angular styles on browsers that do not support them via [ShadyCSS](https://github.com/webcomponents/shadycss), with some [limitations](styles/README.md#limitations).\n\n```ts\nimport { Component } from '@angular/core';\nimport '@polymer/paper-button/paper-button';\n\n@Component({\n  selector: 'app-component',\n  styles: [\n    `\n      paper-button {\n        --paper-button-ink-color: blue;\n      }\n    `\n  ],\n  template: `\n    \u003cpaper-button\u003eBlue Ink!\u003c/paper-button\u003e\n  `\n})\nexport class AppComponent {}\n```\n\n### [Style Modules](styles/README.md#style-modules)\n\nAllows for [style modules](https://www.polymer-project.org/3.0/docs/devguide/style-shadow-dom#style-modules) defined in Polymer to be injected into Angular components.\n\n\u003e Requires the `@angular/router` module. Use `IncludeStylesNoRouterModule` if `@angular/router` is not used.\n\n```ts\nimport { Component } from '@angular/core';\nimport { IncludeStyles } from '@codebakery/origami/styles';\nimport '@polymer/iron-flex-layout/iron-flex-layout-classes';\n\n@IncludeStyles('iron-flex')\n@Component({\n  selector: 'app-component',\n  styles: [':host { display: block; }'], // See Limitations\n  template: `\n    \u003cdiv class=\"layout horizontal\"\u003e\n      \u003cdiv class=\"flex\"\u003eColumn 1\u003c/div\u003e\n      \u003cdiv class=\"flex\"\u003eColumn 2\u003c/div\u003e\n    \u003c/div\u003e\n  `\n})\nexport class AppComponent {}\n```\n\n### [Polymer `\u003ctemplate\u003e` Stamping](templates/README.md)\n\nCall `polymerHost()` and add it to the providers for a component that uses Polymer's data binding syntax in `\u003ctemplate\u003e` elements. Add `ngNonBindable` to all `\u003ctemplate\u003e` elements.\n\n```ts\nimport { Component } from '@angular/core';\nimport { polymerHost } from '@codebakery/origami/templates';\nimport '@polymer/iron-list/iron-list';\n\n@Component({\n  selector: 'app-component',\n  template: `\n    \u003ciron-list [items]=\"items\"\u003e\n      \u003ctemplate ngNonBindable\u003e\n        \u003cdiv on-click=\"itemClicked\"\u003e\n          \u003cdiv\u003e[[getLabel(item)]]\u003c/div\u003e\n        \u003c/div\u003e\n      \u003c/template\u003e\n    \u003c/iron-list\u003e\n  `,\n  providers: [polymerHost(AppComponent)]\n})\nexport class AppComponent {\n  items = [1, 2, 3];\n\n  getLabel(item: number) {\n    return `# ${item}`;\n  }\n\n  itemClicked(event: Event) {\n    console.log(event);\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhotforfeature%2Forigami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhotforfeature%2Forigami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhotforfeature%2Forigami/lists"}