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

@open-tender/components

v5.1.6

Published

A component library built for use with the Open Tender open source web app

Downloads

66

Readme

@open-tender/components

A component library for use with the Open Tender open source web app: open-tender-web.

This library is only relevant for restaurant brands that are customers of Open Tender. To learn more about establishing an Open Tender account, please visit our website.

Installation

Install via yarn:

yarn add @open-tender/components

Or via npm:

npm install --save @open-tender/components

Purpose

This library handles some of the most complex components featured in the Open Tender web app, including:

  • button variations that come preconfigured with a brand's styles
  • map and autocomplete components for Google Maps
  • a menu item builder and its constituent components
  • all forms, including a highly complex <CheckoutForm />

The benefits of using this libray are many:

  • all components come with a restaurant brand's configured styles (which are passed down via an Emotion theme from the Open Tender web app)
  • forms, in general, are annoying, especially in React
  • the <CheckoutForm /> is super complex based on the flexibility of the Open Tender platform around different tender types, service charges, discounts, promo codes, gift cards, loyalty points, etc.
  • the menu item <Builder /> used to associate modifiers with a menu item handles a fairly complex set of rules across one or more modifier groups
  • Google Maps can be a pain to work with

These are all very important components, and if you leverage this library, you can drop them in and they all just work.

In addition, many of the components have been decoupled into custom hooks and presentational components so you can customize the presentation while getting all the complex functionality "for free" (the useBuilder custom hook is a prime example, and all of the forms are implemented this way).

In general, this library is designed to handle the hard stuff for you, so you can focus on the fun parts of designing and building a customized user experience.

Theme Support via Emotion

This library leverages Emotion for CSS-in-JS styled components and theme support via the @emotion/react and @emotion/styled packages (which are installed in the open-tender-web app).

The theme is passed down by the open-tender-web app, and you can read more about how this works via the Styling with Emotion section of the open-tender-web readme.

The punchline here is that all of these components come with a brand's styles built-in, which is helpful for things like buttons that come in four different variations.

Usage

Buttons

As noted above, one of the most common uses of this library in the open-tender-web app is for button variations. A brand can configure four different types of buttons that come in one of four possible color combinations. Here's an example:

import { ButtonStyled } from '@open-tender/components'
<ButtonStyled
  icon={<Home size={null} />}
  onClick={() => history.push('/')}
  size="big"
  color="secondary"
>
  Home
</ButtonStyled>

In this case, we're using the "big" button type and the "secondary" color scheme. You can see all of the possibilities in the buttons attribute of the example Open Tender theme.

Forms

Here's an example of using a form component:

import { ProfileForm } from '@open-tender/components'
const AccountProfile = () => {
  const dispatch = useDispatch()
  const { profile, loading, error } = useSelector(selectCustomer)
  const update = useCallback(
    (data) => dispatch(updateCustomer(data)),
    [dispatch]
  )

  return (
    <ProfileForm
      profile={profile}
      loading={loading}
      error={error}
      update={update}
    />
  )
}

As you can see above, the form receives data and a dispatch function from the open-tender-web app, and all of the inputs, error handling, etc. is handled by the <ProfileForm /> component. So you don't need to worry about creating all of the different inputs and handling user input - the inputs will automatically come with the brand's configured styles. Here's an example of what this form looks like:

image

Pretty complex, but all of the inputs are styled for you via the theme, which is configured by the brand in the Open Tender Admin Portal:

image

If you want to customize the inputs beyond what comes with the theme styles, then you can use the useProfileForm custom hook and build the inputs and form yourself, following the example of the <ProfileForm /> component in this library.

More Examples

You can see many more examples in the open-tender-web app itself.

Issues

If you find a bug or have a question, please file an issue on our issue tracker on GitHub.

License

MIT

About

Built and maintained by Open Tender.