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

@apparts/web-components

v1.0.4

Published

Components for web applications

Downloads

20

Readme

#+TITLE: @apparts/web-components #+DATE: [2021-03-11 Thu] #+AUTHOR: Philipp Uhl

@apparts/web-components gives you some standard web components for forms, inputs and in general. They are lightweight, some are for making the use of Formik easier and more standardized.

  • Components
  • General purpose:

    • Button
    • Input
    • ErrorMessage
    • FadeIn
  • Formik specific:

    • If
    • IfElse
    • Row
    • GlobalError
    • IfDirty
    • FormikInput

** Button

The button component has all usual button props and these:

  • ~submit: <?boolean>~ :: Type should be "submit"
  • ~loading: <?boolean>~ :: The button should be disabled and show a loading animation
  • ~disabled: <?boolean>~ :: The button should be disabled

** Input

The input component has all usual input props and these:

  • ~label: ~ :: The inputs label text
  • ~name: ~ :: The inputs name and id
  • ~error: <?string>~ :: An error text that should be shown

** ErrorMessage

A styled error message that only renders if the ~message~ prop is given. Props:

  • ~message: <?string>~ :: The message that should be rendered

** FadeIn

A component that fades it's content in, on render. Props:

  • ~shown: <?bool>~ :: The content should be visible
  • ~children: ~ :: The content
  • ~min: <?number> = 0~ :: The opacity when invisible
  • ~max: <?number> = 1~ :: The opacity when visible
  • ~duration: <?number> = 1~ :: The duration of the fade in in seconds
  • ~style: <?object>~ :: A style for the wrapper

** If

Formik specific component. Render children, if some condition is true in the Formik input values. Props:

  • ~children: ~ :: The children to be rendered
  • ~test: ~ :: The test function, it will be given the values from the formik context as parameter. If it returns true, the content will be rendered.

** IfElse

Formik specific component. Render children, if some condition is true in the Formik input values. Props:

  • ~then: ~ :: The children to be rendered if condition met
  • ~elze: ~ :: The children to be rendered if condition not met
  • ~test: ~ :: The test function, it will be given the values from the formik context as parameter. If it returns true, the ~then~ part will be rendered, if returns false, the ~elze~ part will be rendered.

** Row

Formik specific component. Renders inputs in a row that wraps at a specifiable width. Props:

  • ~children: ~ :: The content to be rendered in a row
  • ~minWidth: <?number> = 200~ :: The minium width of the items
  • ~margin: <?number> = 5~ :: The margin between the children
  • ~containerStyle: <?object>~ :: Style of the container
  • ~rowStyle: <?object>~ :: Style for each element

** GlobalError

Formik specific component. Renders an error if any field of the form has an error. Useful, e.g. to display a warning near the submit button that explains, that there is an issue present. Props:

  • ~message: ~ :: The message to be rendered.

** IfDirty

Formik specific component. Renders it's content, only if the formik form is dirty. Useful, e.g., to display a react-routes prompt when leaving a page, but only if the user has unsaved input. Takes no props.

To prevent the form to be dirty after submitting, you can use this line in your =onSubmit= handler function:

#+BEGIN_SRC js const onSubmit = (fields, actions) => { // do the saving, etc. Then, on success: actions.resetForm({ values: fields }); }; #+END_SRC

** FormikInput

Formik specific component. An input field with an error field and a label.

The FormikInput component has all usual (formik) input props and these:

  • ~label: ~ :: The inputs label text
  • ~name: ~ :: The inputs name and id
  • Usage

Import the default style, or create your own style based on the default one.

#+BEGIN_SRC js // The default style: import "@apparts/web-components/style.css"; #+END_SRC

To keep the given style sheet but alter the color scheme, just redefine these CSS variables with your color scheme:

#+BEGIN_SRC css :root { --dark-0: #0c0e0e; --dark-1: #23292a; --dark-2: #394546; --dark-3: #516062; --dark-4: #677b7e;

--bright-0: #d8dedf; --bright-1: #e1e6e6; --bright-2: #eaedee; --bright-3: #f3f5f5; --bright-4: #fcfdfd;

--primary-0: #144a52; --primary-1: #1b636d; --primary-2: #227c88; --primary-3: #2995a3; --primary-4: #30aebe; --primary-5: #41bfcf; --primary-6: #5cc8d6; --primary-7: #77d1dd; --primary-8: #92dae4; --primary-9: #ade3eb;

--secondary-0: #521c14; --secondary-1: #6d251b; --secondary-2: #882e22; --secondary-3: #a33729; --secondary-4: #be4030; --secondary-5: #cf5141; --secondary-6: #d66a5c; --secondary-7: #dd8377; --secondary-8: #e49c92; --secondary-9: #ebb5ad;

--green-0: #145214; --green-1: #248f24; --green-2: #33cc33; --green-3: #70db70; --green-4: #adebad;

--yellow-0: #525214; --yellow-1: #8f8f24; --yellow-2: #cccc33; --yellow-3: #dbdb70; --yellow-4: #ebebad;

--red-0: #521414; --red-1: #8f2424; --red-2: #cc3333; --red-3: #db7070; --red-4: #ebadad; } #+END_SRC