1 | import React from 'react';
|
2 | import {storiesOf} from '@storybook/html';
|
3 |
|
4 | import reactDecorator from '../../.storybook/react-decorator';
|
5 | import Code, {code} from '../code/code';
|
6 |
|
7 | storiesOf('Components|Code', module).
|
8 | addParameters({
|
9 | notes: `
|
10 | Displays a block of code. Syntax highlighting is available by default for the following languages: _cpp, xml, bash, clojure, coffeescript, cs, css, markdown, dockerfile, elixir, elm, ruby, erlang, glsl, go, gradle, groovy, handlebars, haskell, ava, javascript, json, kotlin, less, livescript, lua, makefile, perl, php, powershell, python, r, rust, scala, scss, shell, sql, swift, yaml, twig, typescript_.
|
11 |
|
12 | Highlighting of other languages is available as well:
|
13 |
|
14 | \`import {highlight} from '@jetbrains/ring-ui/components/code/code'\`
|
15 |
|
16 | \`import 1c from 'highlight.js/lib/languages/1c';\`
|
17 |
|
18 | \`highlight.registerLanguage('1c', 1c);\`
|
19 | `
|
20 | }).
|
21 | addDecorator(reactDecorator()).
|
22 | add('basic', () => (
|
23 | <Code
|
24 | code={`
|
25 | import React, {Component} from 'react';
|
26 | import ChildComponent from './child-component';
|
27 |
|
28 | const MyComponent = () => (
|
29 | <div className="class">
|
30 | <ChildComponent prop="value" />
|
31 | </div>
|
32 | );
|
33 | `}
|
34 | />
|
35 | )).
|
36 | add('tagged template', () => (
|
37 | code`
|
38 | import React from 'react';
|
39 | import {code} from '@jetbrains/ring-ui/components/code/code';
|
40 |
|
41 | const el = code\`some('js')\`;
|
42 | `
|
43 | ), {
|
44 | hermione: {skip: true}
|
45 | });
|