npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adactive/arc-steplist

v2.5.4

Published

Adsum Steplist Component

Downloads

32

Readme

react-badge touch-badge

Step List

Screenshot of Step List component

Getting started

npm i --save @adactive/arc-steplist

OR

yarn add @adactive/arc-steplist

How to use

Just add the component as below:


import * as React from 'react';

// import StepList component
import StepList from '@adactive/arc-steplist';

/*...*/

class MyComponent extends React.Component {
    render() {
        return (
            <StepList placeId={placeId} />
        );
    }
}

Props


type OwnPropsType = {|
    placeId: ?number,
    pmr: boolean, // optional
    messages: MessagesType, // optional
    stepStyle: StepStyleType, // optional
    renderStep: RenderStepType, // optional
    renderStepTail: RenderStepTailType, // optional
|};

You can see here as well what flow types are exported. You can import them from the component to enhance your flow typing in your app.


export type StepType = {|
    index: number,
    floor: ?{|
        id: number,
        name: ?string,
        deltaAltitudeWithPrevStep: number,
    |},
    message: string,
|};

export type MessagesType = (step: StepType) => {|
    firstStep?: string,
    lastStep?: string,
    isInterfloor?: string,
    default?: string,
|};

export type StepStyleType = {|
    default?: { [key: string]: string},
    isDone?: { [key: string]: string},
    current?: { [key: string]: string},
    isNext?: { [key: string]: string},
    isNotDoneYet?: { [key: string]: string},
|};

export type RenderStepType = (
    mode: StepModeType,
    step: StepType,
    stepStyle: StepStyleType,
    onClick: (stepIndex: number) => () => void,
) => ?Node;

export type RenderStepTailType = (mode: StepModeType, step: StepType) => ?Node;

placeId

Place ID of the place targeted by the steplist. This is the only necessary prop of the component.

pmr

Draw the wayfinding with PMR (avoid stairs, use elevator instead) or not.

default value

defaultPmr = false

messages

Customize message shown on each step, following this structure:


type MessagesType = (step: StepType) => {|
    firstStep?: string,
    lastStep?: string,
    isInterfloor?: string,
    default?: string,
|};
  • firstStep: the first step.
  • lastStep: the last step.
  • isInterfloor: steps where the floor is different from the previous one.
  • default: message for steps that don't fall into any of the previous categories.
default value

defaultMessages = (step: StepType) => {
    const { floor } = step;

    let floorName = null;
    let upOrDown = '';

    if (floor) {
        const { name, deltaAltitudeWithPrevStep } = floor;

        // floor name
        floorName = name;

        // interfloor direction
        if (deltaAltitudeWithPrevStep > 0) upOrDown = ' up'; // space before on purpose
        else if (deltaAltitudeWithPrevStep < 0) upOrDown = ' down'; // same
    }

    return {
        firstStep: `Start here${floorName ? `, at ${floorName}` : ''}`,
        lastStep: 'You are at your destination',
        isInterfloor: floorName ? `Go${upOrDown} to ${floorName}` : 'Change floor',
        default: 'Continue',
    };
}

stepStyle

Customize style of each step, following this structure:


export type StepStyleType = {|
    default?: CSSStyleDeclaration,
    isDone?: CSSStyleDeclaration,
    current?: CSSStyleDeclaration,
    isNext?: CSSStyleDeclaration,
    isNotDoneYet?: CSSStyleDeclaration,
|};
  • default: style applied to each step, whatever their current mode.
  • isDone: style added to step that are done.
  • current: style added to current step.
  • isNext: style added to the step just after the current step.
  • isNotDoneYet: style added to the steps that are after the 'isNext' step, not done yet.

Be aware that you don't have to modify all the styles. For examples, you can modify only the 'isNext' style, and the others default styles will be kept.

If you want to modify the style of the whole step list, you can overwrite the 'steplist' classname in your component stylesheet.

default value

defaultStepStyle = {
    default: {
        transition: 'all .5s',
    },
    isDone: {
        opacity: 0.3,
    },
    current: {
        backgroundColor: 'green',
    },
    isNext: {
        backgroundColor: 'lightgreen',
    },
    isNotDoneYet: {},
}

renderStep

Overwrite the default render step function. This is one step further than just customizing the style with stepStyle prop.


export type RenderStepType = (
    mode: StepModeType,
    step: StepType,
    stepStyle: StepStyleType,
    onClick: (stepIndex: number) => () => void,
) => ?Node;

This is a function that return some JSX,for you to be able to use the current mode, the step, the stepStyle and the default click handler in your own steps.

default value

defaultRenderStep = (
    mode: StepModeType,
    step: StepType,
    stepStyle: StepStyleType,
    onClick: (stepIndex: number) => () => void,
) => (
    <div
        className="step"
        style={stepStyle}
        onClick={onClick(step.index)}
        role="complementary"
        onKeyDown={() => {}}
    >
        <div className="badge">{step.index + 1}</div>
        <div className="message">{step.message}</div>
    </div>
)

renderStepTail

Same as renderStep, but for the step tail: the space before each step.

If you want to remove the tails, simply pass a function that returns null.


export type RenderStepTailType = (mode: StepModeType, step: StepType) => ?Node;

Again, this a function, so you can use the current mode and the step in your own step tails.

default value

defaultRenderStepTail = (mode: StepModeType, step: StepType) => {
    if (step.index === 0) return null; // no tail before first step

    const numberOfCircles = 4;

    // [0, 1, ..., numberOfCircles - 1]
    const dumbArrayToMap = [...Array(numberOfCircles).keys()];

    const delayBetweenEachCircle = 1 / 10;

    // wait for the last circle to finish + add 1 more delay to make it smoother
    const animationDuration = (numberOfCircles + 2) * delayBetweenEachCircle;

    const circleStyle = delay => (
        {
            width: `${100 / (numberOfCircles * 3)}%`,
            maxWidth: '1em',
            animation: mode !== 'isNext' ? null // animation only if step is next
                : `blink ${animationDuration}s linear ${delay}s infinite alternate`,
        }
    );

    return (
        <div className="tail">
            {dumbArrayToMap.map(index => (
                <div
                    // 'index' as key is ok here,
                    // because no modification will happen on numberOfCircles array
                    key={index}
                    className="circle"
                    style={circleStyle(index * delayBetweenEachCircle)}
                />
            ))}
        </div>
    );
}

Copy component inside your project src folder

It will copy the component inside your project, in src/components/adsum-steplist/.

npx @adactive/arc-steplist copy