npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@react-native-toolkit/triangle

v0.0.1

Published

Draw geometrically accurate triangles in React Native

Downloads

181

Readme

logo.png

React Native Triangle

Draw geometrically accurate triangles in React Native

Supports equilateral, isosceles, scalene & right-angled triangles

Built on top of the inbuilt <View/> component

Maintainability Test Coverage

Version Downloads Bundlephobia

Star on GitHub Watch on GitHub Twitter Follow


Compatible with Expo & React Native Web 🚀

PRs Welcome 👍✨

Installation

#npm
npm install --save @react-native-toolkit/triangle

#yarn
yarn add @react-native-toolkit/triangle

Motivation

Triangles are an important part of user interfaces and I needed full control over the triangle dimensions. I initially tried react-native-triangle but I had very less control over the triangle properties. Especially scalene & isosceles triangles.

This library is focused on providing an easy API to create all possible triangles based on the CSS Triangle Generator

Usage

By default, the Triangle component renders an equilateral triangle

import React from "react";
import Triangle from "@react-native-toolkit/triangle";

const App = () => {
  return <Triangle mode={"top"} base={50} color={"red"} />;
};

This will render an equilateral triangle of color "red" & side - 50

Properties

Equilateral Triangle - All three sides equal

type?: "equilateral"

Type of the triangle. Optional for equilateral triangle

mode: "top" | "bottom" | "left" | "right"

Direction in which the triangle is facing

base: number

Length of the base & since it's equilateral all the sides have the length of the base

color: string

Color of the triangle

Isosceles Triangle - Two sides of the triangle are equal

type: "isosceles"

Type of the triangle.

mode: "top" | "bottom" | "left" | "right"

Direction in which the triangle is facing

base: number

Length of the base

height: number

Height of the triangle from base to the peak. The two connecting sides will have the equal length.

color: string

Color of the triangle

Scalene Triangle - All three sides of the triangle have different lengths

type: "scalene"

Type of the triangle.

mode: "top" | "bottom" | "left" | "right"

Direction in which the triangle is facing

height: number

Height of the triangle from base to the peak.

left: number

Length of the side on the left of the line representing height of the triangle.

right: number

Length of the side on the right of the line representing height of the triangle.

color: string

Color of the triangle

Right Angled Triangle - A triangle with angle of 90° on one of it's sides

type: "rightAngle"

Type of the triangle.

mode: "top-left" | "top-right" | "bottom-left" | "bottom-right"

Direction in which the triangle is facing

base: number

Length of the base

height: number

Height of the triangle from base to the peak. The two connecting sides will have the equal length.

color: string

Color of the triangle

ViewProps

All existing ViewProps are supported by this component as it extends the <View/> component. However, it cannot have any children as creating a triangle requires height & width of the View to be 0.

Examples

Licenses

MIT © DaniAkash