{"id":16346797,"url":"https://github.com/matype/yacp","last_synced_at":"2025-03-20T23:32:50.388Z","repository":{"id":15478976,"uuid":"18212526","full_name":"matype/YACP","owner":"matype","description":"Yet Another CSS Preprocessor","archived":false,"fork":false,"pushed_at":"2015-01-26T17:22:58.000Z","size":501,"stargazers_count":52,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-03T13:18:47.218Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matype.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-03-28T13:15:17.000Z","updated_at":"2021-03-21T12:41:50.000Z","dependencies_parsed_at":"2022-08-04T04:45:12.962Z","dependency_job_id":null,"html_url":"https://github.com/matype/YACP","commit_stats":null,"previous_names":["morishitter/yacp","matype/yacp","masaakim/yacp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2FYACP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2FYACP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2FYACP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2FYACP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matype","download_url":"https://codeload.github.com/matype/YACP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244092755,"owners_count":20396866,"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-11T00:37:27.291Z","updated_at":"2025-03-20T23:32:50.044Z","avatar_url":"https://github.com/matype.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://nodei.co/npm/yacp.png)](https://nodei.co/npm/yacp/)\n\n#YACP  [![Build Status](https://travis-ci.org/morishitter/YACP.svg)](https://travis-ci.org/morishitter/YACP) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/morishitter/YACP?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nYet Another CSS Preprocessor.\n\n## Installation\n\n```\n$ npm install -g yacp\n```\n\nwhen use in HTML:\n\n```\n$ bower install client-yacp\n```\n\n\n## Example\n\n```css\n/* Import your other CSS files */\n@import url(\"foo.css\")\n\n/* Define variables in W3C syntax */\n:root {\n  --font-lg: 18px;\n}\n\n/* Placeholder selector for `extend` */\n%att {\n  color: red;\n  font-weight: normal;\n}\n\n.attBox {\n  extend: %att; /* Extend `%att` */\n  box-shadow: 5px 5px;\n  font-size: var(--font-lg); /* Use variable `--font-lg` */\n  padding: 5px 10px;\n}\n```\n\nCompiled with the following command:\n\n```\n$ yacp input.css output.css\n```\n\nYields:\n\n```css\n/* Expand foo.css */\n.foo {\n\n}\n\n/* Inherited in `.attBox` */\n.attBox {\n  color: red;\n  font-weight: normal;\n}\n\n.attBox {\n  -webkit-box-shadow: 5px 5px; /* Automatically added vendor prefix */\n  box-shadow: 5px 5px;\n  font-size: 18px; /* Expand the variable */\n  padding: 5px 10px;\n}\n```\n\n## Features\n\n- [Automatic vendor-prefixed property](https://github.com/ai/autoprefixer)\n- [Rulesets binding syntax](https://github.com/morishitter/rework-rule-binding)\n- [Inherit other rules more safely](https://github.com/morishitter/rework-extend-validator)\n- [W3C-style CSS variables syntax](https://github.com/reworkcss/rework-vars)\n- [Support `calc()`, a feature to do simple calculations](https://github.com/reworkcss/rework-calc)\n- [Read and inline css via `@import`](https://github.com/reworkcss/rework-import)\n\n### Bind ruleset syntax\n\nYACP provide [Bind ruleset syntax](https://github.com/morishitter/rework-rule-binding/).\n\nSelectors rounded by `()` cannot cascade.\n\nUsing this feature, you can define **encapsulated** ruleset.\n\n```css\n(.btn) {\n  background-color; #4dac26;\n  border: solid 1px #2c9700;\n  color: #fff;\n  font-size: 16px;\n  padding: 12px 8px;\n}\n\n/* Error */\n.btn {\n  padding: 15px 10px;\n}\n/* Error */\n(.btn) {\n  padding: 15px 10px;\n}\n```\n\n### Inherit other rulesets safely\n\nOne of fault of existin CSS Preprocessor is compiling any code which don't have syntax error.\n\nThis is 'dangerous' inheritance code (Sass):\n\n```css\n.btn {\n  border-radius: 5px;\n  color: #fff;\n  padding: 6px 12px;\n}\n\n.btn-success {\n  @extend .btn;\n  background-color: #4dac26;\n}\n\n...\n\n.btn {\n  padding: 8px 16px;\n}\n```\n\nYields:\n\n```css\n.btn, .btn-success {\n  border-radius: 5px;\n  color: #fff;\n  padding: 6px 12px;\n}\n\n.btn-success {\n  background-color: #4dac26;\n}\n\n...\n\n.btn, .btn-success {\n  padding: 8px 16px;\n}\n```\n\nWhen overwrite `.btn`, `.btn-success` is overwrote too, and it may cause unexpected result.\n\nBut, [YACP's inheritance is safe](https://github.com/morishitter/rework-extend-validator). You can use with `extend(s)` or `inherit(s)` property.\n\n1. Must use the placeholder selector (`%`). The Ruleset defined with placeholder selector don't output as CSS code.\n\n2. YACP's placeholder selector cannot cascade.\n\n3. If inherited selectors have same properties, run error.\n\nEx (1, 2):\n\n```css\n%btn {\n  border-radius: 5px;\n  color: #fff;\n  padding: 6px 12px;\n}\n\n.btn-success {\n  extend: %btn;\n  background-color: var(--color-green);\n}\n\n/* Error */\n%btn {\n  padding: 8px 16px;\n}\n```\n\nEx (3):\n\n```css\n%foo {\n  font-size: 16px;\n  padding: 5px 10px;\n}\n\n%bar {\n  color: #fff;\n  font-size: 14px;\n}\n\n.baz {\n  /* Error */\n  extend: %foo;\n  extend: %bar;\n}\n```\n\nUsing this feature, you can define **private** (cannot overwrite and refer from only YACP code) ruleset.\n\n\n## Compile Options\n\n```\n$ yacp --help\n```\n\n```\nUsage: yacp [options]\n\nOptions:\n\n  -c, --compress    use output compression\n  -s, --strict      use strict mode compile\n  -w, --whitespace  use whitespace syntax like Stylus\n  -V, --versions    output the version number\n  -h, --help        output usage information\n```\n\n### strict mode\n\nYACP's strict mode allow only class and pseudo-elements selector.\n\nFollowing selectors cannot compile.\n\nEx:\n\n```css\n#id {}\n\ndiv {}\n\n.class .nested {}\n\np.class {}\n```\n\nand prohibit `!important`.\n\n```css\n.class {\n  /* Error */\n  padding: 0 !important;\n}\n```\n\nUsing this option, you can keep [specificity](http://www.w3.org/TR/css3-selectors/#specificity) constant, so its code will be more maintenable.\n\n### whitespace mode\n\nUsing with [css-whitespace](https://github.com/reworkcss/css-whitespace).\n\n\n## Option projects\n\n- [grunt-yacp](https://github.com/morishitter/grunt-yacp)\n\n## License\nThe MIT License (MIT)\n\nCopyright (c) 2014 Masaaki Morishita\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fyacp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatype%2Fyacp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fyacp/lists"}