react-icons/fi#FiWatch JavaScript Examples

The following examples show how to use react-icons/fi#FiWatch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Clock.jsx    From 4IZ268-2021-2022-ZS with MIT License 6 votes vote down vote up
function Clock({ handleSwitch }) {
  return (
    <div className='group flex items-center'>
      <Tooltip
        content="after:content-['stopwatch']"
        position='left'
        method={() => handleSwitch('Stopwatch')}>
        <FiWatch size='1.5em' />
      </Tooltip>

      <ClockDisplay />

      <Tooltip
        content="after:content-['world_clock']"
        position='right'
        method={() => handleSwitch('Timezones')}>
        <FiGlobe size='1.5em' />
      </Tooltip>
    </div>
  )
}
Example #2
Source File: WorldClock.jsx    From 4IZ268-2021-2022-ZS with MIT License 5 votes vote down vote up
function WorldClock({ handleSwitch }) {
  const [timezones, setTimezones] = useState([])
  const [error, setError] = useState(null)
  const [isLoaded, setIsLoaded] = useState(false)

  useEffect(() => {
    Promise.all([fetch(NYC_TIME), fetch(LONDON_TIME), fetch(TOKYO_TIME)])
      .then(async ([aa, bb, cc]) => {
        const a = await aa.json()
        const b = await bb.json()
        const c = await cc.json()
        return [a, b, c]
      })
      .then(
        (result) => {
          setTimezones(result)
          setIsLoaded(true)
        },
        (error) => {
          setIsLoaded(true)
          setError(error)
        }
      )
  }, [])

  if (error) {
    return <div>Error: {error.message}</div>
  } else if (!isLoaded) {
    return <div className='loader'>Loading...</div>
  }

  return (
    <div className='group flex items-center'>
      <Tooltip
        content="after:content-['stopwatch']"
        position='left'
        method={() => handleSwitch('Stopwatch')}>
        <FiWatch size='1.5em' />
      </Tooltip>

      <div className='flex flex-col mt-8'>
        {timezones.map((timezone, idx) => (
          <div className='flex items-center' key={idx}>
            <ClockDisplay
              small
              offset={(timezone.raw_offset + timezone.dst_offset) / 3600}
            />
            <p>
              in{' '}
              {idx === 0
                ? 'New York, USA'
                : idx === 1
                ? 'London, UK'
                : 'Tokyo, Japan'}{' '}
              (GMT
              {(timezone.raw_offset + timezone.dst_offset) / 3600})
            </p>
          </div>
        ))}
      </div>

      <Tooltip
        content="after:content-['clock']"
        position='right'
        method={() => handleSwitch('Clock')}>
        <FiClock size='1.5em' />
      </Tooltip>
    </div>
  )
}