import * as React from 'react'; import './CodeBox.css'; import {filter, Render} from '../../render/index'; import {Tooltip} from '@native-ads/antd'; import {HighLight} from '../common/HighLight'; let unExpand = require('./img/unExpand.svg'); let expanded = require('./img/expanded.svg'); // test only function toUpperCase(word: string) { return word.toUpperCase(); } filter.setFilter('toUpperCase', toUpperCase); export interface CodeBoxPropsInterface { title: string; desc: string; code: string; language: string; mode?: string; } export interface CodeBoxStateInterface { expand: boolean; } export class CodeBox extends React.Component { constructor(props: CodeBoxPropsInterface) { super(props); this.state = { expand: false }; this.handleClick = this.handleClick.bind(this); } render() { const global = { text: 'this is global value', proxy: location.origin + '/proxy' }; return (
{this.props.title &&
{this.props.title}
} { this.props.desc &&
}
{this.props.code.trim()}
); } private handleClick() { this.setState({ expand: !this.state.expand }); } }