{"id":16349479,"url":"https://github.com/jednano/postcss-triangle","last_synced_at":"2025-03-21T00:30:36.515Z","repository":{"id":57328615,"uuid":"39977619","full_name":"jednano/postcss-triangle","owner":"jednano","description":"PostCSS plugin to create a triangle.","archived":false,"fork":false,"pushed_at":"2017-11-02T17:05:06.000Z","size":106,"stargazers_count":59,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T01:11:10.182Z","etag":null,"topics":["equilateral","isosceles","postcss","postcss-plugin","right","triangle"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jednano.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":"2015-07-30T23:57:36.000Z","updated_at":"2025-02-27T14:21:20.000Z","dependencies_parsed_at":"2022-09-04T10:20:36.933Z","dependency_job_id":null,"html_url":"https://github.com/jednano/postcss-triangle","commit_stats":null,"previous_names":["jedmao/postcss-triangle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-triangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-triangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-triangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fpostcss-triangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jednano","download_url":"https://codeload.github.com/jednano/postcss-triangle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244094244,"owners_count":20397020,"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":["equilateral","isosceles","postcss","postcss-plugin","right","triangle"],"created_at":"2024-10-11T00:59:53.890Z","updated_at":"2025-03-21T00:30:36.264Z","avatar_url":"https://github.com/jednano.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postcss-triangle\n\n\u003cimg align=\"right\" width=\"135\" height=\"95\"\n\ttitle=\"Philosopher’s stone, logo of PostCSS\"\n\tsrc=\"http://postcss.github.io/postcss/logo-leftp.png\"\u003e\n\n[![NPM version](http://img.shields.io/npm/v/postcss-triangle.svg?style=flat)](https://www.npmjs.org/package/postcss-triangle)\n[![npm license](http://img.shields.io/npm/l/postcss-triangle.svg?style=flat-square)](https://www.npmjs.org/package/postcss-triangle)\n[![Travis Build Status](https://img.shields.io/travis/jedmao/postcss-triangle.svg)](https://travis-ci.org/jedmao/postcss-triangle)\n[![codecov](https://codecov.io/gh/jedmao/postcss-triangle/branch/master/graph/badge.svg)](https://codecov.io/gh/jedmao/postcss-triangle)\n[![Dependency Status](https://gemnasium.com/badges/github.com/jedmao/postcss-triangle.svg)](https://gemnasium.com/github.com/jedmao/postcss-triangle)\n\n[![npm](https://nodei.co/npm/postcss-triangle.svg?downloads=true)](https://nodei.co/npm/postcss-triangle/)\n\n[PostCSS](https://github.com/postcss/postcss) plugin to create a triangle.\n\n## Introduction\n\nCreating triangles in CSS [is entirely complicated](https://css-tricks.com/snippets/css/css-triangle/), but it doesn't have to be!\n\nUsing this plugin, you can create three different types of triangles:\n\n```css\n.isosceles-triangle {\n\ttriangle: pointing-\u003cup|down|left|right\u003e;\n\twidth: \u003clength\u003e;\n\theight: \u003clength\u003e;\n\tbackground-color: \u003ccolor\u003e;\n}\n\n.right-isosceles-triangle {\n\ttriangle: right-iso pointing-\u003cup|down|left|right\u003e;\n\t\u003cwidth|height\u003e: \u003clength\u003e;\n\tbackground-color: \u003ccolor\u003e;\n}\n\n.equilateral-triangle {\n\ttriangle: equilateral pointing-\u003cup|down|left|right\u003e;\n\t\u003cwidth|height\u003e: \u003clength\u003e;\n\tbackground-color: \u003ccolor\u003e;\n}\n```\n\n### Triangle types\n\nAll triangle types have the following rules/caveats:\n- You must specify a direction (`pointing-up`, `pointing-down`, `pointing-left` or `pointing-right`).\n- You must provide a separate `background-color` declaration. This will transpile into a `border-color` in the opposite direction in which your triangle points. The `background-color` helps you forget about all that nonsense and just specify what _appears_ to be the background color, visually.\n- Unfortunately, there is no way to set a triangle's actual `border` at this time. I considered using the `::before` pseudo-class to achieve this; however, it had a defect that was cutting it in half and I gave up. Feel free to submit a pull request with this feature if you have a solution for it.\n\nNow, on to the triangle types!\n\n#### Isosceles\n\n\u003cimg src=\"https://github.com/jedmao/postcss-triangle/blob/master/images/isosceles-triangle.png?raw=true\" alt=\"Isosceles Triangle (Default)\" width=\"234\" height=\"146\" align=\"right\"\u003e\n\nThis is the default triangle type. It has two angles the same and two sides the same. The triangle will fit snug inside the `width` and `height` box that you define. Here's how you create one:\n\n```css\n.isosceles-triangle {\n\ttriangle: pointing-right;\n\twidth: 150px;\n\theight: 115px;\n\tbackground-color: red;\n}\n```\n\nThis transpiles into:\n\n```css\n.isosceles-triangle {\n\twidth: 0;\n\theight: 0;\n\tborder-style: solid;\n\tborder-color: transparent;\n\tborder-width: 57.5px 0 57.5px 150px;\n\tborder-left-color: red;\n}\n```\n\n[See it on CodePen!](http://codepen.io/jedmao/details/yNZJxE/)\n\nThis creates a triangle with `width: 150px; height: 115px;` and pointing right.\n\nThe isosceles triangle has the following rules/caveats:\n- You must specify both a `width` and `height`.\n\n#### [Right-Isosceles](http://mathworld.wolfram.com/IsoscelesRightTriangle.html)\n\n\u003cimg src=\"https://github.com/jedmao/postcss-triangle/blob/master/images/right-isosceles-triangle.png?raw=true\" alt=\"Right-Isosceles Triangle\" width=\"300\" height=\"125\" align=\"right\"\u003e\n\nThis triangle has two 45\u0026deg; angles and one 90\u0026deg; angle. The 90\u0026deg; angle is the direction the triangle points. This is great if you want to render a triangle with the sharpest edge possible, because it follows the pixels on your screen exactly, without any additional anti-aliasing.\n\nIso is short for isosceles, because it's not the most fun word to spell/type; rather, it's only fun if you know how to spell it!\n\nHere's how you create one:\n\n```css\n.right-isosceles-triangle {\n\ttriangle: right-iso pointing-down;\n\twidth: 250px;\n\tbackground-color: red;\n}\n```\n\nThis transpiles into:\n\n```css\n.right-isosceles-triangle {\n\twidth: 0;\n\theight: 0;\n\tborder-style: solid;\n\tborder-color: transparent;\n\tborder-width: 125px 125px 0;\n\tborder-top-color: red;\n}\n```\n\n[See it on CodePen!](http://codepen.io/jedmao/details/gpqMZg/)\n\nThis creates a triangle with `width: 250px; height: 125px;` and pointing down.\n\nThe right-isosceles triangle has the following rules/caveats:\n- You must specify either a `width` or a `height`.\n- You may not specify both a `width` and `height`, because it will calculate the missing dimension for you.\n\n#### [Equilateral](https://en.wikipedia.org/wiki/Equilateral_triangle)\n\n\u003cimg src=\"https://github.com/jedmao/postcss-triangle/blob/master/images/equilateral-triangle.png?raw=true\" alt=\"Equilateral Triangle\" width=\"250\" height=\"181\" align=\"right\"\u003e\n\nThis triangle's angles are all the same (60\u0026deg;). This means all sides are the same length as well. Here's how you create one:\n\n```css\n.equilateral-triangle {\n\ttriangle: equilateral pointing-up;\n\theight: 100px;\n\tbackground-color: red;\n}\n```\n\nThis transpiles into:\n\n```css\n.equilateral-triangle {\n\twidth: 0;\n\theight: 0;\n\tborder-style: solid;\n\tborder-color: transparent;\n\tborder-width: 0 57.73503px 100px;\n\tborder-bottom-color: red;\n}\n```\n\n[See it on CodePen!](http://codepen.io/jedmao/details/waNWRq/)\n\nThis creates a triangle with `width: 115.47006px; height: 100px;` and pointing up.\n\nThe equilateral triangle has the following rules/caveats:\n- You must specify either a `width` or a `height`.\n- You may not specify both a `width` and `height`, because it will calculate the missing dimension for you.\n\nThat's about it!\n\n## Installation\n\n```\n$ npm install postcss-triangle\n```\n\n## Usage\n\n### JavaScript\n\n```js\npostcss([ require('postcss-triangle')(/* options */) ]);\n```\n\n### TypeScript\n\n```ts\nimport * as postcssTriangle from 'postcss-triangle';\n\npostcss([ postcssTriangle(/* options */) ]);\n```\n\n## Options\n\n### unitPrecision\n\nType: `number`\u003cbr\u003e\nRequired: `false`\u003cbr\u003e\nDefault: `5`\n\nWhen using `right-iso` or `equilateral` triangles, calculations will be performed that will most likely turn into fractions. This option allows you to control the number of significant digits after the decimal point (e.g., `1.2354` with a `unitPrecision` of `2` would yield `1.24`, rounding it off nicely).\n\n## Testing\n\nRun the following command:\n\n```\n$ npm test\n```\n\nThis will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.\n\n### Watching\n\nFor much faster development cycles, run the following commands in 2 separate processes:\n\n```\n$ npm run build:watch\n```\n\nCompiles TypeScript source into the `./dist` folder and watches for changes.\n\n```\n$ npm run watch\n```\n\nRuns the tests in the `./dist` folder and watches for changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fpostcss-triangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjednano%2Fpostcss-triangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fpostcss-triangle/lists"}