From 97b2a85d490ef48d8927328ceeaba5bdc1ffb7a0 Mon Sep 17 00:00:00 2001 From: lakshay-jainn Date: Tue, 18 Feb 2025 21:52:10 +0530 Subject: [PATCH] fix: mobileview: cant switch tab between code and preview tab --- .../IDE/components/ShowOutputButton.jsx | 28 +++++++++++++++++++ .../components/ShowOutputButton.stories.jsx | 8 ++++++ client/modules/IDE/pages/IDEView.jsx | 19 +++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 client/modules/IDE/components/ShowOutputButton.jsx create mode 100644 client/modules/IDE/components/ShowOutputButton.stories.jsx diff --git a/client/modules/IDE/components/ShowOutputButton.jsx b/client/modules/IDE/components/ShowOutputButton.jsx new file mode 100644 index 000000000..396b9bff9 --- /dev/null +++ b/client/modules/IDE/components/ShowOutputButton.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import styled from 'styled-components'; +import PropTypes from 'prop-types'; +import { prop } from '../../../theme'; + +const Button = styled.button` + width: 90%; + margin: 10px auto; + z-index: 4; + padding: 1rem; + border-radius: 100px; + align-items: center; + color: #ffffff !important; + ${prop('Button.secondary.default')}; +`; + +const ShowOutputButton = ({ showOutput, setShowOutput }) => ( + +); + +ShowOutputButton.propTypes = { + showOutput: PropTypes.bool.isRequired, + setShowOutput: PropTypes.func.isRequired +}; + +export default ShowOutputButton; diff --git a/client/modules/IDE/components/ShowOutputButton.stories.jsx b/client/modules/IDE/components/ShowOutputButton.stories.jsx new file mode 100644 index 000000000..5c6e09bf2 --- /dev/null +++ b/client/modules/IDE/components/ShowOutputButton.stories.jsx @@ -0,0 +1,8 @@ +import ShowOutputButton from './showOutputButton'; + +export default { + title: 'IDE/ShowOutputButton', + component: ShowOutputButton +}; + +export const Default = {}; diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 4084facb7..a07c6ed2b 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -20,6 +20,7 @@ import { getIsUserOwner } from '../selectors/users'; import RootPage from '../../../components/RootPage'; import Header from '../components/Header'; import FloatingActionButton from '../components/FloatingActionButton'; +import ShowOutputButton from '../components/showOutputButton'; import Editor from '../components/Editor'; import { EditorSidebarWrapper, @@ -102,6 +103,7 @@ const IDEView = () => { const [consoleSize, setConsoleSize] = useState(150); const [sidebarSize, setSidebarSize] = useState(160); + const [showOutput, setShowOutput] = useState(false); const [isOverlayVisible, setIsOverlayVisible] = useState(false); const [MaxSize, setMaxSize] = useState(window.innerWidth); @@ -114,6 +116,13 @@ const IDEView = () => { dispatch(updateFileContent(file.id, file.content)); }; + useEffect(() => { + if (ide.isPlaying) { + setShowOutput(true); + } else { + setShowOutput(false); + } + }, [ide.isPlaying]); useEffect(() => { dispatch(clearPersistedState()); }, [dispatch]); @@ -182,7 +191,11 @@ const IDEView = () => { syncFileContent={syncFileContent} offsetBottom={ide.isPlaying ? currentConsoleSize : 0} /> - + + { > - + {