codellyson / timezone-list

🌐 An extremely usable and dynamic React timezone selector

Home Page:https://codellyson.github.io/timezone-list

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

timezone-list-hook

This is a fork of ndom91/react-timezone-select with the following changes:

  • Removed react-select dependency
  • Exported only useTimezoneSelect and allTimezones

πŸͺ Hooks

import { useTimezoneSelect, allTimezones } from 'timezone-list-hook'

const labelStyle = 'original'
const timezones = {
  ...allTimezones,
  'Europe/Berlin': 'Frankfurt',
}

const customSelect = () => {
  const { options, parseTimezone } = useTimezoneSelect({
    labelStyle,
    timezones,
  })

  return (
    <select onChange={(e) => onChange(parseTimezone(e.currentTarget.value))}>
      {options.map((option) => (
        <option value={option.value}>{option.label}</option>
      ))}
    </select>
  )
}

OR

You can use the useTimezoneSelect hook to build your own custom timezone select component.

🚧 Contributing

Pull requests are always welcome! Please stick to repo settings (prettier, eslint, etc.), and if adding new features, please consider adding test(s) and documentation where appropriate!

About

🌐 An extremely usable and dynamic React timezone selector

https://codellyson.github.io/timezone-list

License:MIT License


Languages

Language:TypeScript 76.0%Language:HTML 17.3%Language:CSS 6.8%