2019-03-01 13:46:29 +00:00
|
|
|
import React, { useState } from 'react';
|
2018-11-06 03:57:51 +00:00
|
|
|
import CodePreview from './CodePreview';
|
|
|
|
import TerminalPreview from './TerminalPreview';
|
|
|
|
import Tabs from './Tabs';
|
2018-12-20 04:00:18 +00:00
|
|
|
import styles from './TextPreviews.module.css';
|
2018-11-06 03:57:51 +00:00
|
|
|
|
2019-03-01 13:46:29 +00:00
|
|
|
export default () => {
|
|
|
|
const [activePreview, setActivePreview] = useState('code');
|
2018-11-06 03:57:51 +00:00
|
|
|
|
2019-03-01 13:46:29 +00:00
|
|
|
return (
|
|
|
|
<Tabs>
|
|
|
|
{ ({ tabClassName, getTabStyle, contentClassName, contentStyle }) => (
|
|
|
|
<div className={ styles.wrapper }>
|
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
className={ tabClassName }
|
|
|
|
style={ getTabStyle(activePreview === 'code') }
|
2020-06-18 14:07:27 +00:00
|
|
|
onClick={ () => {
|
|
|
|
setActivePreview('code');
|
|
|
|
window.__ssa__log('change active preview', { preview: 'code' });
|
|
|
|
} }
|
2019-03-01 13:46:29 +00:00
|
|
|
>Code</button>
|
|
|
|
<button
|
|
|
|
className={ tabClassName }
|
|
|
|
style={ getTabStyle(activePreview === 'terminal') }
|
2020-06-18 14:07:27 +00:00
|
|
|
onClick={ () => {
|
|
|
|
setActivePreview('terminal');
|
|
|
|
window.__ssa__log('change active preview', { preview: 'terminal' });
|
|
|
|
} }
|
2019-03-01 13:46:29 +00:00
|
|
|
>Terminal</button>
|
2018-11-24 18:29:07 +00:00
|
|
|
</div>
|
2019-03-01 13:46:29 +00:00
|
|
|
<div className={ contentClassName } style={ contentStyle }>
|
|
|
|
{ activePreview === 'code' ? (
|
|
|
|
<CodePreview />
|
|
|
|
) : null }
|
|
|
|
{ activePreview === 'terminal' ? (
|
|
|
|
<TerminalPreview />
|
|
|
|
) : null }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
</Tabs>
|
|
|
|
);
|
2018-11-06 03:57:51 +00:00
|
|
|
}
|