{"id":15138319,"url":"https://github.com/inizio/winks","last_synced_at":"2025-09-29T06:31:34.584Z","repository":{"id":57148648,"uuid":"132830691","full_name":"IniZio/winks","owner":"IniZio","description":":stuck_out_tongue_winking_eye: A reactive web-component library","archived":true,"fork":false,"pushed_at":"2019-10-18T03:54:20.000Z","size":131,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-15T03:54:32.830Z","etag":null,"topics":["custom-elements-v1","web-components"],"latest_commit_sha":null,"homepage":"","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/IniZio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-05-10T01:14:39.000Z","updated_at":"2023-01-28T16:54:29.000Z","dependencies_parsed_at":"2022-08-31T23:50:30.821Z","dependency_job_id":null,"html_url":"https://github.com/IniZio/winks","commit_stats":null,"previous_names":["winksjs/winks"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IniZio%2Fwinks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IniZio%2Fwinks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IniZio%2Fwinks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IniZio%2Fwinks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IniZio","download_url":"https://codeload.github.com/IniZio/winks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234597574,"owners_count":18857980,"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-v1","web-components"],"created_at":"2024-09-26T07:21:53.461Z","updated_at":"2025-09-29T06:31:34.192Z","avatar_url":"https://github.com/IniZio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eWinks.js\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e:stuck_out_tongue_winking_eye: A library made when doing assignment https://github.com/IniZio/COMP4021-SPA :stuck_out_tongue_winking_eye:\u003c/p\u003e\n\u003cp align=\"center\"\u003eUses web-component, custom-element and html-import\u003c/p\u003e\n\n## Getting started\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"\u003e\n  \u003ctitle\u003eHello Winks.js\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- 0. Polyfill for web-component --\u003e\n  \u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/webcomponents-lite.js\"\u003e\u003c/script\u003e\n  \u003c!-- 1. Polyfill for es5 custom-element work in modern browsers --\u003e\n  \u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/custom-elements-es5-adapter.js\"\u003e\u003c/script\u003e\n  \u003c!-- 2. Winks.js --\u003e\n  \u003cscript src=\"https://unpkg.com/winks/dist/winks.min.js\"\u003e\u003c/script\u003e\n  \u003c!-- 3. Create a web component  --\u003e\n  \u003cscript\u003e\n    Winks.component('hello-winks', {\n      template: '\u003ch1\u003eHello Winks.js!\u003c/h1\u003e'\n    })\n  \u003c/script\u003e\n  \u003c!-- 4. Use the custom-element --\u003e\n  \u003chello-winks\u003e\u003c/hello-winks\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## How to use\n\n#### 1. Add a new component\n\n```js\nWinks.component('some-component', {\n  template: '\u003ch2\u003eComponent content\u003c/h2\u003e'\n})\n```\n\n### 2. Access children of the html file in its class\n\n```js\nWinks.component('xyz-abc', {\n  connectedCallback () {\n    super.connectedCallback()\n    console.log($(this.shadowRoot).children('#send-email'))\n  }\n}\n```\n\n### 3. Add event listeners to template content\n\n```js\nWinks.component('xyz-abc', class extends MyElement {\n  template: '\u003cbutton @click=\"sendEmail\"\u003eSend\u003c/button\u003e'\n  sendEmail (e) {\n    e.preventDefault()\n    api.sendMail()\n    console.log('sending email')\n  }\n})\n```\n\n### 4. Use reactive state\n\n```html\n\u003ctemplate\u003e\n  \u003cinput :value=\"message\" @input=\"changeMessage\"\u003e\n  \u003cdiv :children=\"message\"\u003e\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  Winks.component('abc-xyz', {\n    // NOTE: Use a function that returns the initial value\n    data () {\n      return {\n        cc: 100,\n        message: 'qq'\n      }\n    }\n    changeMessage (e) {\n      this.data.message = e.target.value\n    }\n  })\n\u003c/script\u003e\n```\n\n### 5. Use global context\n\n```html\n\u003ctemplate\u003e\n  \u003cinput ~value=\"magic\" @input=\"changeMessage\"\u003e\n  \u003cdiv ~children=\"magic\"\u003e\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  Winks.component('abc-xyz', {\n    changeMessage (e) {\n      this.context.magic = e.target.value\n    }\n  })\n\u003c/script\u003e\n```\n\n### 6. Use `x-for` directive\n\n```html\n\u003ctemplate\u003e\n  \u003cdiv x-for=\"abc:messages\" :children=\"abc\"\u003e\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  Winks.component('abc-xyz', {\n    data () {\n      return {\n        messages: ['hello', 'bye', 'magic']\n      }\n    }\n  })\n\u003c/script\u003e\n```\n\n### 7. Use `x-if` and `x-else` directive\n\n```html\n\u003ctemplate\u003e\n  \u003cbutton @click=\"toggleEdit\"\u003eEdit\u003c/button\u003e\n  \u003cinput x-if=\"isEditting\" :value=\"content\" @input=\"changeContent\"\u003e\n  \u003cdiv x-else :children=\"content\"\u003e\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  Winks.component('abc-xyz', {\n    data () {\n      return {\n        isEditting: false,\n        content: ''\n      }\n    }\n  \n    toggleEdit () {\n      this.data.isEditting = !this.data.isEditting\n    }\n  \n    changeContent (e) {\n      this.data.content = e.target.value\n    }\n  })\n\u003c/script\u003e\n```\n\n## Development\n\n```sh\nyarn\n\nyarn clip watch\n\nyarn clip build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finizio%2Fwinks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finizio%2Fwinks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finizio%2Fwinks/lists"}