pressbooks / ideas

Ideas for Pressbooks.
GNU General Public License v3.0
12 stars 4 forks source link

Allow author to create discrete show/hide blocks #121

Open SteelWagstaff opened 6 years ago

SteelWagstaff commented 6 years ago

Feature Scope

Feature Description

Several of our authors would like to be able to insert collapsible text into their books, i.e. text that begins as hidden but can be toggled into a state of visibility in the webbook. For example, one instructor may produce a figure generated with R, a popular statistical software program. Beneath the figure they may wish to include instructions or commands for generating that figure, but they want students to think about or see if they can generate the commands themselves before viewing the pre-provided text. In that case, they'd wrap the explanatory text in a 'hide' block of some kind and let the reader toggle it into a 'show' state. Another example might be in a foreign language text, where a translation is provided for a text passage or sample dialogue. The text designers may wish to have the supplementary text available for display if the user selects it, but to have it hidden by default.

It would be nice to allow text blocks to be given a class that provides them with a show/hide button, rather than to rely on heading elements and for it to be an all-or-nothing proposition for the book or chapter entire. Even better might be a WYSIWYG button that lets a user create a well-formed <details> element with a summary property, or perhaps shortcodes?

Feature Use Case

I think that this feature would have fairly broad interest from anyone developing or designing a text that's intended to be a learning object, particularly if the text has reflection questions or some interactive self-check learning activities. Having toggled show/hide blocks lets learners reveal parts of the text at their own pace, without destroying the possibility of self-inquiry by providing an answer or solution before they've puzzled through something.

Other Notes

In the past, we used an imperfect WP plugin, WP-ShowHide to do some of these things, with less-than-ideal results. One consideration will be fallback behavior across container export formats. In my view, it would be fine for the hidden text to be expanded in exports which don't support javascript actions or collapsible/expandable text (not sure if ePUB or MOBI permits this, but I expect perhaps not). Many other sites have implemented something like this to hide spoilers or via 'read more/expand' options. See the comments at https://meta.stackexchange.com/questions/5199/please-add-the-ability-to-fold-blocks-of-code-in-questions-and-answers/261082 for some interesting discussion of possible implementations.

SteelWagstaff commented 6 years ago

Sample implementation using <details> shown here: https://wisc.pb.unizin.org/oersourcebook/chapter/show-hide-experimentation/. Have not tested this implementation in any container exports, so no idea what happens there ...

SteelWagstaff commented 5 years ago

Lumen Learning has written shortcodes for show and hide answer blocks into their Candela Utility plugin. See https://github.com/lumenlearning/candela-utility/blob/7f7cb0f6077d0b83277e63a54bc3faa7dc28f9ef/includes/class-cu-editor.php#L131-L169 + https://github.com/lumenlearning/candela-utility/blob/master/assets/js/hide-answer.js + https://github.com/lumenlearning/candela-utility/blob/master/assets/js/editor-hide-answer.js that could serve as one model for how to do this in Pressbooks?

SteelWagstaff commented 5 years ago

Old product spec brought in from Asana:

Short version: Users can insert short sections of collapsible content wherever they choose in their text. The sections are inserted in the same way as textboxes.

Entry

Click on ‘Textboxes’ in the writing tools menu Drop-down opens with an option for “Collapsible” Behaviour is consistent with other textboxes.

Display (in progress)

General: Font for title and content & colour of collapsible box determined by theme And/or top and bottom border on title (more likely if we don’t use heading variants)

Web: +/- next to title, toggles show/hide on click. Each box should be controlled individually (no accordion)

PDF: No icon next to title Format determined by theme, but it should be clear the content belongs under the title.

Ebook: Is show/hide supported anywhere? If not, as in PDF