Have ideas to improve npm?Join in the discussion! »

    rwt-storyboard

    1.0.11 • Public • Published

    Premium DOM Component

    Storyboard

    Multi-panel story with cool effects

    by Read Write Tools Sep 9, 2020
    Abstract
    The rwt-storyboard DOM component displays a sequence of panels that tell a story. Transitions from one panel to the next can slide-in or fade-in to dramatic effect. The content of each panel is provided by an HTML template, and the sequencing speed can be controlled by CSS variables.

    Motivation

    The rwt-storyboard DOM component is intended for use on web pages where the author wants to grab the reader's attention and funnel them towards a particular action.

    The component has these features:

    • Each panel may contain any arbitrary content and styling.
    • Each panel may be transitioned to visibility using it's own effect.
    • The first panel can be shown with an initial delay before the sequencing begins.
    • The last panel can be shown with a final hold time before restarting the full sequence.
    • Sequencing occurs only when the component is fully visible within the browser's viewport. It is suspended when the component is hidden or only partially visible.
    • The user may suspend the auto-sequencing by clicking anywhere within the component's frame, and may resume the auto-sequencing by clicking the component a second time.
    • Round buttons along the bottom of the storyboard allow the user to override the auto-sequencing to display a particular panel.

    In the wild

    To see an example of this component in use, visit the READ WRITE STACK website. Each page uses this component to tell a user story about apps, plugins and DOM components. To understand what's going on under the hood, use the browser's inspector to view the HTML source code and network activity, and follow along as you read this documentation.

    Installation

    Prerequisites

    The rwt-storyboard DOM component works in any browser that supports modern W3C standards. Templates are written using BLUE PHRASE notation, which can be compiled into HTML using the free Read Write View desktop app. It has no other prerequisites. Distribution and installation are done with either NPM or via Github.

    Download

    Download using NPM

    OPTION 1: Familiar with Node.js and the package.json file?
    Great. Install the component with this command:

    npm install rwt-storyboard	

    OPTION 2: No prior experience using NPM?
    Just follow these general steps:

    • Install Node.js/NPM on your development computer.
    • Create a package.json file in the root of your web project using the command:
    npm init		
    Download and install the DOM component using the command:
    npm install rwt-storyboard		

    Important note: This DOM component uses Node.js and NPM and package.json as a convenient distribution and installation mechanism. The DOM component itself does not need them.

    Download using Github

    If you prefer using Github directly, simply follow these steps:

    • Create a node_modules directory in the root of your web project.
    • Clone the rwt-storyboard DOM component into it using the command:
    git clone https://github.com/readwritetools/rwt-storyboard.git		

    Using the DOM component

    After installation, you need to add two things to your HTML page to make use of it.

    • Add a script tag to load the component's rwt-storyboard.js file:
    <script src='/node_modules/rwt-storyboard/rwt-storyboard.js' type=module></script>             
    • Add the component tag somewhere on the page with these two attributes:

      • Apply a sourceref attribute with a reference to an HTML file containing the panels. See details below.
      • Optional. For WAI-ARIA accessibility apply a role=contentinfo attribute.

    Here's an example:

    <rwt-storyboard sourceref='/five-panel-story.html' role=contentinfo></rwt-storyboard>

    Panel template

    The sourceref file should contain valid HTML consisting of two or more section elements. The contents of each section is treated as a panel.

    Transition effects are declared by adding the two special attributes data-next and data-prev to each section. In this example (shown using BLUE PHRASE notation for clarity), each panel will transition to visibility using fade-in and transition to hidden using fade-out:

    section *data-next='fade-in' *data-prev='fade-out' {
        Ask a leading question
    }
    section *data-next='fade-in' *data-prev='fade-out' {
        Pose a suggested answer
    }
    section *data-next='fade-in' *data-prev='fade-out' {
        State the product's feature 
    }
    section *data-next='fade-in' *data-prev='fade-out' {
        Assert that user needs the product
    }
    section *data-next='fade-in' *data-prev='fade-out' {
        Give user easy way to get it
    }

    The possible transition values are:

    fade-in
    from-left
    from-right
    from-top
    from-bottom
    
    fade-out
    to-left
    to-right
    to-top
    to-bottom
    

    Customization

    Dimensions

    The width and height of the storyboard are set using the CSS variables --width and --height.

    Adjust the --font-basis to shrink or grow the entire storyboard.

    rwt-storyboard {
        --font-basis: 1.0;
        --width: calc(10rem * var(--font-basis));
        --height: calc(40rem * var(--font-basis));
    }

    Color scheme

    The default color palette for the storyboard uses a dark mode theme. You can use CSS to override the variables' defaults:

    rwt-storyboard {
        --color: var(--white);
        --background: var(--black);
        --button-color: var(--pure-white);
    }

    Important: the content of each panel can be customized with any CSS you want, but that CSS must be included in the sourceref template file together with the panel's HTML declarations. CSS that is outside the component is firewalled and will not pierce the document/component barrier.

    Threshold

    Panels will only transition when visible. When the document is scrolled outside the user's viewport, the transitioning effect is suspended. The component can be customized to suspend/resume transitions when only a portion of the full storyboard is visible. The threshold for this is a value between 0.0 and 0.99.

    rwt-storyboard {
        --threshold: 0.95;
    }

    Timing variables

    The sequencing of panel transitions is controlled by CSS variables. Each variable may specify values in units of seconds (s) or milliseconds (ms).

    • --duration-in is the duration for a new panel to become fully visible.
    • --duration-out is the duration for the previous panel to become completely hidden.
    • --delay-in is the amount of time to wait before starting a panel's transition from hidden to visible.
    • --delay-out is the amount of time to wait before starting a panel's transition from visible to hidden.
    • --initial-delay is the initial amount of time to show the first panel, before beginning the transition to the second panel.
    • --sequence-time is the total time from one panel to the next. Normally this should be equal to --duration-in + --duration-out + --delay-in + --delay-out.
    • --hold-time is the final amount of time to show the last panel, before restarting the full sequence.
    rwt-storyboard {
        --duration-in: 2s;
        --duration-out: 2s;
        --delay-in: 0s;
        --delay-out: 0s;
        --initial-delay: 6s;
        --sequence-time: 4s;
        --hold-time: 6s;
    }

    Life-cycle events

    The component issues life-cycle events.

    component-loaded
    Sent when the component is fully loaded and ready to be used. As a convenience you can use the waitOnLoading() method which returns a promise that resolves when the component-loaded event is received. Call this asynchronously with await.
    collapse-popup
    The component listens on DOM document for collapse-popup messages, which are sent when other components are activated. Upon receipt it will suspend sequencing.

    Reference

    DOM components logo Documentation READ WRITE HUB
    git logo Source code github
    DOM components logo Component catalog DOM COMPONENTS
    npm logo Package installation npm
    Read Write Stack logo Publication venue READ WRITE STACK

    License

    The rwt-storyboard DOM component is not freeware. After evaluating it and before using it in a public-facing website, eBook, mobile app, or desktop application, you must obtain a license from Read Write Tools .

    Storyboard Software License Agreement
    1. This Software License Agreement ("Agreement") is a legal contract between you and Read Write Tools ("RWT"). The "Materials" subject to this Agreement include the "Storyboard" software and associated documentation.
    2. By using these Materials, you agree to abide by the terms and conditions of this Agreement.
    3. The Materials are protected by United States copyright law, and international treaties on intellectual property rights. The Materials are licensed, not sold to you, and can only be used in accordance with the terms of this Agreement. RWT is and remains the owner of all titles, rights and interests in the Materials, and RWT reserves all rights not specifically granted under this Agreement.
    4. Subject to the terms of this Agreement, RWT hereby grants to you a limited, non-exclusive license to use the Materials subject to the following conditions:
    • You may not distribute, publish, sub-license, sell, rent, or lease the Materials.
    • You may not decompile or reverse engineer any source code included in the software.
    • You may not modify or extend any source code included in the software.
    • Your license to use the software is limited to the purpose for which it was originally intended, and does not include permission to extract, link to, or use parts on a separate basis.
    Each paid license allows use of the Materials under one "Fair Use Setting". Separate usage requires the purchase of a separate license. Fair Use Settings include, but are not limited to: eBooks, mobile apps, desktop applications and websites. The determination of a Fair Use Setting is made at the sole discretion of RWT. For example, and not by way of limitation, a Fair Use Setting may be one of these:
    • An eBook published under a single title and author.
    • A mobile app for distribution under a single app name.
    • A desktop application published under a single application name.
    • A website published under a single domain name. For this purpose, and by way of example, the domain names "alpha.example.com" and "beta.example.com" are considered to be separate websites.
    • A load-balanced collection of web servers, used to provide access to a single website under a single domain name.
    THE MATERIALS ARE PROVIDED BY READ WRITE TOOLS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL READ WRITE TOOLS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This license is effective for a one year period from the date of purchase or until terminated by you or Read Write Tools. Continued use, publication, or distribution of the Materials after the one year period, under any of this Agreement's Fair Use Settings, is subject to the renewal of this license. Products or services that you sell to third parties, during the valid license period of this Agreement and in compliance with the Fair Use Settings provision, may continue to be used by third parties after the effective period of your license. If you decide not to renew this license, you must remove the software from any eBook, mobile app, desktop application, web page or other product or service where it is being used. Without prejudice to any other rights, RWT may terminate your right to use the Materials if you fail to comply with the terms of this Agreement. In such event, you shall uninstall and delete all copies of the Materials. This Agreement is governed by and interpreted in accordance with the laws of the State of California. If for any reason a court of competent jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum extent possible to effectuate the intent of the parties and the remainder of the Agreement shall continue in full force and effect.

    Activation

    To activate your license, copy the rwt-registration-keys.js file to the root directory of your website, providing the customer-number and access-key sent to your email address, and replacing example.com with your website's hostname. Follow this example:

    export default [{
        "product-key": "rwt-storyboard",
        "registration": "example.com",
        "customer-number": "CN-xxx-yyyyy",
        "access-key": "AK-xxx-yyyyy"
    }]
    

    Install

    npm i rwt-storyboard

    DownloadsWeekly Downloads

    24

    Version

    1.0.11

    License

    see license.html

    Unpacked Size

    288 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar