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

@bratislava/component-library

v0.1.2

Published

## Available Scripts

Downloads

63

Readme

Component library

Available Scripts

In the project directory, you can run:

npm run dev

Runs the app for local development.
Open http://localhost:5173/ to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm run build

Builds the app to the dist folder, ready to be published or locally tested as a library.

Local testing with Yalc

For local testing our library without the necessity to publish to npm, you can use a small local repository called yalc
You can find complete documentation here.

Instalation

Using NPM:

npm i yalc -g

Using Yarn:

yarn global add yalc

Publishing built version to local repository

First we need to publish our library in order to be able to deploy it:

npm run build

Then you can publish current built version of this library using:

yalc push --sig

It will copy all the files that should be published in remote NPM registry. We are using --sig flag, to ensure that the dependent project knows, that something has changed. Otherwise it will keep the last imported version in cache and not propagate current changes.

Import local library

To import our published library into dependent project you can use:

yalc link @bratislava/component-library

Now you can use the imported library in your code as such:

import { Input, Button } from '@bratislava/component-library'

Remove imported library

To remove the imported library you can use:

yalc remove @bratislava/component-library

Alternatively to remove all imported libraries use:

yalc remove --all

TS config

Short explanation of tsconfig usage in this library.

tsconfig-build.json

We want to exclude /src from building, because its use is only for local dev. Because of that we use extension of our base tsconfig.json to exclude it for build. This extended config needs to be referenced later in build script

tsc --p ./tsconfig-build.json && vite build

Using ComponentLibraryEnvironmentContext for native Next components

For harnessing functionality of Next native components along with functionalities of components of this library, you need to import ComponentLibraryEnvironmentContext from '@bratislava/component-library'. It exposes provider.

  1. create wrapper for next/link

Example:

const LinkWrapper = ({
  href,
  children
}: {
  href: string;
  children: React.ReactNode
}) => {
  return <Link href={href}>{children}</Link>
}
  1. Wrap consuming app in this provider f.e. in index.tsx and pass LinkWrapper as value in ComponentLibraryEnvironmentContext.Provider
       <ComponentLibraryEnvironmentContext.Provider value={{Link: LinkWrapper}}>
           <PageLayout>         
             <HomepageContent />
           </PageLayout>
       </ComponentLibraryEnvironmentContext.Provider>
  1. This will provide next/link context for AriaAnchor component from library, when it's imported and used inside of components wrapped in Provider Go to example