From c1314da941d09bcce51570accc3ed7c5c12c2f15 Mon Sep 17 00:00:00 2001 From: Rich Boakes Date: Wed, 27 Sep 2023 09:14:49 +0100 Subject: [PATCH] help button and modal dialog --- i/help.svg | 7 +++++++ index.html | 17 ++++++++++++++++- script.js | 16 ++++++++++++++-- styles.css | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 i/help.svg diff --git a/i/help.svg b/i/help.svg new file mode 100644 index 0000000..ff5db3d --- /dev/null +++ b/i/help.svg @@ -0,0 +1,7 @@ + + + Help + + + + \ No newline at end of file diff --git a/index.html b/index.html index 94307cb..3913923 100644 --- a/index.html +++ b/index.html @@ -16,9 +16,10 @@

edit

- +

edit

+ help

Key Partners

@@ -35,3 +36,17 @@

Designed by: Strategyzer AG & Steve Blank. Built for the web at Uni. of Portsmouth. + +

+

Using the Mission Model Canvas.

+

The MMC comprises nine sections ("Key Partners", "Key Activities", etc). +

Editing

+

Click a section to begin editing it: a highlight will appear and you'll see a flashing caret where you can enter text. +

Click outside a section or press Escape to stop editing. +

Defocusing

+

Shift-click a section to defocus it (it will blend more into the background). +

Type in any defocused area will automatically refocus it. +

Reset

+

Ctrl+Escape opens a dialog that will allow you to remove all your text from the page.

+ +
diff --git a/script.js b/script.js index 19d300c..b3ec521 100644 --- a/script.js +++ b/script.js @@ -89,7 +89,7 @@ function handleFragment() { function keyboardHandler(event) { if (event.ctrlKey && event.key === 'Escape') { - const confirmed = confirm('Are you sure you want to reset the page?'); + const confirmed = confirm('Are you sure you want to remove all text from this page?'); if (confirmed) { for (const element of el.editableElements) { element.innerHTML = ''; @@ -111,6 +111,7 @@ function keyboardHandler(event) { function prep() { el.gridItems = document.querySelectorAll('.grid-item'); el.editableElements = document.querySelectorAll('[contenteditable]'); + el.help = document.querySelector('#help'); loadContent(); @@ -123,7 +124,18 @@ function prep() { for (const element of el.editableElements) { element.addEventListener('input', saveContent); } - + + el.help.addEventListener('click', openUsageDialog); + + +} + +function openUsageDialog() { + const dialog = document.querySelector('#usage'); + dialog.showModal(); + dialog.addEventListener('click', () => { + dialog.remove(); + }); } window.addEventListener('load', prep); diff --git a/styles.css b/styles.css index 293943b..7ae2486 100644 --- a/styles.css +++ b/styles.css @@ -155,4 +155,52 @@ h2 img { .grid-item:has(*:focus) { box-shadow: inset 0 0 1em #F0F7; +} + +dialog { + margin: auto; + padding: 2em; + display: flex; + flex-direction: column; +} + +dialog p { + padding-block-start: 0.3em; +} + +dialog h2 { + padding-block-start: 2em; +} + + +dialog::backdrop { + background: repeating-linear-gradient( + 45deg, + #009EE277, + #62136077, + #0076A677, + #3C023877 + ); + } + +dialog button { + align-self: flex-end; + padding: 0.5em; +} + +#help { + transition: all 0.2s linear; + align-self: flex-start; +} + +#help:hover { + transform: scale(1.2); +} + +.key { + background: #00000022; + padding: 0.2em; + border: thin dashed #000; + border-radius: 0.2em; + font-weight: bold; } \ No newline at end of file