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

@ryanliu6/xi

v2.1.0

Published

Project Xi is a component library for my personal Astro + Tailwind projects.

Downloads

683

Readme

Project Xi

npm version npm downloads License: MIT

Project Xi is a component library for Astro + Tailwind projects. They are personalized and may not fit your use-case! Feel free to modify to your liking!

[!NOTE] Version 1.x.x was unpublished as it was used for playing around with npm, and I did not realize that the same version number cannot be reused even if I unpublished the entire package. Version 2.0.0 represents the first stable release.

Installation

You can install the package from npm:

npm install @ryanliu6/xi

Setup

Styles

This library uses Tailwind CSS for styling. To use the components properly, you need to:

  1. Make sure you have Tailwind CSS installed in your project
  2. Add the library's CSS file to your project's Tailwind content configuration:
// tailwind.config.js
export default {
  content: [
    // ... your other content paths
    "./node_modules/@ryanliu6/xi/dist/**/*.js",  // Add this line
  ],
  // ... rest of your config
}

Components

BorderedButton

A button component with consistent styling and hover effects.

import { BorderedButton } from '@ryanliu6/xi';

<BorderedButton id="my-button">
  <p>Click me</p>
</BorderedButton>

All child elements are passed through to the button.

Card

A card component for displaying content with title, description, and tags.

import { Card } from '@ryanliu6/xi';
import type { Tag } from '@ryanliu6/xi';

const tags: Tag[] = [
  { name: 'JavaScript', colour: '#f7df1e' },
  { name: 'React', colour: '#61dafb' }
];

<Card
  title="My Project"
  description="A cool project"
  link="https://github.com/myproject"
  tags={tags}
/>

My current use-case is to display projects on my portfolio, for which Cards are clickable and will take the user to the project's GitHub repository or website. In my use-case, since the cards represent projects, the tags prop is used to display the languages used in the project. For a more generic use-case, tags could be used to display any other metadata, and colour is optional.

[!NOTE] This component is designed 100% to work with Astro's Markdown content translator in mind, and thus not much testing has been done with raw tags. Please report any issues with this component to me via GitHub issues!

IconedPopover

A popover component that can display either text or an icon as its trigger.

import { IconedPopover } from '@ryanliu6/xi';

<IconedPopover text="Click me">
  <div>Popover content</div>
</IconedPopover>

My current use-case is a dropdown menu for Mobile Navigation, hence the existence of this component.

[!NOTE] Currently implemented using @headlessui/react rather than scratch-implemented. Please report any issues with this component to them, unless I'm doing something wrong in particular!

TextLink

A styled link component.

import { TextLink } from '@ryanliu6/xi';

<TextLink
  href="https://example.com"
  title="Visit Example"
>
  Click here
</TextLink>

Represents a link that is styled to look like a text link, with an underline and a hover effect.

ThemeIcon

A theme toggle component for switching between light and dark modes.

import { ThemeIcon } from '@ryanliu6/xi';

<ThemeIcon />

An all-in-one component for toggling between light and dark modes. The theme is stored in local storage. To use this component, you'll need to also include the following in your Astro layout:

<html lang="en">
	<head>
    ...
		<script is:inline>
			const THEME_KEY = "theme";
			const THEME_DARK = "dark";

			if (typeof localStorage !== "undefined") {
				const storedTheme = localStorage.getItem(THEME_KEY) || THEME_DARK
				if (storedTheme == THEME_DARK) {
					document.documentElement.classList.add(THEME_DARK);
				} else {
					document.documentElement.classList.remove(THEME_DARK);
				}
			}
		</script>
	</head>

Styles

You can import pre-defined styles separately:

import {
  textStyle,
  mdStyle,
  bgColour,
  hoverColour,
  buttonStyle,
  linkStyle,
  flexStyle,
  shadowBorder,
  bodyBorder,
  mainBorder,
  marginalBorder
} from '@ryanliu6/xi/styles';

Types

The package includes TypeScript types:

import type { Tag } from '@ryanliu6/xi';
import { Themes } from '@ryanliu6/xi';

These are used in Card and ThemeIcon respectively. I don't forsee any use-case for Theme, but Tag can be used for any custom tags you wish for Card.

Requirements

  • React 18+
  • Tailwind CSS 3+
  • @headlessui/react 2+
  • @heroicons/react 2+