{"id":16346584,"url":"https://github.com/matype/postcss-ref","last_synced_at":"2025-03-23T00:32:48.787Z","repository":{"id":12358542,"uuid":"71691350","full_name":"matype/postcss-ref","owner":"matype","description":"PostCSS plugin to refer properties from another rule (@ref rule)","archived":false,"fork":false,"pushed_at":"2022-03-24T09:31:48.000Z","size":44,"stargazers_count":26,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T14:11:25.365Z","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":"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":"2016-10-23T08:45:11.000Z","updated_at":"2024-10-24T05:46:02.000Z","dependencies_parsed_at":"2022-08-07T06:16:57.285Z","dependency_job_id":null,"html_url":"https://github.com/matype/postcss-ref","commit_stats":null,"previous_names":["morishitter/postcss-ref","matype/postcss-ref"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fpostcss-ref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fpostcss-ref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fpostcss-ref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matype%2Fpostcss-ref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matype","download_url":"https://codeload.github.com/matype/postcss-ref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040235,"owners_count":20551297,"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:35:42.652Z","updated_at":"2025-03-23T00:32:48.502Z","avatar_url":"https://github.com/matype.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postcss-ref [![Build Status](https://travis-ci.org/morishitter/postcss-ref.svg)](https://travis-ci.org/morishitter/postcss-ref)\n\nPostCSS plugin to refer properties from another rule (@ref rule)\n\n## Spec\n\n### Abstract\n\nThis specification defines the @ref rule, which allows an author to refer properties in another style rule.\n\n### Using @ref rule\n\n```\n@ref = @ref \u003cselector-name\u003e, \u003creffered-property-name\u003e( ,\u003cnew-property-name\u003e)\n```\n\n#### Example\n\n```css\n.foo {\n  font-size: 12px;\n  color: #333;\n}\n\n.bar {\n  @ref .foo, font-size;\n  color: #444;\n}\n```\n\n### `ref()` notation (with `atRule` option)\n\nYou can pass an option to `postcss-ref` which lets you use `ref` as a function (`ref()`) instead of an atRule (`@ref`)\n\n```\nref() = ref(\u003cselector-name\u003e, \u003creffered-property-name\u003e)\n```\n\n#### Example\n```css\n.foo {\n  font-size: 12px;\n  color: #333;\n}\n\n.bar {\n  font-size: ref(.foo, font-size);\n  color: #444;\n}\n```\n\n### with media queries\n\nIt also works with @media rules\n\n```css\n.foo {\n  font-size: 10px;\n}\n\n@media (min-width: 1602px) {\n  .foo {\n    font-size: 12px;\n    color: #333;\n  }\n}\n\n.bar {\n  @ref @media (min-width: 1602px) .foo, font-size;\n}\n```\n\nor\n\n```css\n.bar {\n  font-size: ref(@media (min-width: 1602px) .foo, font-size);\n}\n```\n\nThis allows you to be more verbose with what you are doing.\n\n## Installation\n\n```shell\n$ npm install postcss-ref\n```\n\n## How to use postcss-ref\n\n### in Node.js\n\n```js\n// dependencies\nvar fs = require(\"fs\")\nvar postcss = require(\"postcss\")\nvar ref = require(\"postcss-ref\")\n\n// css to be processed\nvar css = fs.readFileSync(\"input.css\", \"utf8\")\n\n// process css\nvar output = postcss()\n  .use(ref()) // If using the function way change it to `ref({ atRule: false })`\n  .process(css)\n  .css\n```\n\n## Example\n\nInput:\n\n```css\n.foo {\n  font-size: 12px;\n  color: #333;\n}\n\n.bar {\n  @ref .foo, font-size;\n  color: #444;\n}\n```\n\nOutput:\n\n```css\n.foo {\n  font-size: 12px;\n  color: #333;\n}\n\n.bar {\n  font-size: 12px;\n  color: #444;\n}\n```\n\n### Works well with custom properties\n\nInput:\n\n```css\n.foo {\n  --font-m: 12px;\n  color: #333;\n}\n\n.bar {\n  @ref .foo, --font-m, font-size;\n}\n```\n\nOutput:\n\n```css\n.foo {\n  --font-m: 12px;\n  color: #333;\n}\n\n.bar {\n  font-size: var(--font-m);\n}\n```\n\nInput:\n\n```css\n.foo {\n  --font-m: 12px;\n  color: #333;\n}\n\n.bar {\n  font-size: ref(.foo, --font-m);\n}\n```\n\nOutput:\n\n```css\n.foo {\n  --font-m: 12px;\n  color: #333;\n}\n\n.bar {\n  font-size: var(--font-m);\n}\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Masaaki Morishita\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fpostcss-ref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatype%2Fpostcss-ref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatype%2Fpostcss-ref/lists"}