Code Monkey home page Code Monkey logo

playroom-clickable-prototypes's Introduction

Create clickable prototypes in Playroom.

This package lets you create clickable prototypes in your Playroom. It's intended for prototyping purposes.

Demo

Installation

Install the package

# npm
npm install playroom-clickable-prototypes

# yarn
yarn add playroom-clickable-prototypes

Then open your Playroom components file and add

export { Stage, Trigger, Frame } from "playroom-clickable-prototypes";

Usage

Use <Stage initial="frame-id" /> to define a stage and an initial state.

A stage can have different frames. Each <Frame id="frame-id" /> needs to have an id. Only the active frame will be shown.

To create links between states, you can wrap any element in a <Trigger target="frame-id" />.

<Stage initial="step1">

  <Frame id="step1">
    <p>First step</p>
    <Trigger target="step2">
      <button type="button">Continue</button>
    </Trigger>
  </Frame>

  <Frame id="step2">
    <p>Second step</p>
    <Trigger target="step1">
      <button type="button">Back</button>
    </Trigger>
  </Frame>

</Stage>

You can press the escape key twice to highlight all clickable areas.

After transitioning away from the initial frame, you can press the Escape key thrice to go back to the initial frame.

Components

Stage

The general stage. Wrap this component around your frames.

  • initial (string, required): The id of the frame to be shown initially

Frame

The individual frames of your prototype.

  • id (string, required): The id of this frame

Trigger

The triggers which transition to different frames when clicked. Wrap this around your buttons or links.

  • target (string, required): The id of the frame this trigger links to

playroom-clickable-prototypes's People

Contributors

dferber90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

iamtekeste

playroom-clickable-prototypes's Issues

Support nested stages

Let users nest stages so they don't have to copy the whole UI into the next frame if only a tiny part of the UI changes.

<Stage id="stage-one" initial="start">
  <Frame stage="stage-one" id="start">
    <Stage id="stage-two" initial="frame-two">
      <Frame stage="stage-two" id="frame-two">
        <Trigger stage="stage-two" target="frame-two">next</Trigger>
      </Frame>
      <Frame stage="stage-two" id="frame-three">
        Stage two, Frame three
      </Frame>
    </Stage>
  </Frame>
</Stage>

This makes the API and implementation more difficult tho. Not sure it's worth it. If we go for it, the stage props need to be optional.

Show clickable triggers on click

Instead of making users press escape twice, show clickable areas on click. That's much more discoverable. Also, it would be cool to make the effect look more like it does in Figma.

We can then move the "go back to initial frame" action to escape-twice.

Sync frames across themes

We'd probably need built-in support from Playroom (or some sessionStorage syncing workaround), but it would be pretty cool to make the frames sync across themes.

Support different types of triggers

We could support different types of actions for Triggers. At the moment there's no action attribute. But we could add one

<Trigger action="click, hovering, pressing, mouseEnter, mouseLeave" />

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.