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

@sthirupu/justfortesting

v1.0.0

Published

An Unstyled Svelte Component Library

Downloads

10

Readme

An Unstyled Svelte Component Library

About

drab focuses on providing JavaScript functionality where it's most useful. Many of the components are helpful wrappers around browser APIs. Whenever possible, components are progressively enhanced or provide a fallback noscript message. Additionally, transitions are disabled for users who prefer reduced motion.

This library takes a more opinionated approach compared to some headless UI libraries by providing the basic HTML structure for every component, as well as default positioning for elements like the sheet. However, these components can still be further customized using styles, slots, and slot props.

Install

If you haven't used Svelte before, start with the tutorial. drab works anywhere Svelte does.

npm install -D drab

Documentation

The library provides inline documentation for each component, allowing you to conveniently access the documentation by hovering over the component in your text editor after importing it. Additionally, every prop is documented using JSDoc and TypeScript. By hovering over a prop, you can retrieve its type and description.

These docs use the TailwindCSS Typography plugin. Styles on this site are based on shadcn/ui.

Other UI Libraries

drab is a collection of useful components, not a complete UI kit. If drab isn't what you are looking for, here are some other libraries to check out.

Styling

Components without styles can appear rather drab. You have the freedom to bring your own styles to these components. Using unstyled components allows you to selectively choose what you need and avoid being tied to any specific library.

To style the markup provided by the components, you can make use of global styles. Each component exports class and id props that can be leveraged for this purpose. This process can be expedited by utilizing CSS frameworks like TailwindCSS. Tailwind generates a global stylesheet based on the utility classes used in your project. The examples in this documentation are styled with Tailwind classes, but Tailwind does not have to be used with this library.

Stylesheet

Here's a SvelteKit example using CSS imported in a layout. By using a layout, these styles can be accessed anywhere.

/* src/app.css */
.button {
	border-radius: 5px;
	background-color: black;
	padding: 5px;
	color: white;
}
<!-- src/routes/+layout.svelte -->
<script>
	import "../app.css";
</script>

<slot />
<!-- src/routes/+page.svelte -->
<script>
	import { FullscreenButton } from "drab";
</script>

<FullscreenButton class="button" />

Global modifier

Alternatively, the :global() modifier can be used instead of a separate stylesheet.

<!-- src/routes/+page.svelte -->
<script>
	import { FullscreenButton } from "drab";
</script>

<FullscreenButton class="button" />

<style>
	:global(.button) {
		border-radius: 5px;
		background-color: black;
		padding: 5px;
		color: white;
	}
</style>

Contributing

Find an bug or have an idea? Feel free to create an issue on GitHub. drab is meant to house all kinds of components including ones outside of the standard UI elements.

Currently, drab has only one dependency - Svelte. Not to say it will never have another, but please consider this when proposing additional functionality. drab is meant to make the most of what Svelte and the web platform provide.

Since this is an unstyled library, simple components like a badge that can be easily created with HTML and CSS are not included.

Local Development

Contribute to the project, or use drab as a template for another component library. This library is built with SvelteKit, TypeScript, and npm. The package contents are located in src/lib, the site is contained within src/routes and src/site. If you are using this project as a template, be sure to update the adapter based on how you deploy.

Make changes

  1. Clone the repository
  2. npm install
  3. npm run dev -- --open

Add or edit a component

  1. Add or edit the component in src/lib/components/Component.svelte - if you're adding a new one, copy and paste an existing one to get started with the conventions
  2. Add or edit the example in src/routes/docs/Component/+page.svelte
  3. Document the component with an @component comment, include a description, and the @slots available. Add a placeholder @props and @example to the comment. These sections will be generated based on the JSDoc comment above each prop and the example route upon running npm run doc
  4. If new, add the link to src/site/components/NavItems.svelte
  5. Run npm run build to verify your build