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

ghost-spirit

v0.0.50

Published

tbc

Downloads

54

Readme

Spirit

Ghost's style guide, CSS framework, and component library.

Usage

Node/Express apps

First, install the package 🙂

yarn add -D --exact ghost-spirit

From here there are multiple entry points depending on the use case but typically you'll want a setup something like this:

bootstrap/index.js:

const spirit = require('ghost-spirit');
const hbs = require('express-hbs');

spirit.registerHelpers('brand', {hbs});

gulpfile.js

const spirit = require('ghost-spirit');

gulp.task('css', function () {
    gulp.src(['assets/css/app.css'])
        .pipe(spirit.gulpPostcss())
        .pipe(gulp.dest('public/'));
})

resources/assets/css/app.css

@import "spirit-brand.css";

NB: If you want the product styles rather than brand styles swap instances of brand for product, eg:

spirit.registerHelpers('product', {hbs});
@import "spirit-product.css";

Advanced config

If you need to modify the default Spirit postcss config you can do so like this:

let spirit = require('spirit');

gulp.task('css', function () {
    let config = spirit.postcssPluginConfig();

    // modify options for a default plugin
    config.options['autoprefixer'].browsers = ['last 1 versions'];

    // add a new plugin in a specific order, eg, before minification
    config.plugins.splice(config.plugins.indexOf('cssnano'), 0, 'css-awesome');
    config.options['css-awesome'] = {
        emojify: true
    };

    // remove a plugin
    config.plugins.splice(config.plugins.indexOf('cssnano'), 1);

    // finally pass the config as a param to spirit.gulpPostcss
    gulp.src(['assets/css/app.css'])
        .pipe(spirit.gulpPostcss(config))
        .pipe(gulp.dest('public/'));
});

Ember.js apps

See https://github.com/TryGhost/ember-cli-ghost-spirit

Development

yarn && cd components/SearchInput && yarn && cd ../../

Run

Publish

  • yarn ship

Search-Input component

The search box is a Glimmer.js component that can be found in /components/SearchInput. It's implementation is entirely client-side using a generated JSON file as the search index that is built as part of the standard gulp tasks.

The component is built as part of the default gulp tasks using the correct environment based on the NODE_ENV env var so there's no extra steps needed unless you want to modify the search component.

Updating the search data

The search index is generated from YAML front-matter located in the product view files. Each view file that you want to appear in the search results should have three pieces of data in the front-matter:

  • url (optional) - a relative URL where this entry can be located, if it's omitted then it will be calculated based on the file path
  • title - the text that should appear in the search results and is used for matching
  • keywords - any additional words that should be used for matching (can also be useful for providing alternatives, eg English/American spelling)

An example of the front-matter format from /resources/views/product/classes/font-weight.hbs:

---
title: Font Weight
keywords:
    - font-weight
    - typography
---

... view content ...

For this example the url will be generated as /product/classes/font-weight/. Note that the keywords includes a form that matches the CSS naming (font-weight), this is so that including the - in the search query will still match.

Developing the component

To start the Glimmer.js development server run the following:

  • cd components/SearchInput
  • ember serve

You can then access http://localhost:4200 where you can see a dummy sidebar containing the search component. Any changes you make to the component code will live-reload this screen.

It's also possible to run both the Spirit server and Glimmer.js dev server at the same time in two terminal tabs. If you do this then the Spirit pages will also livereload when the search component is rebuilt.

There are two primary files where 95% of the component development will occur:

  • components/SearchInput/src/ui/components/SearchInput/component.ts
  • components/SearchInput/src/ui/components/SearchInput/template.hbs

Differing class lists for the product/brand search inputs are defined in:

  • components/SearchInput/src/ui/components/SearchInputProduct/template.hbs
  • components/SearchInput/src/ui/components/SearchInputBrand/template.hbs

Glimmer.js doesn't yet allow passing through attributes via web component attributes so the above is a little hack so that we can have different input styles without unnecessary duplication.