{"id":21151514,"url":"https://github.com/outstand/postcss-each-in-map","last_synced_at":"2025-10-08T23:22:20.506Z","repository":{"id":60856688,"uuid":"541558802","full_name":"outstand/postcss-each-in-map","owner":"outstand","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-05T17:18:05.000Z","size":381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-26T04:51:51.873Z","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/outstand.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":"2022-09-26T11:49:22.000Z","updated_at":"2022-09-26T11:49:36.000Z","dependencies_parsed_at":"2022-10-05T22:29:39.394Z","dependency_job_id":null,"html_url":"https://github.com/outstand/postcss-each-in-map","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/outstand/postcss-each-in-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outstand%2Fpostcss-each-in-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outstand%2Fpostcss-each-in-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outstand%2Fpostcss-each-in-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outstand%2Fpostcss-each-in-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outstand","download_url":"https://codeload.github.com/outstand/postcss-each-in-map/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outstand%2Fpostcss-each-in-map/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000734,"owners_count":26082862,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-20T10:17:21.731Z","updated_at":"2025-10-08T23:22:20.481Z","avatar_url":"https://github.com/outstand.png","language":"JavaScript","readme":"# postcss-each-in-map\n\n[PostCSS] plugin to iterate through maps.\n\n[PostCSS]: https://github.com/postcss/postcss\n\nIterate through a map:\n```css\n.u-display {\n  @each-in-map $display-name, $display-type in display_types {\n    \u0026$(display-name) {\n      display: $display-type;\n    }\n  }\n}\n```\n\n```css\n.u-display {\n  @each $display-name, $display-type in (None, InlineBlock, InlineFlex, Block, Flex, Grid), (none, inline-block, inline-flex, block, flex, grid) {\n    \u0026$(display-name) {\n      display: $display-type;\n    }\n  }\n}\n```\n\nIterate through a map with multiple (and missing) values:\n```css\n@each $space, $space-index in 0, 5px, 10px, 15px, 30px, 45px, 60px {\n  @each-in-map $direction, $direction-attribute in direction_map {\n    $(direction)$(space-index) {\n      $(direction-attribute): $space !important;\n    }\n  }\n}\n```\n\n```css\n@each $space, $space-index in 0, 5px, 10px, 15px, 30px, 45px, 60px {\n  @each $direction, $direction-attribute in (X, X, Y, Y, A, T, B, L, R), (-left, -right, -top, -bottom, , -top, -bottom, -left, -right) {\n    $(direction)$(space-index) {\n      $(direction-attribute): $space !important;\n    }\n  }\n}\n```\n\nIterate through a map while destructuring array values:\n```css\n@each-in-map $class, $background, $label_width in graph_parts {\n  $(class) {\n    .metrics-graph-part-number:before {\n      background: $background;\n    }\n\n    .metrics-graph-part-number,\n    .metrics-graph-part-label {\n      width: $label_width;\n    }\n  }\n}\n```\n\n```css\n@each $class, $background, $label_width in (opt-outs, clicks, opens, bounces, unactioned), ($mango_tango, var(--color-a11y-blue), $funk, $agrellan_badland, $hint_of_mauve_pansy), (52px, 36px, 35px, 49px, auto) {\n  $(class) {\n    .metrics-graph-part-number:before {\n      background: $background;\n    }\n\n    .metrics-graph-part-number,\n    .metrics-graph-part-label {\n      width: $label_width;\n    }\n  }\n}\n```\n\nExample json:\n```json\n{\n  \"display_types\": {\n    \"None\": \"none\",\n    \"InlineBlock\": \"inline-block\",\n    \"InlineFlex\": \"inline-flex\",\n    \"Block\": \"block\",\n    \"Flex\": \"flex\",\n    \"Grid\": \"grid\"\n  },\n  \"direction_map\": {\n    \"X\": [\n      \"-left\",\n      \"-right\"\n    ],\n    \"Y\": [\n      \"-top\",\n      \"-bottom\"\n    ],\n    \"A\": \"\",\n    \"T\": \"-top\",\n    \"B\": \"-bottom\",\n    \"L\": \"-left\",\n    \"R\": \"-right\"\n  },\n  \"graph_parts\": {\n    \"opt-outs\": [\n      \"$mango_tango\",\n      \"52px\",\n      \"top\"\n    ],\n    \"clicks\": [\n      \"var(--color-a11y-blue)\",\n      \"36px\",\n      \"bottom\"\n    ],\n    \"opens\": [\n      \"$funk\",\n      \"35px\",\n      \"top\"\n    ],\n    \"bounces\": [\n      \"$agrellan_badland\",\n      \"49px\",\n      \"bottom\"\n    ],\n    \"unactioned\": [\n      \"$hint_of_mauve_pansy\",\n      \"auto\",\n      \"bottom\"\n    ]\n  }\n}\n```\n\n## Usage\n\n**Step 1:** Install plugin:\n\n```sh\nnpm install --save-dev postcss postcss-each-in-map postcss-each\n```\n\n**Step 2:** Add the plugin to the plugins list:\n\n```diff\nmodule.exports = {\n  plugins: [\n+   require('postcss-each-in-map'),\n+   require('postcss-each'),\n    require('autoprefixer')\n  ]\n}\n```\n\n### Options\n\n```javascript\nrequire('postcss-each-in-map')({\n  basePath: 'app/assets/json',\n  jsonPath: 'maps.json',\n  logLevel: 'info',\n})\n```\n\n#### `basePath`\n\nType: `String`\nDefault: `process.cwd()`\n\nLocation to look for map json. Can be either relative or absolute.\n\n#### `jsonPath`\n\nType: `String`\nDefault: `'maps.json'`\n\nName (or path) relative to the `basePath` to find the map json file.\n\n#### `logLevel`\n\nType: `String`\nDefault: `'warn'`\n\nLog level (from https://github.com/pimterry/loglevel) for this plugin.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutstand%2Fpostcss-each-in-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutstand%2Fpostcss-each-in-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutstand%2Fpostcss-each-in-map/lists"}