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

@telus-uds/docusaurus-theme-component-docs

v1.0.4

Published

A Docusaurus theme exporting `@theme/PropsTable`, `@theme/LibraryInfo` and `@theme/Playground` components

Downloads

381

Readme

@telus-uds/docusaurus-theme-component-docs 📝

A Docusaurus theme exporting @theme/PropsTable, @theme/LibraryInfo and @theme/Playground components to render documentation pages, including components-base and their editable code snippets.

Setup ⚙️

  1. Install this theme into a UDS Docs website powered by Docusaurus
npm install --save @telus-uds/docusaurus-theme-component-docs
  1. Add the theme to the docusaurus.config.js
module.exports = {
  // ...
  themes: ['@telus-uds/docusaurus-theme-component-docs']
  // ...
}
  1. Provide a UDS Compatible Theme in docusaurus.config.js
const theme = require('@telus-uds/theme-koodo')
module.exports = {
  // ...
  themeConfig: {
    // ...
    componentDocs: {
      theme
    }
  }
  // ...
}
  1. Create a new file index.js under src/theme/ReactLiveScope and add the following:
import InitReactLiveScope from '@theme-init/ReactLiveScope'

// Add react-live imports you need here
const ReactLiveScope = {
  ...InitReactLiveScope
}
export default ReactLiveScope

By default, @theme-init/ReactLiveScope has the following primitives exported:

  • React
  • All top-level exports of React
  • All top-level exports from @telus-uds/components-base

If you want to extend this list, simply reference that in ReactLiveScope object as follows:

import InitReactLiveScope from '@theme-init/ReactLiveScope'
import Cart from '@telus-uds/palette-koodo/build/web/icons/Cart'


// Add react-live imports you need here
const ReactLiveScope = {
  ...InitReactLiveScope
  ExampleIcon: Cart
}
export default ReactLiveScope

Swizzling 🌀

You can choose to swizzle other components like LibraryInfo and Playground to either enhance their functionality or pass data specific to the consumption documentation package.

LibraryInfo

By default, LibraryInfo has the following values for its props:

| prop | value | | -------------- | ----------------------------------------------- | | library | 'UDS Base' | | repository | 'universal-design-system' | | packageName | 'components-base' | | packageVersion | current version of @telus-uds/components-base |

But we can swizzle this component in the following way:

  • Create a new file src/theme/LibraryInfo/index.jsx:
import React from 'react'
import LibraryInfo from '@theme-original/LibraryInfo'

export default function LibraryInfoWrapper(props) {
  return (
    <>
      <LibraryInfo {...props} {/* pass extra sets of props here*/} />
    </>
  )
}

Playground

We can pass a provide a UDS Compatible Theme in docusaurus.config.js but there may be situations where there is a need to provide a React provider rather than the raw theme and that is where we can swizzle Playground and pass a provider prop.

  • Create a new file src/theme/Playground/index.jsx:
import React from 'react'
import Playground from '@theme-init/Playground'
import theme from '@telus-uds/theme-koodo'
import { BaseProvider } from '@telus-uds/components-base'

function KoodoProvider({ children }) {
  return <BaseProvider defaultTheme={theme}>{children}</BaseProvider>
}

export default function PlaygroundWrapper(props) {
  return (
    <>
      <Playground {...props} provider={KoodoProvider} />
    </>
  )
}

Note that if both theme (through docusaurus.config.js) and provider are provided at the same time, provider takes precedence over theme.

Also, you can choose not to wrap when you swizzle but entirely eject the default components, please check Docusaurus's documentation on swizzling to learn more.