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

questionnaire-webcomponent

v4.0.8

Published

The webcomponent for the questionnaire library

Downloads

907

Readme

QuestionnairePlayer

The Questionnaire Player is a web component built with Angular (version 16.2.1).

Prerequisites for Setup

  • Angular 16
  • Node.js 16.19.0

Setup

  1. Run npm install after cloning the repo locally to install the necessary dependencies.

Build QuestionnairePlayer and Generate the Web Component

  1. Run npm run build-web-comp to build the player with the latest changes and reflect the updates in the web component.

Demo Application

  1. Navigate to projects/questionnaire-app and run ng serve for a dev server. Open http://localhost:4200/ in your browser. The application will automatically reload when source files are changed.
    • If changes are made to the library, running npm run build-web-comp will automatically reflect those changes in the demo app (applicable only to this Angular app, not the React demo app).

Web Component

  1. The web component can be installed by running:

    npm i questionnaire-webcomponent
  2. In angular.json, include the published web component script under the "scripts" section (navigate to projects -> questionnaire-app -> architect -> build).

  3. Path to the web component script:

    "scripts":[... , "node_modules/questionnaire-webcomponent/questionnaire-player-webcomponent.js"]

To include the npm-published styles of the web component, add the following path to the "styles" section in angular.json:

    "styles":[... , "node_modules/questionnaire-webcomponent/styles.scss"]
    

For usage in a React app, visit the React demo repository - https://github.com/5Amogh/react-usingwebcomponent-app

Key Features

  1. API-based Data Fetching

    • The component accepts a solution ID and configuration options via an apiConfig object.
    • It fetches questionnaire data dynamically through API calls based on the provided solution ID.
  2. Configurable Theming

    • Theming is flexible and configurable at the application level using CSS variables, allowing for seamless integration into various applications with customized designs.
  3. Pagination

    • A built-in pagination system makes it easy to navigate through multi-page questionnaires.
  4. Question Map (Navigation)

    • A question map provides a visual overview of progress:
      • Filled questions are marked in green.
      • Mandatory unfilled questions are highlighted in red.
      • Non-mandatory unfilled questions are shown in light green.
    • Clicking on a question in the map allows users to directly navigate to that question.

Adding the Web Component to an Angular Application

Consumption in HTML File

To integrate the web component into your Angular application, include the following in your HTML file:

<questionnaire-player-main angular [apiConfig]="apiConfig"></questionnaire-player-main>

If you are using the webcomponent inside an angular application, use the attribute angular in questionnaire-player-main tag to help the webcomponent detect the input changes inside ngOnChanges

In your Angular component, you can configure the apiConfig object as follows:

apiConfig = {
  baseURL: '<base_url>',
  fileSizeLimit:<fileSizeInNumber(MB)>,
  userAuthToken: '<user_auth_token>',
  solutionId: '<solution_id>',
  solutionType: 'survey' | 'observation'
}

Configuration

baseURL: Base url is necessary for making API requests to fetch, save, submit the questionnaire data fileSizeLimit: To limit the size of the file uploads for evidences, in MB. userAuthToken: Necessary to append during API requests for authentication. solutionId: Necessary to render and make changes to a survey or an observation via API requests. solutionType: To switch the endpoints for API requests and features as applicable to survey and observation.

Theming Configuration

To apply custom theming in your application, you can define CSS variables in your global styles (e.g., :root):

:root {
  --primary-color: 1B4CA1;
  --btn-outline: 1B4CA1;
  --error-color: rgb(150, 4, 4);
  --question-tip: gray;
  --general-btn-text-color: white;
  --general-btn-hover-bg: white;
  --secondary-btn-bg: white;
  --secondary-btn-hover-bg: whitesmoke;
  --card-bg: white;
  --disabled-btn-bg: gainsboro;
  --disabled-btn-text: gray;
}

This allows you to control the visual appearance of the web component and ensure it aligns with your application's design.