diff --git a/src/features/stories/storiesComponents/SourceBlock.tsx b/src/features/stories/storiesComponents/SourceBlock.tsx index 678669cf55..0daf0c921b 100644 --- a/src/features/stories/storiesComponents/SourceBlock.tsx +++ b/src/features/stories/storiesComponents/SourceBlock.tsx @@ -1,8 +1,11 @@ import { Card, Classes } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; import React, { useEffect, useRef, useState } from 'react'; import AceEditor from 'react-ace'; import { useDispatch } from 'react-redux'; import { styliseSublanguage } from 'src/commons/application/ApplicationTypes'; +import { ControlBarRunButton } from 'src/commons/controlBar/ControlBarRunButton'; +import ControlButton from 'src/commons/ControlButton'; import { SideContentTab, SideContentType } from 'src/commons/sideContent/SideContentTypes'; import Constants from 'src/commons/utils/Constants'; import { useTypedSelector } from 'src/commons/utils/Hooks'; @@ -45,7 +48,6 @@ const SourceBlock: React.FC = props => { const dispatch = useDispatch(); const [code, setCode] = useState(props.children); const [outputIndex, setOutputIndex] = useState(Infinity); - const [sideContentHidden, setSideContentHidden] = useState(true); const [selectedTab, setSelectedTab] = useState(SideContentType.introduction); const envList = useTypedSelector(store => Object.keys(store.stories.envs)); @@ -216,27 +218,26 @@ const SourceBlock: React.FC = props => { // to handle environment reset useEffect(() => { if (output.length === 0) { - console.log('setting to infinity'); setOutputIndex(Infinity); } - setOutputIndex(output.length); }, [output]); selectMode(chapter, variant, ExternalLibraryName.NONE); - console.log(outputIndex); - console.log(output); - return (
- - + +

{env === DEFAULT_ENV ? chapterVariantDisplay : env + ' | ' + chapterVariantDisplay}

-
+
= props => { height="1px" width="100%" value={code} - onChange={code => { - setCode(code); - }} + onChange={code => setCode(code)} commands={[ { name: 'evaluate', @@ -277,12 +276,7 @@ const SourceBlock: React.FC = props => { ) : null}
- -
+
diff --git a/src/features/stories/storiesComponents/StoriesSideContent.tsx b/src/features/stories/storiesComponents/StoriesSideContent.tsx index 4066b1806c..5fa310b06b 100644 --- a/src/features/stories/storiesComponents/StoriesSideContent.tsx +++ b/src/features/stories/storiesComponents/StoriesSideContent.tsx @@ -1,6 +1,8 @@ import { Card, Icon, Tab, TabProps, Tabs } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; import { Tooltip2 } from '@blueprintjs/popover2'; import * as React from 'react'; +import ControlButton from 'src/commons/ControlButton'; import GenericSideContent, { generateIconId, @@ -27,7 +29,11 @@ const generateClassName = (id: string | undefined) => ? 'side-content-tooltip side-content-tab-alert' : 'side-content-tooltip'; -const renderTab = (tab: SideContentTab, workspaceLocation?: WorkspaceLocation) => { +const renderTab = ( + tab: SideContentTab, + isHidden: boolean, + workspaceLocation?: WorkspaceLocation +) => { const iconSize = 20; const tabId = tab.id === undefined || tab.id === SideContentType.module ? tab.label : tab.id; const tabTitle = ( @@ -59,15 +65,17 @@ const renderTab = (tab: SideContentTab, workspaceLocation?: WorkspaceLocation) = : tab.body; const tabPanel: JSX.Element =
{tabBody}
; - return ; + return ; }; // TODO: Reduce code duplication with the main SideContent component const StoriesSideContent: React.FC = ({ selectedTabId, renderActiveTabPanelOnly, + // isHidden, ...otherProps }) => { + const [isHidden, setIsHidden] = React.useState(true); return ( = ({
{ + setIsHidden(false); + changeTabsCallback(newTabId, prevTabId, e); + }} renderActiveTabPanelOnly={renderActiveTabPanelOnly} selectedTabId={selectedTabId} > - {dynamicTabs.map(tab => renderTab(tab, otherProps.workspaceLocation))} + {dynamicTabs.map(tab => renderTab(tab, isHidden, otherProps.workspaceLocation))} + {dynamicTabs.length ? ( + setIsHidden(!isHidden)} + icon={isHidden ? IconNames.EYE_OPEN : IconNames.EYE_OFF} + /> + ) : undefined}
diff --git a/src/styles/_stories.scss b/src/styles/_stories.scss index 85c5df2efd..53bd96a66a 100644 --- a/src/styles/_stories.scss +++ b/src/styles/_stories.scss @@ -2,32 +2,6 @@ .#{$ns}-card { background-color: $cadet-color-2; padding: 0.4rem 0.6rem 0.4rem 0.6rem; - margin: 0 0 0.5rem 0; - - pre { - background-color: transparent; - box-shadow: none; - color: inherit; - padding: 0px; - margin: 0px; - /** - * white-space, word-wrap and word-break - * are specified to allow all output to wrap. - */ - white-space: pre-wrap; - word-wrap: break-word; - word-break: break-word; - /** - * Use same fonts as ace-editor for - * output. Taken from react-ace - * sourcecode, font size modified. - */ - font: 16px / normal 'Inconsolata', 'Consolas', monospace; - } - - .variantChapText { - color: #ced9e0; - } } }