{"id":18544496,"url":"https://github.com/instructure/ic-styled","last_synced_at":"2025-04-09T19:30:45.424Z","repository":{"id":12256906,"uuid":"14873460","full_name":"instructure/ic-styled","owner":"instructure","description":"automatically style components with css templates","archived":false,"fork":false,"pushed_at":"2014-09-05T15:00:28.000Z","size":1462,"stargazers_count":21,"open_issues_count":3,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-24T10:56:25.288Z","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/instructure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-02T20:12:38.000Z","updated_at":"2016-11-08T21:24:36.000Z","dependencies_parsed_at":"2022-08-21T03:10:49.179Z","dependency_job_id":null,"html_url":"https://github.com/instructure/ic-styled","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-styled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-styled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-styled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fic-styled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instructure","download_url":"https://codeload.github.com/instructure/ic-styled/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730067,"owners_count":20986404,"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-06T20:16:42.729Z","updated_at":"2025-04-09T19:30:44.855Z","avatar_url":"https://github.com/instructure.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ic-styled\n=========\n\n[![Build Status](https://travis-ci.org/instructure/ic-styled.svg)](https://travis-ci.org/instructure/ic-styled)\n\nAutomatically style components with css templates.\n\nDemo\n----\n\nhttp://instructure.github.io/ic-styled\n\nInstallation\n------------\n\n`bower install ic-styled`\n\n`npm install ic-styled`\n\n... or download `main.js` and include it into your app however you want.\n\nModule Support\n--------------\n\nic-styled doesn't export anything, it just adds functionality to\n`Ember.Component`. If using a module system, require it somewhere in the\nroot of your application somewhere (like `application.js`).\n\n- AMD\n\n  `define(['ic-styled'], function() {});`\n\n- CJS\n\n  `require('ic-styled')`\n\nUsage\n-----\n\nGiven a component named `x-foo`, create an additional component template\nat `components/x-foo-css`, treat it like a css file. The css will be\nimported into your app automatically on the first instance of `x-foo`.\n\nSounds tricky but its not; here's a sample app:\n\n```html\n\u003cscript type=\"text/x-handlebars\"\u003e\n  \u003ch1\u003eApplication Template using x-foo\u003c/h1\u003e\n  {{x-foo}}\n\u003c/script\u003e\n\n\u003cscript type=\"text/x-handlebars\" id=\"components/x-foo\"\u003e\n  I am x-foo, the main component.\n\u003c/script\u003e\n\n\u003cscript type=\"text/x-handlebars\" id=\"components/x-foo-css\"\u003e\n  /* I am x-foo-css, the styles that go with x-foo */\n  x-foo { color: red; font-weight: bold; }\n\u003c/script\u003e\n\n\u003cscript\u003e\n  var App = Ember.Application.create();\n  App.XFooComponent = Ember.Component.extend({\n    tagName: 'x-foo'\n  });\n\u003c/script\u003e\n```\n\nAt the first render of `{{x-foo}}` the `{{x-foo-css}}` template is\nimported into the app to style `x-foo` elements.\n\nOverriding Component Styles\n---------------------------\n\n`Styled` injects the css template to the top of the `\u003chead\u003e` element so\nits the first-ish css to be applied. This means that you can override\nthe CSS of styled components the same as any native element since your\napp's CSS will be applied after.\n\nVim Config\n----------\n\nIf you use vim, add this to your `vimrc` to get css highlighting for\nthese templates:\n\n`au BufNewFile,BufRead *-css.hbs set filetype=css`\n\nUse Tags to Style\n-----------------\n\nI know, its been hammered into our brains not to use tagNames when\nwriting CSS. But, when you build a component, you are creating a new\ncustom element; you should mimick native elements as much as possible.\nTherefore, style it by tagName so everybody consuming your component can\noverride styles the same way they override a `\u003cbutton\u003e`.\n\nAbout the Implementation\n------------------------\n\nA lot of questions come up, hopefully this answers them:\n\n- all styles are injected into a shared `\u003cstyle\u003e` tag to avoid the IE\n  issue of only allowing 31 style/link tags\n- this style tag is at the top of the `\u003chead\u003e` so application CSS can\n  override the same way they override native element css\n- styles for a component definition are only injected once, even if the\n  component is used several times\n- a comment is inserted so you can see which component injected the css\n\nContributing\n------------\n\n```sh\nbower install\nnpm install\nnpm test\n```\n\nLicense and Copyright\n---------------------\n\nMIT Style license\n\n(c) 2013 Instructure, Inc.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fic-styled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstructure%2Fic-styled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fic-styled/lists"}