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

tachyon-report-wizard

v32.0.0

Published

A package that contains shared logic and components for the twitch.tv report wizard

Downloads

1

Readme

Tachyon Report Wizard

Tachyon Report Wizard package provides a report wizard context and UI components for the twitch.tv report wizard. The report wizard context will be a place for building the report form and handling pagination through the wizard. It will provide event props for report form submission, blocking user, analytics, and closing the wizard.

The report wizard flow is data driven from edge's query reportWizard and the form object that gets passed on onSubmit is typed to edge's mutation reportUserContent.

How to dev locally

  1. Build this package (use watch if preferred) yarn build:watch
  2. In tachyon/package-examples/report-wizard directory, run yarn demo

How to consume package

Report Wizard UI components contain localized strings with tachyon-intl. Consumers of the report wizard package will need to set its own TachyonIntlRoot context.

Setting up ReportWizardRoot

The root supports initializing with a content type if the report wizard is going to be opened from an ingress point that specifies a content type, ie. opening the report wizard from a chat message should skip the 'content selection step' and proceed to the 'reason step'. the query for report wizard data should also specify the same content type in order to ensure the report wizard data reflects the flow for known content types. this will also reduce payload size.

The client consuming the report wizard package is responsible for generating a consistent and unique report session ID for analytics. The same ID should be used across all the queries/mutation such as reportWizard, onAnalyticEvent, and reportUserContent (see example).

import type { FC } from 'react';
import { ReportWizardRoot } from 'tachyon-report-wizard';
import { gql } from 'any-gql-client';
import { WizardComponent } from './wizard-component';

export const WizardModal: FC = ({
  content,
  contentID,
  contentMetadata,
  fromUserID,
  onClose,
  targetUserID,
  targetUserUsername,
}) => {
  const reportSessionID = generateSessionID();

  const data = gql(`
    query ReportWizardQuery($content: ReportContentType, $reportSessionID: ID!) {
      reportWizard(content: $content, reportSessionID: $reportSessionID) {
        ...all possible report wizard fields
      }
    }
  `, { variables: { content, reportSessionID }})

  const mutation = gql(`
    mutation ReportUserContentMutation($input: ReportUserContentInput!) {
      reportUserContent(input: $input) {
        error {
          code
        }
      }
    }
  `);

  return (
    <ReportWizardRoot
      content={content}
      contentID={contentID}
      contentMetadata={contentMetadata}
      data={data}
      fromUserID={fromUserID}
      onCloseWizard={onClose}
      onAnalyticEvent={(event) => {
        spadeClient.call({
          ...event,
          reportSessionID,
        })
      }}
      onSubmit={(formValues) => {
        mutation({
          ...formValues,
          sessionID: reportSessionID,
        })
      }}
      onToggleBlock={(block) => {
        // set up mutation to call to block/unlock on toggle
        // or set `hideBlockPrompt=false` on ReportWizardRoot
        // if user is unauth or has already blocked target user
      }}
      reportSubmissionLoading={mutation.loading}
      reportSubmissionError={mutation.error.code}
      reportSubmissionSuccess={mutation.success}
      targetUserID={targetUserID}
      targetUserUsername={targetUserUsername}
    >
      <WizardComponent>
    </ReportWizardRoot>
  );
};

Setting up wizard UI components

import type { FC } from 'react';
import {
  Confirmation,
  Content,
  Description,
  DetailedReason,
  Form,
  NetzDG,
  Reason,
  ReportWizardStep,
  reportWizardContext,
} from 'tachyon-report-wizard';

export const WizardComponent: FC = () => {
  const { currentStep, reportSubmissionSuccess } =
    useContext(reportWizardContext);
  if (reportSubmissionSuccess) {
    return <Confirmation />;
  }
  return (
    <Form>
      {currentStep === ReportWizardStep.Content && <Content />}
      {currentStep === ReportWizardStep.DetailedReason && <DetailedReason />}
      {currentStep === ReportWizardStep.Reason && <Reason />}
      {currentStep === ReportWizardStep.Description && <Description />}
      {currentStep === ReportWizardStep.NetzDG && <NetzDG />}
    </Form>
  );
};