0.1.5 • Published 1 year ago

@code-ui/docstring v0.1.5

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
1 year ago

npm.io

@code-ui/docstring

ui controls seamlessly embedded in docstring style block

What is it?

npm.io

Installation

yarn add @code-ui/docstring
# or with npm
npm i @code-ui/docstring

Simple Usage

import DocstringView from "@code-ui/docstring";

<DocstringView
  lang={"jsx"} // defaults to js - "js" | "dart" | "paython" | LanguageConfig
  style={"monokai"} // default style = monokai
  padding={"10px"} // code wrapper padding
  controls={[
      platform_field,
      lang_field,
  ]}
  expandableConfig={
      lines: 2,
      expandable: true
  }
  onChange={(field, value) => {
      setField(field,value)
  }}
/>;

Comlex Example

creating field

let lang = "tsx";

const onLangChange = (v) => {
    lang = v
}

const lang_field  = {
    tag: "@"
    name: "lang",
    template?: `{{ tag }}{{ name }}{{ option.name }}`
    options: [
        {
            name: "Javascript",
            value: "platform.javascript",
            description: "javascript",
        }
    ]
}

const platform_field  = {
    tag: "@"
    name: "platform",
    template: `{{ tag }}{{ name }}{{ value }} (juice.${lang})`
    options: [
        {
            name: "Flutter",
            value: "platform.flutter",
            description: "flutter",
        }
    ]
}

Props

interface Option<T> {
  name: string;
  value: T;
  desc?: string;
}

interface Field<T = string> {
  tag: "@" | "";
  name: string;
  template?: string;
  enabled?: boolean;
  options?: Option<T>[];
}
0.1.1

1 year ago

0.1.5

1 year ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago