0.2.0 • Published 4 years ago

react-code-space v0.2.0

Weekly downloads
31
License
MIT
Repository
-
Last release
4 years ago

React Code Space

React Code Space is a stylized code syntax highlighter for your documentation/ lesson building.

npm.io npm.io

Code

Code is the base import. It will recieve the below compound components for formatting your code.

import Code from 'react-code-space';

function App() {
  return <Code></Code>;
}

export default App;

Code props

NameDescriptionOptionsUsage
languagesets the language of the code spacejavascript, jsx, css, scss, html<Code language="jsx">
darkset the type of code space to darkdefault is true<Code dark>
lightset the type of code space to lightdefault is true<Code light>
themeset the syntax theme of the code spacematerial, monokai, xonokai<Code theme="monokai">
iconadds an icon of the language. default is language.react, javascript, css, scss, html<Code icon>, <Code icon="css"/>
shadowadds a shadow to the code spacedefault is true<Code shadow>
neomorphadds a neomorphism design effect to the code space.default is true<Code neomorph>
roundedadds a border radius to the code spacedefault is true<Code rounded>

Code Header

Header can recieve any child and output it in a small container within the Code Space;

import Code from 'react-code-space';

function App() {
  return (
    <Code dark theme='material' language='javascript'>
      <Code.Header>A lovely Header!</Code.Header>
    </Code>
  );
}

export default App;

Code Body

Body is the syntax highlighting portion of the code space. This allows multiple code blocks within a code space.

import Code from 'react-code-space';

const codeString = '//Your code here!';

function App() {
  return (
    <Code dark theme='material' language='javascript'>
      <Code.Header>A lovely Header!</Code.Header>
      <Code.Body content={codeString} />
    </Code>
  );
}

export default App;

Body Props

NameDescriptionOptionsUsage
contentrecieves a string of code to displaya string<Code.Body content={codeString} />
numberedadds line numbers to code outputdefault is true<Code.Body numbered/>
startstarting point for line numbersdefault is 1. Will recieve any number<Code.Body numbered start={17}/>
highlightaccepts string numbers to highlight lines of codestring of line numbers. will accept ranges<Code.Body highlight={"4"} />,<Code.Body content={"4,8-11,16"} />
collapsablemakes the code body an animated dropdowndefault is true<Code.Body collapsable />
collapsableTextsets the text for the animated dropdowna string<Code.Body collapsableText={"Here is the code!"} />
copyadds a copy to clipboard functionalitydefault is true<Code.Body copy />
bluradds a blurred effect to reveal on hoverdefault is true<Code.Body blur />

Code Doc

Doc is an embedded slot in the code space to add detailed text inline with the code space.

import Code from 'react-code-space';

const codeString = '//Your code here!';

function App() {
  return (
    <Code dark theme='material' language='javascript'>
      <Code.Header>A lovely Header!</Code.Header>
      <Code.Body content={codeString} />
      <Code.Doc>Some simple text explaining the code above or below.</Code.Doc>
    </Code>
  );
}

export default App;

Code Divider

Divider is a simple split to seperate the code blocks with a themed horizontal rule. This can also be styled with three dots with the dots property.

Divider Props

NameDescriptionOptionsUsage
dotschanges the style to three dotsdefault is true<Code.Divider dots/>