@jswork/react-codeflask
TypeScript icon, indicating that this package has built-in type declarations

1.0.15 • Public • Published

react-codeflask

A micro code-editor for awesome web pages.

version license size download

installation

npm install -S @jswork/react-codeflask

usage

  1. import css
@import "~@jswork/react-codeflask/dist/style.css";

// or use sass
@import "~@jswork/react-codeflask/dist/style.scss";

// customize your styles:
$react-codeflask-options: ()
  1. import js
import React, { useState } from 'react';
import ReactCodeflask from '@jswork/react-codeflask';
import '../../src/components/style.scss';
import styled from 'styled-components';
// import 'prismjs/themes/prism.css';

const Container = styled.div`
  width: 80%;
  margin: 30px auto 0;

  > .is-actions {
    margin-top: 10px;
  }
`;

export default () => {
  const [val, setVal] = useState(
    `curl 'https://api.cdnjs.com/libraries/backbone.js/tutorials/this-tutorial-doesnt-exist' | json`
  );
  return (
    <Container>
      <ReactCodeflask
        value={val}
        height={0}
        language="js"
        onChange={(e) => {
          // console.log('current value:', e.target.value);
          setVal(e.target.value);
        }}
      />

      <div className="is-actions">
        <button
          onClick={(e) => {
            setVal('const for="bar"; \nlet bar="bc";');
          }}>
          Set value.
        </button>
      </div>
    </Container>
  );
};

preview

license

Code released under the MIT license.

Package Sidebar

Install

npm i @jswork/react-codeflask

Homepage

js.work

Weekly Downloads

0

Version

1.0.15

License

MIT

Unpacked Size

15.1 kB

Total Files

8

Last publish

Collaborators

  • afeiship