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

@labosaurus/core

v0.2.0

Published

**Labosaurus** provides interactive features to Docusaurus, useful for training purposes.

Downloads

4

Readme

Labosaurus

Labosaurus provides interactive features to Docusaurus, useful for training purposes.

Live demo here!, or (with Google authentication), or (with fake authentication)
🧪 Lab example here!, or (with Google authentication), or (with fake authentication)

How to install

Install Labosaurus :

npm install @labosaurus/core
npm install @labosaurus/firebase # If you want to use Firebase auth and storage.

Inside your Docusaurus repository, create a file src/theme/Root.tsx (or jsx) :

import { GoogleLogin, LabosaurusRoot } from '@labosaurus/core';
import { firebaseAuthProvider, firebaseStoreProvider } from '@labosaurus/firebase';

// If you want to use Firebase. You can use something else if you want.
import * as firebase from 'firebase/app';
export const app = firebase.initializeApp(... firebaseConfig ...);

export default function Root({ children }) {
  return (
    <LabosaurusRoot
      config={{
        storeProvider: firebaseStoreProvider(app), // Uses Firestore to display/hide Hidden blocks.
        authProvider: firebaseAuthProvider(app), // Uses Firebase auth.
        loginElement: () => <GoogleLogin /> // Displays a "Sign in with Google" button.
      }}
    >
      {children}
    </LabosaurusRoot>
  );
}

Features

Slide mode

Adds a space before each title to facilitate presentation. Enable it by pressing Option+Shift+S. labosaurus-slide-demo

Hidden block

Allows to hide/show content from all readers in realtime.
Can be plugged to any realtime sources, such as Firestore, your own API or anything else.

labosaurus-hidden-demo

Only administrator can show/hide hidden blocks.
If you use firebase/firestore, you have to create 2 collections :

  • hidden : Labosaurus will use it to store the state of hidden groups.
  • users : Labosaurus will use it to check if the connected user is an administrator. For each administrator, create a document with user's email as id, and a field admin: true. Ensure to secure your collection.

Parameters :

  • until : The sequential number of the block. Displaying a block with until=N will display all blocks <N of the current group.
  • group (optional) : Hidden block group (default by default).
  • label (optional) : Hidden label.
import { Hidden } from "@labosaurus/core";

<Hidden until={100}>
... Content ...
</Hidden>

<Hidden until={101}>
If I'm visible, the previous block is also visible.
</Hidden>

<Hidden group="foo" until={1} label="I'm hidden">
I'm in my own group. I'm not affected by others blocks.
</Hidden>

Use Firestore to get realtime synchronization :

export default function Root({ children }) {
  return (
    <LabosaurusRoot
      config={{
        ...
        storeProvider: firebaseStoreProvider(app),
      }}
    >
      {children}
    </LabosaurusRoot>
  );
}

... or anything else :

<LabosaurusRoot
    config={{
    ...
    storeProvider: {
        dispatch: ...
        get: ...
        subscribe: ...
    },
    }}
>
    {children}
</LabosaurusRoot>

Hint

Displays a hint.
labosaurus-hint-demo

import { Hint } from "@labosaurus/core";

<Hint>A hint</Hint>

Question

Displays a simple question.
Answer cannot be seen in the DOM, but could be found in sources (not easily).

labosaurus-question-demo

Parameters :

  • label : The... label.
  • answer : The... answer. It can be a string, or an object with details. Details is displayed after the user made his choice.
  • wrongAnswers : An array of wrong answers. It can be a string, or an object with details.
  • onAnswer (optional) : On answer callback.
import { SimpleQuestion } from "@labosaurus/core";

<SimpleQuestion
  label="🫵 What's the weather like today?"
  answer="Sunny"
  wrongAnswers={["Cloudy", "Rainy"]}
  onAnswer={onAnswer}
/>

<SimpleQuestion
  label="🫵 What's the weather like today?"
  answer={{
    label: "Sunny",
    details:
      "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
  }}
  wrongAnswers={[
    {
      label: "Cloudy",
      details:
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    },
    {
      label: "Rainy",
      details:
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    },
  ]}
/>

Browser Window

Just an integration of Facebook's Browser Window.

labosaurus-browser-window-demo

import { BrowserWindow } from '@labosaurus/core';

<BrowserWindow url="https://my-website">
    Hello world
</BrowserWindow>

Admin/User only

Displays a content only if user is an admin, or not.

import { AdminOnly, UserOnly } from '@labosaurus/core';

<AdminOnly>If you see this, then you are an admin.</AdminOnly>
<UserOnly>If you see this, then you are a user, but not an admin.</UserOnly>

Blur Flow

This displays blurry steps, which the user can discover through an interactive experience.

labosaurus-blurflow-demo

Parameter :

  • unblurred : Disable blur, useful for the first step.
import { BlurFlow, BlurFlowStep, unblurNextStep } from '@labosaurus/core';

<BlurFlow>
  <BlurFlowStep unblurred={true}>
    <button onClick={unblurNextStep}>Reveal next step</button>
  </BlurFlowStep>
  <BlurFlowStep>
    Hello
    <button onClick={unblurNextStep}>Reveal next step</button>
  </BlurFlowStep>
  <BlurFlowStep>
    Bye
  </BlurFlowStep>
</BlurFlow>

Authentication

By using LabosaurusRoot, the user will be prompted to authenticate.
You can use anything you want to authenticate.
Labosaurus provides a Firebase authentication (Google oAuth), but you can highly customize authentication and use others access manager, or your own API, or nothing. labosaurus-signin-google

Using Firebase :

import * as firebase from 'firebase/app';
import { LabosaurusRoot, GoogleLogin } from '@labosaurus/core';
import { firebaseAuthProvider } from '@labosaurus/firebase';


export const app = firebase.initializeApp({ /* firebase config */ });

export default function Root({ children }) {
  return (
    <LabosaurusRoot
      config={{
        authProvider: firebaseAuthProvider(app), // Uses Firebase auth.
        loginElement: () => <GoogleLogin /> // Displays a "Sign in with Google" button.
        ...
      }}
    >
      {children}
    </LabosaurusRoot>
  );
}

... or anything else :

<LabosaurusRoot
    config={{
    authProvider: {
        login: async () => { ... },
        logout: async () => { ... },
        isAdmin: async () => { return true|false },
        getUser: () => { return "string"|undefined; },
        onUser: (callback) => { // Labosaurus subscribes to user login/logout.
        ...
        callback(user); // Triggers callback immediately.
        return unsubscribeFunction;
        }
    },
    loginElement: () => {
        const { authProvider } = useContext<LabosaurusConfig>(LabosaurusContext);
        return <button onClick={authProvider.login}>Login</button>;
    }
    }}
>
    {children}
</LabosaurusRoot>