1.0.15 • Published 7 months ago

@jswork/react-codeflask v1.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

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: ()
  2. 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.

1.0.11

7 months ago

1.0.10

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago