Skip to content

Commit b8b66ff

Browse files
committed
add mobile view
1 parent 2162154 commit b8b66ff

File tree

1 file changed

+68
-40
lines changed
  • client/modules/IDE/components/Editor

1 file changed

+68
-40
lines changed

client/modules/IDE/components/Editor/index.jsx

Lines changed: 68 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
colorPicker,
2727
wrapperClassName
2828
} from '@replit/codemirror-css-color-picker';
29-
29+
import MediaQuery from 'react-responsive';
3030
import prettier from 'prettier/standalone';
3131
import babelParser from 'prettier/parser-babel';
3232
import htmlParser from 'prettier/parser-html';
@@ -654,45 +654,73 @@ const Editor = (props) => {
654654
}, [props.file.content, theme]);
655655

656656
return (
657-
<section
658-
className={classNames('editor', { 'sidebar--contracted': !isExpanded })}
659-
>
660-
<div className="editor__header">
661-
<button
662-
aria-label={t('Editor.OpenSketchARIA')}
663-
className="sidebar__contract"
664-
onClick={collapseSidebar}
665-
>
666-
<LeftArrowIcon focusable="false" aria-hidden="true" />
667-
</button>
668-
<button
669-
aria-label={t('Editor.CloseSketchARIA')}
670-
className="sidebar__expand"
671-
onClick={expandSidebar}
672-
>
673-
<RightArrowIcon focusable="false" aria-hidden="true" />
674-
</button>
675-
<div className="editor__file-name">
676-
<span>
677-
{file.name}
678-
<UnsavedChangesIndicator />
679-
</span>
680-
<Timer />
681-
</div>
682-
</div>
683-
<div
684-
ref={editorRef}
685-
className={classNames('editor-holder', {
686-
'editor-holder--hidden': file.fileType === 'folder' || file.url
687-
})}
688-
/>
689-
<div id="color-picker" />
690-
{file.url ? <AssetPreview url={file.url} name={file.name} /> : null}
691-
<EditorAccessibility
692-
lintMessages={lintMessages}
693-
currentLine={currentLine}
694-
/>
695-
</section>
657+
<MediaQuery minWidth={770}>
658+
{(matches) =>
659+
matches ? (
660+
<section
661+
className={classNames('editor', {
662+
'sidebar--contracted': !isExpanded
663+
})}
664+
>
665+
<div className="editor__header">
666+
<button
667+
aria-label={t('Editor.OpenSketchARIA')}
668+
className="sidebar__contract"
669+
onClick={collapseSidebar}
670+
>
671+
<LeftArrowIcon focusable="false" aria-hidden="true" />
672+
</button>
673+
<button
674+
aria-label={t('Editor.CloseSketchARIA')}
675+
className="sidebar__expand"
676+
onClick={expandSidebar}
677+
>
678+
<RightArrowIcon focusable="false" aria-hidden="true" />
679+
</button>
680+
<div className="editor__file-name">
681+
<span>
682+
{file.name}
683+
<UnsavedChangesIndicator />
684+
</span>
685+
<Timer />
686+
</div>
687+
</div>
688+
<div
689+
ref={editorRef}
690+
className={classNames('editor-holder', {
691+
'editor-holder--hidden': file.fileType === 'folder' || file.url
692+
})}
693+
/>
694+
<div id="color-picker" />
695+
{file.url ? <AssetPreview url={file.url} name={file.name} /> : null}
696+
<EditorAccessibility
697+
lintMessages={lintMessages}
698+
currentLine={currentLine}
699+
/>
700+
</section>
701+
) : (
702+
<EditorContainer expanded={isExpanded}>
703+
<div>
704+
<IconButton onClick={expandSidebar} icon={FolderIcon} />
705+
<span>
706+
{file.name}
707+
<UnsavedChangesIndicator />
708+
</span>
709+
</div>
710+
<section>
711+
<EditorHolder ref={editorRef} />
712+
{file.url ? (
713+
<AssetPreview url={file.url} name={file.name} />
714+
) : null}
715+
<EditorAccessibility
716+
lintMessages={lintMessages}
717+
currentLine={currentLine}
718+
/>
719+
</section>
720+
</EditorContainer>
721+
)
722+
}
723+
</MediaQuery>
696724
);
697725
};
698726

0 commit comments

Comments
 (0)