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

xinjs-timezone-picker

v0.4.3

Published

a lightweight, mobile-friendly, self-contained timezone-picker web-component

Downloads

23

Readme

xinjs-timezone-picker

demo | github | npm | bundlejs

Copyright ©2023 Tonio Loewald

This is a web-component that provides a graphical timezone-picker, inspired by Apple's graphical timezone-picker.

<timezone-picker> has been made as compact and fast-loading as possible, by keeping the geometry to a minimum, computing as using data provided by Intl where possible, and generating the underlying SVG data on-the-fly.

The widget is designed so that the value of the <timezone-picker> element will always be a valid IANA timezone name, and it supports both a graphical picker and autocomplete based on the timezone name and the GMT offset, so you can get to "America/Los_Angeles" by typing "Los" or "-7".

Usage

HTML

import 'xin-timezone-picker'

And now you can use:

<timezone-picker timezone="Australia/Sydney"></timezone-picker>

Programmatically

import { timezonePicker } from 'xin-timezone-picker'
document.body.append(timezonePicker())

timezonePicker is a standard xinjs ElementCreator, i.e. a function that takes ElementPart parameters and returns an element of the type expected.

You can also obtain TimezonePicker, the class constructor for <timezone-picker>.

timezones, localTimezone, Timezone

Rather than using a static dataset of timezones, uses the Intl Javascript global to build timezones and determine the localTimezone. This both reduces the size of this component considerably and ensures it will match the behavior of the runtime environment exactly.

These are respectively of type Timezone[] and a Timezone, where:

interface Timezone {
  name: string    // the IANA name
  offset: number  // the offset from GMT in hours
  utc: string     // the timezone's UTC offset
}

Note that for some reason parcel is not recognizing that the Timezone interface is exported, so it's not exported.

Styling

You can style the by using CSS-Variables

By default, the is 400px wide and 231px tall.

--scale scales the map as a whole.

--map-ocean and --map-land set the map colors.

--active-color, --hover-opacity, --active-opacity set the timezone colors.

--hover-transition controls the animated transition of the timezones.

--inset, --padding, --input-bg, --input-radius, position the timezone <input>.

--font-size, --font-color, and --font-family control the text of the <input>

Acknowledgements

I've built on data I found in Keval Bhatt's excellent jQuery-based picker, found here https://github.com/kevalbhatt/timezone-picker

These things are a huge pain-in-the-ass to get right, and I actually ditched an SVG file I had paid to have built in favor of Keval's data. Bravo!

If you want to vastly improve this widget, a good place to start looking is IANA's web page which discusses not only their data, but other sources, and links to tools to build your own.

Fundamentally, there are tools out there to build GeoJSON layers for timezones and, combined with a fairly simple transformation (if you want to overlay one a compressed projection vs. on, say, a mapbox view), would give you the exact correct polygon data. The polygons module could then be used to simplify the polygons (the raw GeoJSON data is over 100MB!).

This is the approach I'd take if someone were actually paying me for this…