Skip to content

Add full-screen button for Playground side content #2911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@blueprintjs/icons": "^5.5.0",
"@blueprintjs/popover2": "^2.0.0",
"@blueprintjs/select": "^5.0.0",
"@mantine/hooks": "^7.7.0",
"@octokit/rest": "^20.0.0",
"@reduxjs/toolkit": "^1.9.7",
"@sentry/browser": "^7.57.0",
Expand Down
21 changes: 20 additions & 1 deletion src/commons/workspace/Workspace.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { FocusStyleManager } from '@blueprintjs/core';
import { Icon } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { useFullscreen } from '@mantine/hooks';
import { Enable, NumberSize, Resizable, ResizableProps, ResizeCallback } from 're-resizable';
import { Direction } from 're-resizable/lib/resizer';
import React from 'react';
Expand Down Expand Up @@ -187,6 +190,15 @@ const Workspace: React.FC<WorkspaceProps> = props => {
</Resizable>
);

// This is a custom hook imported from @mantine/hooks that handles the fullscreen logic
// It returns a ref to attach to the element that should be fullscreened,
// a function to toggle fullscreen and a boolean indicating whether the element is fullscreen
const {
ref: fullscreenRef,
toggle: toggleFullscreen,
fullscreen: isFullscreen
} = useFullscreen<HTMLDivElement>();

return (
<div className="workspace">
<Prompt
Expand All @@ -206,7 +218,14 @@ const Workspace: React.FC<WorkspaceProps> = props => {
<div className="row content-parent" ref={contentContainerDiv}>
<div className="editor-divider" ref={editorDividerDiv} />
<Resizable {...editorResizableProps()}>{createWorkspaceInput(props)}</Resizable>
<div className="right-parent">
<div className="right-parent" ref={fullscreenRef}>
<Icon
id="fullscreen-button"
icon={isFullscreen ? IconNames.MINIMIZE : IconNames.MAXIMIZE}
color="white"
htmlTitle={isFullscreen ? 'Exit full screen' : 'Full screen'}
onClick={toggleFullscreen}
/>
{props.sideContentIsResizeable === undefined || props.sideContentIsResizeable
? resizableSideContent
: sideContent}
Expand Down
8 changes: 8 additions & 0 deletions src/styles/_workspace.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ $code-color-notification: #f9f0d7;
height: 100%;
padding-bottom: 0.6rem;
overflow: auto;

#fullscreen-button {
position: absolute;
right: 8px;
padding: 5px;
cursor: pointer;
z-index: 100;
}
}

.left-parent {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,11 @@
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==

"@mantine/hooks@^7.7.0":
version "7.7.1"
resolved "https://registry.yarnpkg.com/@mantine/hooks/-/hooks-7.7.1.tgz#04fd8999fe109615d064bf42a8ff04435c93b927"
integrity sha512-3YH2FzKMlg840tb04PBDcDXyBCi9puFOxEBVgc6Y/pN6KFqfOoAnQE/YvgOtwSNXZlbTWyDlQoYj+3je7pA7og==

"@mapbox/node-pre-gyp@^1.0.0":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz#8e6735ccebbb1581e5a7e652244cadc8a844d03c"
Expand Down