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

syntacks

v2.1.9

Published

<img src='http://i.imgur.com/sRlENh2.jpg'/>

Downloads

10

Readme

Dependency free syntax highlighter for react.

The component is scaled 100% wide and 100% high relative to the div .wrapper which contains it. This allows for a full customization for height, width and other things such as transitions and box shadows.

Download via npm: https://www.npmjs.com/package/syntacks

npm install syntacks

Demo: https://git.io/vQ9Nj

Upload/browse themes: https://goo.gl/iUrPZ7

Installation

Copy the file your download like so...

Import it into your file...

Add your syntack box...

And you're done :) :+1:

Current Themes

Default themes are found here https://git.io/vQ9Nj and user uploaded custom themes here https://goo.gl/iUrPZ7

Creating custom themes

To create or use custom themes, all you have to do is define one with its properties like so. The parameters follow the below template.

/*
  > color
  > bgColor
  > spineColor
  > quotesColor
  > conditionColor
  > globalsColor
  > standardMethodsColor
  > specialMethodsColor
  > commentColor
*/

Defining template and its theme.

import { Syntack, SyntackThemes } from '../syntack/syntack.js';

const myCoolTheme = new SyntackThemes(
    'rgb(255, 255, 255)',
    'rgb(41, 43, 57)',
    'rgb(29, 31, 42)',
    'rgb(138, 154, 181)',
    'rgb(47, 162, 124)',
    'rgb(203, 89, 192)',
    'rgb(230, 28, 26)',
    'rgb(174, 95, 230)',
    'rgb(67, 135, 153)'
);

/* Note: Don't get confused,
* you don't need to specifically
* use rgb it's just what I am using in this example. */

Adding and compling your theme.

// Use the customTheme prop instead of the default, theme.
<Syntack customTheme={myCoolTheme.compiled()} code={myCode}/>

It works!

Real time editor /w syntax

In order to create an input into the syntack component we just have to use some super simple vanilla react.

import React, {Component} from 'react';
import {Syntack} from '../syntack/syntack.js';

class myComponent extends Component {
  constructor(props) {
    super(props)
    this.state = { editedCode: ''};
  }
  handleCode(e) {
    this.setState({editedCode: e.target.value});
  }
  render() {
    const SyntaxOutput = {
      "width":"500px",
      "height":"350px",
      "position":"absolute",
      "transform":"translate(-50%, -50%)",
      "left":"50%",
      "top":"40%"
    };


    const defaultInput = {
      "width":"500px",
      "height":"200px",
      "position":"absolute",
      "transform":"translate(-50%, -50%)",
      "left":"50%",
      "top":"80%"
    };

    return(
        <div>
          <div style={SyntaxOutput}>
            <Syntack theme='github' code={this.state.editedCode}/>
          </div>
          <textarea onChange={e => this.handleCode(e)} style={defaultInput} />
        </div>
      );
    )
  }
}