Socket
Book a DemoInstallSign in
Socket

syntacks

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syntacks

2.1.9
latest
Source
npmnpm
Version published
Weekly downloads
6
20%
Maintainers
1
Weekly downloads
 
Created
Source

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>
      );
    )
  }
}

Keywords

syntax

FAQs

Package last updated on 16 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.