{"id":17349270,"url":"https://github.com/co2-git/js4","last_synced_at":"2025-03-27T11:44:30.925Z","repository":{"id":35779544,"uuid":"40059509","full_name":"co2-git/js4","owner":"co2-git","description":"Write CSS with ES6 JavaScript.","archived":false,"fork":false,"pushed_at":"2015-08-01T20:45:57.000Z","size":108,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T16:23:22.504Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/co2-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-08-01T20:44:27.000Z","updated_at":"2015-08-20T11:23:13.000Z","dependencies_parsed_at":"2022-08-17T21:31:01.739Z","dependency_job_id":null,"html_url":"https://github.com/co2-git/js4","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fjs4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fjs4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fjs4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fjs4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co2-git","download_url":"https://codeload.github.com/co2-git/js4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841692,"owners_count":20681184,"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-10-15T16:55:12.538Z","updated_at":"2025-03-27T11:44:30.897Z","avatar_url":"https://github.com/co2-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"js4\n===\n\nWrite CSS with ES6 JavaScript.\n\n# Install\n\n```bash\nnpm install -g js4 # may require sudo\n```\n\n# Usage\n\nWrite your CSS in JS in a file, for example `css.js`:\n\n```js\nnew Rule('body', { color : 'red' });\n\nnew Rule('#id, .class \u003e [attr]', { 'text-align' : 'center' });\n```\n\nThen compile it from terminal:\n\n```bash\njs4 css.js\n```\n\nOutputs:\n\n```css\nbody {\n  color: red;\n}\n\n#id, .class \u003e [attr] {\n  text-align: center;\n}\n```\n\nTo compile to a source file:\n\n```bash\njs4 css.js \u003e css.css\n```\n\n# Unleash the power of JavaScript\n\nNow you can use JS to do advanced stuff in your CSS such as declarations or scopes:\n\n```js\n\nconst COLOR = 'red';\n\nfor ( let i = 0; i \u003c 10; i ++ ) {\n  new Rule(`#p-${i}`, { color : COLOR, width : `${i * 25}px`  });\n}\n```\n\n# Mixins\n\nYou can use mixin and reusable rules such as:\n\n```js\nlet reusable = new Rule('.foo', { color : 'red' });\n\nnew Rule('.bar', { reusable, 'padding' : '10px' });\n```\n\n```css\n.foo {\n  color: red;\n}\n\n.bar {\n  color: red;\n  padding: 10px;\n}\n```\n\nIf you don't want the mixin to appear on CSS, do like this:\n\n```js\nlet reusable = new Rule('.foo', { color : 'red' }, { render : false });\n\nnew Rule('.bar', { reusable, 'padding' : '10px' });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fjs4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco2-git%2Fjs4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fjs4/lists"}