Skip to content

Commit 51f5507

Browse files
authored
add toggle statusbar (codesandbox#2427)
* add toggle statusbar * replace with vscode id * toggle in old state management * work always
1 parent f4cb417 commit 51f5507

File tree

7 files changed

+27
-3
lines changed

7 files changed

+27
-3
lines changed

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ export const errorsCleared: Action = ({ state }) => {
355355
state.editor.errors = [];
356356
};
357357

358+
export const toggleStatusBar: Action = ({ state }) => {
359+
state.editor.statusBar = !state.editor.statusBar;
360+
};
361+
358362
export const projectViewToggled: Action = ({ state }) => {
359363
state.editor.isInProjectView = !state.editor.isInProjectView;
360364
};

packages/app/src/app/overmind/namespaces/editor/state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type State = {
5555
quickActionsOpen: boolean;
5656
previewWindowVisible: boolean;
5757
workspaceConfigCode: string;
58+
statusBar: boolean;
5859
previewWindowOrientation: WindowOrientation;
5960
isAllModulesSynced: Derive<State, boolean>;
6061
currentSandbox: Derive<State, Sandbox>;
@@ -103,6 +104,7 @@ export const state: State = {
103104
isUpdatingPrivacy: false,
104105
quickActionsOpen: false,
105106
previewWindowVisible: true,
107+
statusBar: true,
106108
previewWindowOrientation:
107109
window.innerHeight / window.innerWidth > 0.9
108110
? WindowOrientation.HORIZONTAL

packages/app/src/app/pages/Sandbox/Editor/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import getVSCodeTheme from './utils/get-vscode-theme';
1616

1717
const STATUS_BAR_SIZE = 22;
1818

19-
const AOverride = styled.div`
19+
const StatusBar = styled.div`
2020
a {
2121
color: inherit;
2222
}
@@ -68,6 +68,8 @@ class ContentSplit extends React.Component {
6868
const hideNavigation =
6969
store.preferences.settings.zenMode && store.workspace.workspaceHidden;
7070

71+
const statusBar = store.editor.statusBar;
72+
7173
const templateDef = sandbox && getTemplateDefinition(sandbox.template);
7274

7375
const topOffset = store.preferences.settings.zenMode ? 0 : 3 * 16;
@@ -99,6 +101,7 @@ class ContentSplit extends React.Component {
99101
top: topOffset,
100102
right: 0,
101103
bottom: bottomOffset,
104+
height: statusBar ? 'auto' : 'calc(100% - 3.5rem)',
102105
}}
103106
>
104107
<SplitPane
@@ -132,9 +135,10 @@ class ContentSplit extends React.Component {
132135
</SplitPane>
133136

134137
{vscode && (
135-
<AOverride
138+
<StatusBar
136139
style={{
137140
position: 'fixed',
141+
display: statusBar ? 'block' : 'none',
138142
bottom: 0,
139143
left: 0,
140144
right: 0,
@@ -146,7 +150,7 @@ class ContentSplit extends React.Component {
146150
className="part statusbar"
147151
id="workbench.parts.statusbar"
148152
/>
149-
</AOverride>
153+
</StatusBar>
150154
)}
151155
</div>
152156
</Fullscreen>

packages/app/src/app/store/modules/editor/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default Module({
4545
isUpdatingPrivacy: false,
4646
quickActionsOpen: false,
4747
previewWindowVisible: true,
48+
statusBar: true,
4849
previewWindowOrientation:
4950
window.innerHeight / window.innerWidth > 0.9 ? 'horizontal' : 'vertical',
5051
themes,
@@ -101,6 +102,7 @@ export default Module({
101102
prettifyClicked: sequences.prettifyCode,
102103
errorsCleared: sequences.clearErrors,
103104
projectViewToggled: sequences.toggleProjectView,
105+
toggleStatusBar: sequences.toggleStatusBar,
104106
previewActionReceived: sequences.handlePreviewAction,
105107
privacyUpdated: sequences.updatePrivacy,
106108
frozenUpdated: sequences.updateFrozen,

packages/app/src/app/store/modules/editor/model.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,5 @@ export default {
214214
tabPosition: types.number,
215215
}),
216216
workspaceConfigCode: types.string,
217+
statusBar: types.boolean,
217218
};

packages/app/src/app/store/modules/editor/sequences.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const openQuickActions = set(state`editor.quickActionsOpen`, true);
2929

3030
export const closeQuickActions = set(state`editor.quickActionsOpen`, false);
3131

32+
export const toggleStatusBar = toggle(state`editor.statusBar`);
33+
3234
export const toggleProjectView = toggle(state`editor.isInProjectView`);
3335

3436
const hasEnoughTabs = when(state`editor.tabs`, tabs => tabs.length > 1);

packages/app/src/app/vscode/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ class VSCodeManager {
5151
}
5252

5353
private addWorkbenchActions() {
54+
this.addWorkbenchAction({
55+
id: 'workbench.action.toggleStatusbarVisibility',
56+
label: 'Toggle Status Bar Visibility',
57+
commandLabel: 'Toggle Status Bar Visibility',
58+
category: 'View',
59+
run: () => {
60+
this.controller.getSignal('editor.toggleStatusBar')();
61+
},
62+
});
5463
this.addWorkbenchAction({
5564
id: 'view.preview.flip',
5665
label: 'Flip Preview Layout',

0 commit comments

Comments
 (0)