Add-ons / Popover Macro

Creates a special transparent dialog modal for images and text.

Author ChapelR
Website https://twinelab.net/custom-macros-for-sugarcube-2/#/popover
Story format SugarCube 2
Last checked Mon Jul 22 2024
License Unlicense
Download popover.zip

Index

Overview

Creates a special transparent dialog modal for images and text.

The Popover Macro

Macros

<<popover>>

<<popover>>

Syntax: <<popover [flags] [classList]>><</popover>>

The <<popover>> macro creates a special transparent dialog modal for images and text, rendering the content between its tags into this special dialog element. Like a normal dialog, clicking on the overlay closes the popover, but this behavior may be suppressed. There are also a few additional options and you may add custom classes as well.

Arguments:

Usage:

<<popover 'invert' 'opaque'>>Hi there!<</popover>>

<<popover 'transparent' 'my-class'>>[img[assets/my-img.png]]<</popover>>

<<popover 'my-class'>>[img[assets/my-img.png]]<</popover>>

<<popover 'noclick'>>[[Move on]]<</popover>>

<<popover>>Welcome!<</popover>>

<<dismisspopover>>

<<dismisspopover>>

Syntax: <<dismisspopover>>

Closes the popover dialog. Can't be used to close other dialogs, but functions, methods, or macros that close other dialogs should generally also be able to close popovers, so Dialog.close() should work fine if you prefer.

Usage:

<<popover>>\
    Hi there! Welcome to my game!

    <<button "Continue">><<dismisspopover>><</button>>
<</popover>>

JavaScript API

setup.popover()

setup.popover()

Syntax: setup.popover(content [, flagsAndClasses])

A JavaScript function that is essentially the same as the <<popover>> macro

Arguments:

Live demo

Demo Twee code:

:: Start
<<link "Make it pop!">>
  <<popover 'my-class'>>[img[https://loremflickr.com/320/240]]<</popover>>
<</link>>