Skip to content

Commit

Permalink
Add exit full page button (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
whscullin authored Nov 28, 2024
1 parent 4c33500 commit 1358e56
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apple2js.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
ondrop="Apple2.handleDrop(0, event)"
ondragend="Apple2.handleDragEnd(0, event)">
<div class="outer">
<div id="exit-fullscreen">
<button onClick="Apple2.exitFullScreen();">Exit Full Page</button>
</div>
<div id="header">
<a href="https://github.com/whscullin/apple2js#readme" target="_blank">
<img src="img/badge.png" id="badge" />
Expand Down
3 changes: 3 additions & 0 deletions apple2jse.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
ondrop="Apple2.handleDrop(0, event)"
ondragend="Apple2.handleDragEnd(0, event)">
<div class="outer">
<div id="exit-fullscreen">
<button onClick="Apple2.exitFullScreen();">Exit Full Page</button>
</div>
<div id="header">
<a href="https://github.com/whscullin/apple2js#readme" target="_blank">
<img src="img/badge2e.png" id="badge" />
Expand Down
14 changes: 14 additions & 0 deletions css/apple2.css
Original file line number Diff line number Diff line change
Expand Up @@ -810,3 +810,17 @@ a.button:hover {
min-width: 200px;
min-height: 50px;
}

#exit-fullscreen {
display: none;
}

.full-page #exit-fullscreen {
width: 100%;
position: fixed;
top: 0;
left: 0;
display: flex;
justify-content: center;
padding: 5px;
}
12 changes: 12 additions & 0 deletions js/components/Screen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { h, Ref } from 'preact';

import styles from './css/Screen.module.scss';
import { useContext } from 'preact/hooks';
import { OptionsContext } from './OptionsContext';
import { SCREEN_FULL_PAGE } from 'js/ui/screen';

/**
* Screen properties
Expand All @@ -17,8 +20,17 @@ export interface ScreenProps {
* @returns
*/
export const Screen = ({ screenRef }: ScreenProps) => {
const options = useContext(OptionsContext);

return (
<div className={styles.display}>
<div className={styles.exitFullScreen}>
<button
onClick={() => options.setOption(SCREEN_FULL_PAGE, false)}
>
Exit Full Page
</button>
</div>
<div className={styles.overscan}>
<canvas
className={styles.screen}
Expand Down
4 changes: 4 additions & 0 deletions js/components/css/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
border: none;
}

:global(.standalone) .header {
display: none;
}

:global(.full-page) .header {
display: none;
}
Expand Down
13 changes: 13 additions & 0 deletions js/components/css/Screen.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,16 @@
width: 100%;
height: 100%;
}

.exitFullScreen {
display: none;
}

:global(.full-page) .exitFullScreen {
width: 100%;
position: fixed;
top: 0;
display: flex;
justify-content: center;
padding: 5px;
}
4 changes: 4 additions & 0 deletions js/entry.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { h, render } from 'preact';
import { App } from './components/App';

if (navigator.standalone) {
document.body.classList.add('standalone');
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
render(<App />, document.getElementById('app')!);
6 changes: 5 additions & 1 deletion js/ui/apple2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export function doLoadHTTP(driveNo: DriveNumber, url?: string) {
}
})
.then(function (data) {
const urlParts = url!.split('/');
const urlParts = url.split('/');
const file = urlParts.pop()!;
const fileParts = file.split('.');
const ext = fileParts.pop()!.toLowerCase();
Expand Down Expand Up @@ -862,6 +862,10 @@ export function clearPrinterPaper() {
_printer.clear();
}

export function exitFullScreen() {
options.setOption(SCREEN_FULL_PAGE, false);
}

declare global {
interface Window {
clipboardData?: DataTransfer;
Expand Down

0 comments on commit 1358e56

Please sign in to comment.