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

@tehw0lf/contact-form

v0.18.5

Published

This provides a simple way to let your users contact you.

Downloads

29

Readme

contact-form

This provides a simple way to let your users contact you.

Installation

Peer Dependencies

The following dependencies are needed:

    @angular/animations
    @angular/common
    @angular/core
    @angular/forms
    @ngx-formly/core
    @ngx-formly/material
    @tehw0lf/mvc

Module

If it's not added already, please run ng add @angular/material prior to adding this module. Run ng add @tehw0lf/contact-form in the workspace root of your angular application.

Usage

The contact form component takes an apiCallback returning a boolean Observable as mandatory input. By default, this is set to a dummy function that returns true if the form's value contains a name and false if not. A more verbose error message can be provided by updating sendErrorMessage with the error message dynamically from the callback.

A form can be generated from an arbitrary model. By default, the form contains name, email and message fields.

<contact-form [apiCallback]="apiCallback"></contact-form>

In your component, set the apiCallback property. The naming of these variables is arbitrary:

// eslint-disable-next-line @typescript-eslint/no-explicit-any
apiCallback = (formValue: any) => {
  // run logic and send to api, return true on success and false on failure
  // update sendErrorText input with error text for more verbose error message
  if (formValue.name) {
    return of(true);
  } else {
    return of(false);
  }
};

On submitting the form, your API callback will be executed. The status will be reflected by a message that can be overridden by setting sendErrorText and sendSuccessfulText.

Form Generation

In order to generate the form, a config array can be provided. By default, the config array contains name, email and message fields without default values.

interface FormConfigEntry {
  field: string;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  value?: any;
  required?: boolean;
  type?: string;
}

formConfig: FormConfigEntry[] = [
    { field: 'name', required: true },
    { field: 'email', required: true },
    { field: 'message', required: true, type: 'textarea' }
  ];

Text

The message texts can optionally be specified.

sendSuccessfulText; //'E-Mail successfully sent';

sendErrorText; //'Send error';

Theming

The styles of form background, button and text can be customized with optional input parameters:

buttonStyle; /* {
    border: 'none',
    'background-color': '#333333',
    color: '#cc7832'
  }*/

formStyle; /* {
    color: '#437da8',
    'background-color': 'rgba(34, 34, 34, 0.75)',
    'backdrop-filter': 'blur(50px)',
    'box-shadow': '0 2px 10px rgba(0, 0, 0, 0.075)'
  }*/

textStyle; //{ color: '#cc7832' };

Development

Serve

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

Run ng build contact-form to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build (e.g. when building to publish to npm).

Running unit tests

Run ng test to execute the unit tests via Jest.

To Do

Apply Material Design Extract CSS variables

Contributing

Contributions are welcome, although the library is still in an alpha stage. Feel free to open a PR and I'll have a look!