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

hydra-ide

v0.1.6

Published

Monaco Editor for React with some super powers

Downloads

20

Readme

Hydra IDE

Hydra IDE is simplified code IDE component based on monaco editor for React apps. It has no dependencies as you have to install them yourself inside your project.

Installation in React project

npm i hydra-ide

Install peer dependencies

npm i react react-dom monaco-editor

and install peer development dependencies. It usese webpack to add worker with monaco inside.

npm i -D webpack monaco-editor-webpack-plugin worker-loader file-loader css-loader

add monaco plugin to webpack.

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
  plugins: [
    new MonacoWebpackPlugin({
      // https://github.com/Microsoft/monaco-editor-webpack-plugin#options
      // Add your languages here
      languages: ['javascript'],
    }),
  ],
};

You can check exact webpack configuration in sandbox folder.

How to use?

React Element Props

| Property | type | required | Description | | ---------------------- | ------------------------------------------------------ | -------- | ------------------------------------------------------------------------------ | | value | string | true | current code as string | | setValue | (value:string) => void | true | triggered when editor sets the value | | setValueOnBlur | (value:string) => void | false | triggered when editor sets the value on blur | | className | string | false | class name | | style | React.CSSProperties | false | style properties | | theme | monaco.editor.IStandaloneThemeData | true | monaco editor theme | | editorOptions | monaco.editor.IStandaloneEditorConstructionOptions | true | monaco editor options | | depsToObserveForResize | React.DependencyList | false | dependency list same as in useEffect hook. Used to automatically resize editor | | onMonaco | (editor: monaco.editor.IStandaloneCodeEditor) => void; | false | when monaco is mounted it will be passed here |

import React, { useState } from 'react';
import HydraIDE from 'hydra-ide';
import { darken, lighten, toHex } from 'color2k';

export const Colors = {
  grey: '#F3F3F4',
  main: '#d966ff',
  green: '#acf7c1',
  yellow: '#cfee9e',
  red: '#de3c4b',
  orange: '#f18f01',
  pink: '#e6bccd',
  blue: '#17bebb',
  sky: '#A3E7FC',
} as const;

export const Main = () => {
  const [value, setValue] = useState('');

  return (
    <div style={{ height: `100%`, width: '100%' }}>
      <HydraIDE
        editorOptions={{
          language: 'javascript',
        }}
        theme={{
          base: 'vs-dark',
          inherit: true,
          rules: [
            {
              token: 'comment.js',
              foreground: toHex(darken(Colors.grey, 0.5)),
            },
            { token: 'keyword.js', foreground: Colors.main },
            { token: 'number.js', foreground: Colors.green },
            { token: 'string.js', foreground: Colors.sky },
            {
              token: 'identifier.js',
              foreground: toHex(darken(Colors.sky, 0.21)),
            },
            {
              token: 'type.identifier.js',
              foreground: toHex(lighten(Colors.sky, 0.1)),
            },
          ],
          colors: {
            'editor.foreground': Colors.sky,
            'editor.background': toHex(darken(Colors.main, 0.63)),
            'minimap.background': toHex(darken(Colors.main, 0.64)),
          },
        }}
        setValue={setValue}
        value={value}
      />
    </div>
  );
};

Develop

To run sandbox environment clone this repo, install deps and run start.

npm run start

Roadmap

  • easier token adding
  • easier color customization