GithubHelp home page GithubHelp logo

mohebifar / konsul Goto Github PK

View Code? Open in Web Editor NEW
617.0 8.0 27.0 3.62 MB

A react renderer for browser's dev console

Home Page: https://mohebifar.github.io/konsul/

JavaScript 100.00%
react console browser devtools

konsul's Introduction

Konsul Logo

Konsul is an abstraction of the browser's console that comes with a React renderer. It offers text styling, images, style inheritance, buttons with click interaction, etc. inside the browsers dev console.

See the live demo here

Travis npm js-semistandard-style

Usage

With react

Install konsul and react-konsul using npm:

npm install konsul react-konsul react

The following code demonstrates how you can use konsul with react.

import createKonsul from 'konsul';
import renderToKonsul from 'react-konsul';

// Create an instance of konsul
const konsul = createKonsul();

// Render react elements to the browser console!
renderToKonsul(<text style={{ color: 'red', fontWeight: 'bold' }}>Hello world!</text>, konsul);

This is what the result will look like:

Konsul "Hello world" example

See more examples here with the live demo.

React element types

text

This node is the only node type that accepts strings and numbers as children.

Prop Type Description
style TextStyle A plain javascript object whose keys are camel cased property names with their property value.
children `(Text string

image

A Konsul node for displaying images from a url.

Prop Type Description
style ImageStyle A plain javascript object whose keys are camel cased property names with their property value.
source string The URL of the image.

button

An interactive node that responds to clicks. Note that it only works on chrome for now.

Prop Type Description
onClick function Called when the user clicks on the element.
label string The label of the button. It will replace all the characters that are not acceptable for the name of a function with _.

group

All the children of a Group element will be wrapped inside console.group.

Prop Type Description
children Node[] All kind of elements except strings and numbers are accepted.

container

This node has no specific behaviour. It works as a container and renders all its children.

Prop Type Description
children Node[] All kind of elements except strings and numbers are accepted.

Without react

Install konsul via npm:

npm install konsul

The following code is the previous example but without react:

import createKonsul from 'konsul';

// Create an instance of konsul
const konsul = createKonsul();

// Create a text
const text = konsul.text({
  style: {
    color: 'red',
    fontWeight: 'bold'
  }
});

// Append a text to the text element
text.append('Hello world!');

// Append the text element to konsul
konsul.append(text);

// Render to console. The subsequent renders will occur automatically for example by updating the style or children.
konsul.render();

License

Released under the MIT License

konsul's People

Contributors

mamal72 avatar mohebifar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

konsul's Issues

Separate konsul and react-konsul

Hey. First of all, thanks for creating this project! This project is awesome; The idea is great! ๐Ÿ‘

Isn't it better to separate konsul and react-konsul projects in two git repositories?

Make it possible to use warn and error

It would be nice to have the possibility use console.warn and console.error as well so that we can filter the output in the console. So something like

renderToKonsul (<text type="error">Some error</text>)

Unable to load

I've been trying to get the demo app in /examples running, but I encounter this error:

Failed to compile.

Error in ../lib-react/lib/index.js
Module not found: 'react/lib/instantiateReactComponent' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/index.js 7:33-79

Error in ../lib-react/lib/index.js
Module not found: 'react/lib/ReactInstanceHandles' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/index.js 11:28-69

Error in ../lib-react/lib/index.js
Module not found: 'react/lib/ReactUpdates' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/index.js 15:20-53

Error in ../lib-react/lib/injection.js
Module not found: 'react/lib/ReactInjection' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/injection.js 8:22-57

Error in ../lib-react/lib/injection.js
Module not found: 'react/lib/ReactDefaultBatchingStrategy' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/injection.js 12:36-85

Error in ../lib-react/lib/injection.js
Module not found: 'react/lib/ReactComponentEnvironment' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/injection.js 16:33-79

Error in ../lib-react/lib/reconcileTransaction.js
Module not found: 'react/lib/CallbackQueue' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/reconcileTransaction.js 7:21-55

Error in ../lib-react/lib/reconcileTransaction.js
Module not found: 'react/lib/Transaction' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/reconcileTransaction.js 15:19-51

Error in ../lib-react/lib/reconcileTransaction.js
Module not found: 'react/lib/ReactUpdateQueue' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/reconcileTransaction.js 19:24-61

Error in ../lib-react/lib/ReactKonsulComponent.js
Module not found: 'react/lib/ReactMultiChild' in /Users/rgould/okgrow/konsul/lib-react/lib

 @ ../lib-react/lib/ReactKonsulComponent.js 7:23-59

It looks like lots of changes have been introduced in React since this package was written. For instance, it looks like ReactInjection was deleted here facebook/react@b0ccf62

That said, I would still expect it to work when given the explicit dependency on React 15.4.2, but that doesn't seem to be the case.

Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.