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

my-fa-input

v0.0.1

Published

[angular-advanced-course](https://angular-university.io/course/angular-advanced-course)

Downloads

1

Readme

Building an Angular Library

angular-advanced-course

Run yarn to install dependencies.

Run npm start to start development server.

This is my coursework for Angular University's "Angular Advanced Library Laboratory: Build Your Own Library" course.

Branches au-input : First Section of the Course 1-create-lib 2-content-projection 3-mimic-default-behaviour 4-design-component-styling 5-setup-for-distribution 6-testing

Steps

First, design the public API for the library.

  • START MAKING LIB

  • Make a lib folder for public components.

  • Design component API with @Input().

  • [ngClass] works great with a getter method

  • Style components. Angular gives us good (but not perfect) style encapsulation

  • use :host

  • CONTENT PROEJCTION

  • Zoom in and out to see how well the structural styles hold up.

  • AVOID wrapping regular HTML attributes by using Content Projection.

  • If using content projection, you'll need to override the styles of the projected element

  • If you need to break style encapsulation use :host ::ng-deep <component>

  • MIMIC DEFAULT BEHAVIOUR

  • You could use template references and @ContentChild() to get a reference to the element being passed in to the component

  • However, that's not usually what you will want to do. Instead, make a directive that selects any html element that you are looking for, and pass that directive to @ContentChild()

  • In Angular, it is often practical to not reference projected content directly.

  • Add a helpful error message with ngAfterContentInit to make sure the component is loaded correctly.

  • Use @HostBinding to implement state classes for projected content

  • DESIGN COMPONENT STYLING

  • Separate Structural styles from Theme styles

  • :host-context() selects by working with class names defined outside the component. It is very useful for providing extra themes in our library.

  • Angular has style isolation mechanisms that work differently from regular CSS.

  • The default Angular style isolation mechanism, Emulated View Encapsulation, is design to give us good assurance than our styles will be encapsulated when used in other projects

  • Most of the time we will want to use Emulated View Encapsulation

  • SETUP FOR DISTRIBUTION

  • Make sure AoT Compilation is on.

  • Make a module file that has the same name as the npm package you will create.

  • Add to package.json "serve:prod": "ng serve --prod --aot",

  • Setup an index.ts at the root of application and export the new module.

  • TESTING

  • This is a scenario where we need to do an INTEGRATION test because our component will be integrating into other people's code.

  • Start by giving your component pieces unique ids

  • Add a test class to content that is being projected so that its existance can be tested

  • Setup an app level test by configuring the testing module to have AppComponent AuFaInputComponent and InputRefDirective.

  • Write some tests

  • For integrated tests you may need to run Angular Change Detection to ensure that your expectations are working with elements that have been fully processed

  • fixture is a very helpful class that has all kinds of useful debugging features like .debugElement .nativeElement

  • There is a By.css helper to select pieces from the component under test.

  • PUBLISH TO NPM

  • Using the npm package format is the most recommended for open-source. However, if you want to keep the library private it's actually simpler to publish.