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

postcss-sketch

v0.4.0

Published

PostCSS plugin that provides deep bindings between sketch files and your CSS.

Downloads

31

Readme

PostCSS-Sketch Plugin - Build Status

Just playing with bringing Sketch colours, styles, structure, etc directly into CSS from SketchApp using PostCSS.

TL;DR

PostCSS-Sketch demonstration

Currently Supported Sketch Attributes

  • textStyles
    • font, size, color, line-height, weight, style
  • sharedStyles (background, border)
    • fills
      • solid background
      • linear background
      • radial background
    • border
      • color & width
    • box-shadow
      • done
    • padding, margins etc (needs work)
  • symbols
    • all of the above, nested

TODO

  • Improve documentation (Ughhh - Options, Design Tips)
  • Remove repetition for nested items
  • Sort out ordering of rules
  • Update reference structure? @extends?
  • Supprt image assets & SVG

Quick example...

This "CSS"...

h1 {
    font: sketch('./tests.sketch').textStyle.Headline_1;
}

h2 {
    font: sketch('./tests.sketch').textStyle.Headline_2;
}

p {
    font: sketch('./tests.sketch').textStyle.Body;
}

a {
    font: sketch('./tests.sketch').textStyle.Link;
}

.sharedStyle {
    extends: sketch('./tests.sketch').sharedStyle.Complex;
    padding: 1rem;
}

.buttonPrimary {
    extends: sketch('./tests.sketch').sharedStyle.ButtonPrimary;
}

.basicSymbolTest {
    extends: sketch('./tests.sketch').symbol.BasicSymbol;
}

.testBackground {
    extends: sketch('./tests.sketch').symbol.TestBackground;
}

.testLinearBackground {
    extends: sketch('./tests.sketch').symbol.TestLinearBackground;
}

.testRadialBackground {
    extends: sketch('./tests.sketch').symbol.TestRadialBackground;
}

Becomes this CSS

h1 {
    font-weight: 500;
    font-family: 'Roboto';
    font-size: 32px;
    line-height: 44px;
    color: rgba(57,60,62,1);
}

h2 {
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 22px;
    line-height: 32px;
    color: rgba(57,60,62,1);
}

p {
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 16px;
    line-height: 24px;
    color: rgba(113,120,126,1);
}

a {
    font-weight: 500;
    font-family: 'Roboto';
    font-size: 16px;
    line-height: 24px;
    color: rgba(0,174,239,1);
}

.sharedStyle {
    background-color: #DDDDDD;
    border: 1px solid #979797;
    box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.50);
    padding: 1rem;
}

.buttonPrimary {
    background-image: linear-gradient(90deg, #39B54A 0%, #34AA44 98%);
}

.basicSymbolTest {
    font-style: italic;
    font-weight: 400;
    font-family: 'Helvetica Neue';
    font-size: 24px;
    color: rgba(0,0,0,1);
}

.testBackground {
    background-color: #D8D8D8;
}

.testLinearBackground {
    background-image: linear-gradient(0deg, #B4EC51 0%, #429321 100%);
}

.testRadialBackground {
    background-image: radial-gradient(50% 44%, #3023AE 0%, #C86DD7 100%);
}

Based on 'test/source.sketch'

Image of Sketch file

Nested Symbol Support

Little demo of working with a semantic-ui-react Menu component... Check out the tests.sketch file to see the naming convention for nesting.

One line of "CSS"

.menuContainer.ui.menu {
    extends: sketch('./tests.sketch').symbol.deep.UIMenu;
}

Becomes the following (accurate) mess CSS

.menuContainer.ui.menu .item.active:hover {
    background-image: linear-gradient(0deg, #1991EB 0%, #2DA1F8 100%);
    text-align: left;
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 14px;
    color: rgba(255,255,255,1);
}

.menuContainer.ui.menu .item.active {
    background-image: linear-gradient(0deg, #1991EB 0%, #2DA1F8 100%);
    text-align: left;
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 14px;
    color: rgba(255,255,255,1);
}

.menuContainer.ui.menu .item:hover {
    background-image: linear-gradient(0deg, #1991EB 0%, #2DA1F8 100%);
    text-align: left;
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 14px;
    color: rgba(255,255,255,1);
}

.menuContainer.ui.menu .item {
    text-align: left;
    font-weight: 400;
    font-family: 'Roboto';
    font-size: 14px;
    color: rgba(53,64,82,1);
}

Try it?

Clone the package, yarn install, yarn dev, visit http://localhost:8080. Open tests.sketch. Have a play!

Use it? - Installation

yarn add postcss-sketch --dev - good luck :/ let me know how you go...

Add the plugin to your PostCSS configuration.

module.exports = (ctx) => ({
  plugins: [
    require("postcss-nesting")(),
    require("postcss-sketch")()
  ]
});

Bonus Feature!

One of the coolest things about using postcss with postcss-sketch is that once the bindings are setup, you can modify the sketch styles & design and watch your web app/site update in real-time using the magic of webpack, and webpack-dev-server.