From e59095423e8164ad3674531ee96c4d0ca66fd500 Mon Sep 17 00:00:00 2001 From: Micha Hanselmann Date: Thu, 15 Aug 2019 15:37:37 -0700 Subject: [PATCH] docs: add exemplary fiddle for `launch in fiddle` feat (#19759) * add fit-screen * new url format * nit --- docs/api/screen.md | 2 +- docs/fiddles/screen/fit-screen/main.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 docs/fiddles/screen/fit-screen/main.js diff --git a/docs/api/screen.md b/docs/api/screen.md index 7d56da13b0ee..290a4a690d63 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -14,7 +14,7 @@ property, so writing `let { screen } = require('electron')` will not work. An example of creating a window that fills the whole screen: -```javascript +```javascript fiddle='docs/fiddles/screen/fit-screen' const { app, BrowserWindow, screen } = require('electron') let win diff --git a/docs/fiddles/screen/fit-screen/main.js b/docs/fiddles/screen/fit-screen/main.js new file mode 100644 index 000000000000..2320249cc506 --- /dev/null +++ b/docs/fiddles/screen/fit-screen/main.js @@ -0,0 +1,20 @@ +// Retrieve information about screen size, displays, cursor position, etc. +// +// For more info, see: +// https://electronjs.org/docs/api/screen + +const { app, BrowserWindow } = require('electron') + +let mainWindow = null + +app.on('ready', () => { + // We cannot require the screen module until the app is ready. + const { screen } = require('electron') + + // Create a window that fills the screen's available work area. + const primaryDisplay = screen.getPrimaryDisplay() + const { width, height } = primaryDisplay.workAreaSize + + mainWindow = new BrowserWindow({ width, height }) + mainWindow.loadURL('https://electronjs.org') +}) \ No newline at end of file