2.1.0 • Published 2 years ago

surveyed v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

surveyed

A dope stepwise question component

npm.io

Install

npm install --save surveyed

Usage

An example is provided in the src/playground directory

import React, { Component } from 'react'

import { Surveyed } from "surveyed";
import 'surveyed/lib/index.css'

import surveySteps from "path/to/survey/steps";
import surveyMappedSteps from "path/to/survey/question-map";

class Example extends Component {
  constructor(props) {
    super(props);

    this.handleOnStarting = this.handleOnStarting.bind(this);
    this.handleOnReady = this.handleOnReady.bind(this);
    this.handleOnEmpty = this.handleOnEmpty.bind(this);
    this.handleOnCompleted = this.handleOnCompleted.bind(this);
    this.handleOnBack = this.handleOnBack.bind(this);
    this.handleOnNext = this.handleOnNext.bind(this);
  }

  handleOnStarting() {
    console.log("onStarting");
  }

  handleOnReady() {
    console.log("onReady");
  }

  handleOnEmpty() {
    console.log("onEmpty");
  }

  handleOnCompleted() {
    console.log("onCompleted");
  }

  handleOnBack() {
    console.log("onBack");
  }

  handleOnNext(response) {
    console.log("onNext::", response);
  }

  render() {
    return (
      <div style={{ height: "100vh", width: "100vw" }}>
        <Surveyed
          onStarting={this.handleOnStarting}
          onReady={this.handleOnReady}
          onEmpty={this.handleOnEmpty}
          onCompleted={this.handleOnCompleted}
          onBack={this.handleOnBack}
          onNext={this.handleOnNext}
          allSteps={surveySteps}
          mappedSteps={surveyMappedSteps}
        />
      </div>
    )
  }
}
PropRequiredType
surveyIdfalsestring
allStepstrueobject
mappedStepstrueobject
onStartingfalsefunc
onReadyfalsefunc
onEmptyfalsefunc
onNextfalsefunc
onBackfalsefunc
onCompletedfalsefunc

Props for Surveyed Component

propertytypedescriptionallowed values
idstringid of questioneach should have unique id
titlestringtitle of question
descriptionstring | nullquestion description
identifierstringunique user friendly question identifier (value separated by underscore)
response_display_typestringway of display of response selector"horizontal" | "vertical"
response_display_shapestringshape of response selector"circle" | "card_default"
response_display_styleReact.CSSPropertiescss
response_interaction_formatstringtype of question"input" | "dropdown" | "select" | null
typestring | nullINPUT format type"text" | "email" | "password" | null
placeholderstring | nullplaceholder text for input type question
submit_btn_textstring | nulltext of submit button
continue_btn_textstring | nulltext of continue button
maximum_selectionsnumbermaximum response selections for each question
continue_after_delaynumber | nulltime to wait and then go to next step in milliseconds
responsesQuestionResponse[]responses/options of the question
redirect_urlstringurl to redirect to
is_initial_stepbooleanif step is the first step

Props for QuestionResponse

PropertyTypeDescription
idstringuniqe id
titlestringtitle of response
descriptionstringdescription of response
identifierstringunique user friendly response identifier (value separated by underscore)
image_urlstring (not required)url of image

Development run

npm run storybook

Build

npm run build

Deploy

np

or

np --no-tests to skip tests

License

MIT © amitad16

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

4 years ago