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

@wethecurious/wtc-exhibit-base-lib

v0.6.16

Published

Shared library for WTC Treatments using React. Used for both BrightSign device exhibits and PC-based web exhibits.

Downloads

47

Readme

#@wethecurious/wtc-exhibit-base-lib

Shared library for WTC Treatments using React. Used for both BrightSign device exhibits and PC-based web exhibits.

The recommended way to use this library is to create a new app using wtc-react-app-template. We don't recommend starting from scratch and using this library.

##Usage

All items are exported from the index:

import {BodyA, AppIcons /* etc */} from '@wethecurious/wtc-exhibit-base-libs'

Don't import from files 'inside' the library, only from the root

##See the full API documentation for all items

##AppText

Default typography for the app.

import {
    Heading, // capitalized text for title at top 
    Header1A, // huge title
    Header2A, // medium title
    Header3A, // normal ittle
    BodyA, // normal text
    BodyB, // small text
} from '#@wethecurious/wtc-exhibit-base-lib';

Use for in-app Typography. Sizes automatically scales for 2k and 4k screens.

Note due to a limitation on the BrightSign, we need to manually import the font to use in the index.html file.

<head>
    <link href="https://fonts.googleapis.com/css?family=Barlow:regular,medium&display=swap" rel="stylesheet">
</head>

##AppIcons

Common SVG icons for use in apps, stored as dataURLs.

Be sure to add quotes when using in background-image, e.g. background-image: url("${AppIcons.back}").

import {
 AppIcons
} from '#@wethecurious/wtc-exhibit-base-lib';
const Item  = styled.div`
    background-image: url("${AppIcons.back}")
    background-size: 100%;
`;

const Img = () => {
    return <img src={AppIcons.cross}/>
}

const FooterButtons = () => {
    return <FooterButtonsWrapper center>
        <FooterIconButton large src={AppIcons.tick}/>
    </FooterButtonsWrapper>
}

##Footer Buttons

In these apps, footer buttons are circular buttons centered on the footer 'line'.

To make it easier to lay these out, use , , . These can be used inside the 'Page' component. The layout will work only if the 'page' component fills the space on the screen left after the footer, and not if the page goes 'under' the footer.

const MyPage = () => {
    return (<>
        {/* my page content */}
        <FooterButtonsWrapper center>
            <FooterIconButton large src={AppIcons.tick} onClick={()=>{}}/>
        </FooterButtonsWrapper>
        <FooterButtonsWrapper leftPadding rightPadding>
            <FooterIconButton src={AppIcons.home} onClick={()=>{}}/>
            <div style={{flex:1}}/>
            <FooterIconButton src={AppIcons.next} onClick={()=>{}}/>
        </FooterButtonsWrapper>
    </>);
}

const CONTAINER_FLEX_STYLE = {display: 'flex', flex: 1, zIndex: 1};

const Main = () => {
  return (<>
    <Fade
      show={currentPage === 'myPage'}
      containerStyle={CONTAINER_FLEX_STYLE}
      onFadeOutComplete={handleFadeOutComplete} 
    >
      <MyPage/>
    </Fade>
    <FooterLandscape/>
  </>);
}

##Navigation with usePageNavigation

Used for animated transitions between pages.

Use with a string enum of all the page names in the app:

import {usePageNavigation, Fade} from '#@wethecurious/wtc-exhibit-base-lib';

type Page = 'attract' | 'results' | 'outro';

export const Main = () => {
    const {currentPage, navigateTo, handleFadeOutComplete} = usePageNavigation<Page>('attract' /* initial page */);

    const handleNext = () => {
        navigateTo('outro'); // Call navigateTo to go to other pages
    }

    // To be animated, each page should be wrapped in a <Fade/> component
    return <>
        <Fade
          show={currentPage === 'attract'}  // where 'attract' is a value in Page
          containerStyle={CONTAINER_ABS_STYLE} // e.g. full screen or flexed
          onFadeOutComplete={handleFadeOutComplete} // handleFadeOutComplete is returned by this usePageNavigation hook
        > .. your page here .. </Fade>
    </>
};

##Analytics

Features:

  • In-app viewer for recent redux messages
  • Automatic analytics for page changes (see usePageNavigation)
  • Automatic analytics for Media Controls usage (play/pause/replay) (see MediaControls)
  • Automatic analytics for Restart Screen (see RestartScreen)

Utils

Some useful hooks:

  • usePrevious: When you need the previous value of a prop, use this
  • useTheme: To grab the styled-components theme

##CMSAppDataProvider

download, validates, and provides access to data from the Treatment CMS

Place at the root of your application to enable the useCMSAppData. Also:

  • Makes the styled-components theme available to child items via useTheme.
  • Validates many aspects of the exhibits's data.
  • Catch errors during rendering, in lifecycle methods, and in constructors of the whole tree bellow CMSAppDataProvider, note that it won't catch errors in a callback for example. A custom error screen is displayed where a member of the Staff can unlock and see the log screen, the default password to do that is 115599 but it can be customized by defining REACT_APP_ADMIN_PIN in the .env file.

Additional Promise-based steps to complete before running the app can be passed in as startupTasks

  • staticTheme: To maintain the theme within your app source, pass in the theme here (can use e.g. import myTheme from './themes/json')
  • startupTasks: Promise for additional tasks to complete during startup. You're passed redux's dispatch prop if you want to dispatch actions to redux.

Example:

<MainWindow size="2k" orientation="landscape">
  <ReduxProvider store={store}>
    <CMSAppDataProvider<CMSContent> staticTheme={staticTheme} resolution="2k">
      {/* Now components in here can use `useCMSAppData` */}
    </CMSAppDataProvider>
  </ReduxProvider>
</MainWindow>

Note, in the above CMSContent is a generated TS type for the actual CMS content. We pass as a generic type parameter to allows the startupTasks to have strongly-typed access to the CMS content entries (e.g. object_glass_title).

MainWindow

Place at the root of the app to force a specific screensize

  • size: 2k, 4k
  • orientation: 'landscape' | 'portrait' | 'portraitUpsideDown'

Example:

 <MainWindow size="2k" orientation="landscape">
  <ReduxProvider store={store}>
    <CMSAppDataProvider staticTheme={staticTheme} contentSchema={contentSchema}>
      <BrowserRouter>
        <>
          {/* actual routes are here */}
        </>
      </BrowserRouter>
    </CMSAppDataProvider>
  </ReduxProvider>
  <CustomMouseCursor />
</MainWindow>

##See the full API documentation for all items