Skip to content

Commit

Permalink
chore: cleanup README and types
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Dec 10, 2023
1 parent f00db71 commit fc5758f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@ While looking around for a good option, I had trouble finding a timezone select

> This demo is also available in the `./examples` directory. Simply run `pnpm dev` in the root of the repository and the vite dev server will start, where you can then find the example app at [`localhost:3001`](http://localhost:3001).
We also have some **more examples** available on Codesandbox using this component with the datetime library `spacetime` ([example](https://codesandbox.io/s/react-timezone-select-usage-z37hf)) as well as with `moment` ([example](https://codesandbox.io/s/react-timezone-select-usage-moment-5n6vn)), as well as in Typescript using the new `Intl` browser API ([example](https://codesandbox.io/s/react-timezone-select-typescript-8lsv3?file=/src/App.tsx)) showing how one might use this component in a real application.

## 🏗️ Installing

```bash
npm install react-select react-timezone-select
// react-select is an optional peer dependency, unnecessary if using the hook
npm install react-timezone-select react-select
```
## 🔭 Usage
```jsx
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import TimezoneSelect from 'react-timezone-select'
import TimezoneSelect, { type ITimezone } from 'react-timezone-select'

const App = () => {
const [selectedTimezone, setSelectedTimezone] =useState(
const [selectedTimezone, setSelectedTimezone] = useState<ITimezone>(
Intl.DateTimeFormat().resolvedOptions().timeZone
)

Expand Down Expand Up @@ -97,7 +96,10 @@ You can append custom choices of your own, or fully replace the listed timezone
The `timezones` prop takes a dictionary of timezones. Don't worry, we'll prepend the `(GMT...)` part, you just have to pass the city(s) or region(s) you want in your label.
```jsx
import TimezoneSelect, { allTimezones } from 'react-timezone-select'
import TimezoneSelect, { type ITimezone, allTimezones } from 'react-timezone-select'

const [selectedTimezone, setSelectedTimezone] = useState<ITimezone>('Europe/Berlin')

<TimezoneSelect
value={selectedTimezone}
onChange={setSelectedTimezone}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-timezone-select",
"version": "3.0.1",
"version": "3.0.2",
"description": "Usable, dynamic React Timezone Select",
"scripts": {
"dev": "concurrently \"tsup src/index.tsx --format esm --watch\" \"cd example && pnpm dev\"",
Expand Down
1 change: 0 additions & 1 deletion src/types/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type TimezoneSelectOptions = {
labelStyle?: ILabelStyle
displayValue?: IDisplayValue
timezones?: ICustomTimezone
maxAbbrLength?: number
}

export type Props = Omit<ReactSelectProps<ITimezone, false>, 'onChange'> &
Expand Down

0 comments on commit fc5758f

Please # to comment.