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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@micropasts/grid-ref

v0.1.0

Published

Zero-dependency JavaScript Web Components for OSGB36 British National Grid references, WGS84 conversion, precision/obfuscation badges, and SVG grid-square previews.

Readme

@micropasts/grid-ref

Zero-dependency JavaScript Web Components for British National Grid (OSGB36 / EPSG:27700) references, WGS84 conversion, grid square precision/sensitivity indicators, and SVG grid-square previews.

Includes two custom elements built from the same core library:

  • <grid-ref> — Encapsulated Shadow DOM Web Component with CSS custom properties, ::part() selectors, and custom HTML template hooks.
  • <grid-ref-tw> — Light-DOM Web Component styled with Tailwind CSS utility classes and dark: variants.

Features

  • Pure ES2022 JavaScript: Zero runtime dependencies, no TypeScript build step, and works in vanilla HTML, static sites, or modern bundlers.
  • OSGB36 ↔ WGS84 Conversion: Parses 2-letter 100km grid tiles plus 2- to 10-digit references (TL10, TL 135 072, TL 1354 0728) and computes easting/northing, square precision (100km down to 1m), WGS84 centroids, bounding boxes, and GeoJSON polygons.
  • Findspot Sensitivity & Precision Context: Highlights square size and rounding level so coarse public findspots (10km or 1km) are visually distinct from site or trench coordinates.
  • Inline SVG Grid Preview: Renders a compact preview showing where the square sits within its parent 10km grid tile.
  • Cross-Component Event Sync: Emits and listens for heritage:select CustomEvents so maps, timelines, and panels stay coordinated.
  • Clipboard Copy with Fallback: Copies formatted grid and coordinate strings with a fallback when restricted clipboard contexts block navigator.clipboard.writeText.

Installation & Build

npm install @micropasts/grid-ref

Or build from source with zero external dependencies:

npm run build
npm run dev

npm run build generates:

  • dist/grid-ref.esm.js — ES Module bundle
  • dist/grid-ref.iife.js — Global <script> bundle (window.GridRefLib)
  • docs/index.html and docs/grid-ref.esm.js — Self-contained GitHub Pages demo

Usage

1. Tailwind CSS Light-DOM (<grid-ref-tw>)

<script type="module" src="./dist/grid-ref.esm.js"></script>

<p>
  Findspot recorded at
  <grid-ref-tw ref="TL 135 072" prevent-navigation>
    TL 135 072
  </grid-ref-tw>
  or rounded publicly to
  <grid-ref-tw ref="TL10" mode="inline"></grid-ref-tw>.
</p>

2. Shadow DOM (<grid-ref>)

Works anywhere without Tailwind CSS:

<grid-ref ref="SP910090">SP 910 090</grid-ref>

3. Synchronized Inspector Panel Mode

<grid-ref-tw mode="panel" listen="heritage:select" ref="TL 135 072"></grid-ref-tw>

4. Programmatic Helpers

import {
  parseGridRef,
  osgbToWgs84,
  buildGridSvg,
  emitGridSelect,
} from '@micropasts/grid-ref';

const parsed = parseGridRef('TL 135 072');
console.log(parsed.center, parsed.precisionLabel, parsed.geojson);

Customizing Styles

Tailwind Utility Overrides (<grid-ref-tw>)

Pass trigger-class or card-class on individual elements:

<grid-ref-tw
  ref="TL 135 072"
  trigger-class="text-amber-700 dark:text-amber-400"
  card-class="border-amber-500 ring-2 ring-amber-500/20">
  TL 135 072
</grid-ref-tw>

Or update GridRefTailwind.classes globally at startup.

Shadow DOM CSS Variables & ::part() (<grid-ref>)

grid-ref.custom-grid {
  --gr-accent: #d97706;
  --gr-border: #b45309;
  --gr-radius: 0.375rem;
  --gr-width: 360px;
}

grid-ref.custom-grid::part(title) {
  color: #f59e0b;
}

Custom HTML Template

import { GridRef } from '@micropasts/grid-ref';

GridRef.setTemplate((parsed, esc) => `
  <div>
    <strong>${esc(parsed.formatted)}</strong> (${esc(parsed.precisionLabel)})
    <div>${parsed.center.lat}, ${parsed.center.lon}</div>
  </div>
`);

Deploying to GitHub Pages

  1. Push to main (the included .github/workflows/pages.yml workflow runs npm run build and publishes ./docs).
  2. In GitHub repository Settings → Pages, set Source to GitHub Actions (or Deploy from a branch → main / /docs after running npm run build).

License

MIT