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

schematic-symbols

v0.0.109

Published

[View Online](https://symbols.tscircuit.com/)

Downloads

22,969

Readme

schematic-symbols

View Online

Schematic symbols for tscircuit

[!TIP] Looking to contribute to this repo? Take a look at How to Contribute to Schematic Symbols!

Usage

import { getSvg, resize, symbols } from "@tscircuit/schematic-symbols"

console.log(symbols.resistor.primitives)
// [{ type: "path", d: "M0 0L1 0...", color: "primary" }, {type: "text", text: "{REF}", ... }]
console.log(symbols.resistor.size)
// { width: 1, height: 0.6 }

getSvg(resistor)
// <svg><path d="M0 0L1 0... ..."</svg>

// You can easily resize symbols
console.log(resize(symbols.resistor, { width: 100 }).size)
// { width: 100, height: 60 }

Adding New Symbols

  1. Add a new svg file to the ./assets/symbols directory (copy volt_meter.svg to a new file named <symbol_name>.svg)
  2. Run bun run generate to generate the new symbol
  3. Run bun run dev to start the dev server and verify the new symbol
  4. Run bun run format to format code before committing
  5. Run bun run test to ensure symbol snapshots are present & validated
  6. Run bun run build to build all the symbols into the ./generated directory

Here's an example of a generated symbol file:

// boxresistor.ts
import { path, text, defineSymbol } from "drawing"

export const boxresistor = defineSymbol({
  primitives: [
    path({ points: [[0, 0] /* ... */, , [1, 0]], color: "primary" }),
    text("{REF}", { x: 0.5, y: 0.3, anchor: "middle_top" }),
  ],
  ports: [
    { x: 0, y: 0, labels: ["1", "-"] },
    { x: 1, y: 0, labels: ["2", "+"] },
  ],
  center: { x: 0.5, y: 0 },
  size: { width: 1, height: 0.6 },
})

These files are used to generate an

Primitives

Various primitive JSON elements are defined to represent components, each primitive has a function you can use to quickly define it inside new symbol definitions.

| Primitive | Description | | --------- | ----------------------------------------------------------- | | path | A set of lines { points: Array<[number, number]>, color } | | text | Text { text, x, y, anchor } | | circle | Circle { x, y, radius } | | box | Box { x, y, width, height, anchor } |

Colors

You can use the following color aliases to color your symbol:

  • primary
  • secondary
  • background

Guidelines

The symbols should all look correct next to eachother, since they're all used together in the same schematic.

  • The width of most standard passives is 1
  • The height of most standard passives is 0.6

Development

Software needed to edit this project:

  • VS Code
  • Inkscape

References