Skip to content

Commit

Permalink
popup: big option
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Sep 19, 2023
1 parent cef414d commit dd9a837
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/components/NotifyWhenDone.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export let NotifyWhenDone = ({ status }) => {
const visible = useDelayedTruth(!all_done, 2500) || enabled

return html`
<div class=${cl({ visible, "notify-when-done": true })}>
<div class=${cl({ visible, "notify-when-done": true })} inert=${!visible}>
<label
>${"Notify when done"}
<input
Expand Down
13 changes: 9 additions & 4 deletions frontend/components/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const help_circle_icon = new URL("https://cdn.jsdelivr.net/gh/ionic-team/
/**
* @typedef PkgPopupDetails
* @property {"nbpkg"} type
* @property {HTMLElement?} source_element
* @property {HTMLElement} [source_element]
* @property {Boolean} [big]
* @property {string} package_name
* @property {boolean} is_disable_pkg
*/
Expand All @@ -28,7 +29,8 @@ export const help_circle_icon = new URL("https://cdn.jsdelivr.net/gh/ionic-team/
* @typedef MiscPopupDetails
* @property {"info" | "warn"} type
* @property {import("../imports/Preact.js").ReactElement} body
* @property {HTMLElement?} source_element
* @property {HTMLElement} [source_element]
* @property {Boolean} [big]
*/

export const open_pluto_popup = (/** @type{PkgPopupDetails | MiscPopupDetails} */ detail) => {
Expand All @@ -41,6 +43,8 @@ export const open_pluto_popup = (/** @type{PkgPopupDetails | MiscPopupDetails} *

export const Popup = ({ notebook, disable_input }) => {
const [recent_event, set_recent_event] = useState(/** @type{(PkgPopupDetails | MiscPopupDetails)?} */ (null))
const recent_event_ref = useRef(/** @type{(PkgPopupDetails | MiscPopupDetails)?} */ (null))
recent_event_ref.current = recent_event
const recent_source_element_ref = useRef(/** @type{HTMLElement?} */ (null))
const pos_ref = useRef("")

Expand All @@ -66,10 +70,10 @@ export const Popup = ({ notebook, disable_input }) => {

useEffect(() => {
const onpointerdown = (e) => {
if (recent_event_ref.current == null) return
if (e.target == null) return
if (e.target.closest("pluto-popup") != null) return
if (recent_source_element_ref.current == null) return
if (recent_source_element_ref.current.contains(e.target)) return
if (recent_source_element_ref.current != null && recent_source_element_ref.current.contains(e.target)) return

close()
}
Expand All @@ -96,6 +100,7 @@ export const Popup = ({ notebook, disable_input }) => {
class=${cl({
visible: recent_event != null,
[type ?? ""]: type != null,
big: recent_event?.big === true,
})}
style="${pos_ref.current}"
>
Expand Down
4 changes: 4 additions & 0 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,10 @@ pluto-popup.visible {
pointer-events: initial;
}

pluto-popup.big {
--max-size: 25em;
}

pluto-popup > * {
display: block;
background: var(--overlay-button-bg);
Expand Down

0 comments on commit dd9a837

Please sign in to comment.