All Projects β†’ jaredpalmer β†’ The Platform

jaredpalmer / The Platform

Licence: mit
Web. Components. πŸ˜‚

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to The Platform

react-europe-2019
Slides and demo app from my keynote
Stars: ✭ 29 (-99.33%)
Mutual labels:  hooks, suspense, react-suspense, react-hooks
Use Http
🐢 React hook for making isomorphic http requests
Stars: ✭ 2,066 (-52.56%)
Mutual labels:  suspense, react-suspense, react-hooks
use-async-resource
A custom React hook for simple data fetching with React Suspense
Stars: ✭ 92 (-97.89%)
Mutual labels:  suspense, react-suspense, react-hooks
max-todos
A basic Todo app developed in React.
Stars: ✭ 19 (-99.56%)
Mutual labels:  hooks, react-hooks
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (-95.96%)
Mutual labels:  hooks, react-hooks
use-metamask
a custom React Hook to manage Metamask in Ethereum ĐApp projects
Stars: ✭ 131 (-96.99%)
Mutual labels:  hooks, react-hooks
jedisdb
redis like key-value state management solution for React
Stars: ✭ 13 (-99.7%)
Mutual labels:  hooks, react-hooks
react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (-98.05%)
Mutual labels:  hooks, react-hooks
reason-hooks-lib
A set of reusable ReasonReact hooks.
Stars: ✭ 31 (-99.29%)
Mutual labels:  hooks, react-hooks
Beautiful React Hooks
πŸ”₯ A collection of beautiful and (hopefully) useful React hooks to speed-up your components and hooks development πŸ”₯
Stars: ✭ 5,242 (+20.37%)
Mutual labels:  hooks, react-hooks
React-Combine-Provider
combine react providers in ease
Stars: ✭ 29 (-99.33%)
Mutual labels:  hooks, react-hooks
tacklebox
🎣React UX components for handling common interactions
Stars: ✭ 15 (-99.66%)
Mutual labels:  hooks, react-hooks
use-detect-print
A react hook to detect when a page is being printed
Stars: ✭ 55 (-98.74%)
Mutual labels:  hooks, react-hooks
use-window-focus
React Hook to check if window is focused
Stars: ✭ 19 (-99.56%)
Mutual labels:  hooks, react-hooks
no-redux
βš›οΈ 🎣 Experimenting with using hooks and context instead of Redux
Stars: ✭ 79 (-98.19%)
Mutual labels:  hooks, suspense
atomic-state
A decentralized state management library for React
Stars: ✭ 54 (-98.76%)
Mutual labels:  hooks, react-hooks
Swr
React Hooks for data fetching
Stars: ✭ 20,348 (+367.23%)
Mutual labels:  hooks, suspense
Easy Peasy
Vegetarian friendly state for React
Stars: ✭ 4,525 (+3.9%)
Mutual labels:  hooks, react-hooks
use-app-state
🌏 useAppState() hook. that global version of setState() built on Context.
Stars: ✭ 65 (-98.51%)
Mutual labels:  hooks, react-hooks
use-query-string
πŸ†™ A React hook that serializes state into the URL query string
Stars: ✭ 50 (-98.85%)
Mutual labels:  hooks, react-hooks

Repo Banner

The Platform

Blazing Fast Discord Discord

Web API's turned into React Hooks and Suspense-friendly React components. #useThePlatform

Install

Note: React 16.8+ is required for Hooks.

With npm

npm i the-platform --save

Or with yarn

yarn add the-platform

Examples

API

Hooks

useDeviceMotion()

Detect and retrieve current device Motion.

Returns

DeviceMotionEvent

Example

import { useDeviceMotion } from 'the-platform';

const Example = () => {
  const { acceleration, rotationRate, interval } = useDeviceMotion();

  // ...
};

useDeviceOrientation()

Detect and retrieve current device orientation.

Returns

DeviceOrientationEvent

Example

import { useDeviceOrientation } from 'the-platform';

const Example = () => {
  const { alpha, beta, gamma, absolute } = useDeviceOrientation();

  // ...
};

useGeoPosition()

Retrieve Geo position from the browser. This will throw a promise (must use with Suspense).

Arguments

PositionOptions

Returns

Position

Example

import { useGeoPosition } from 'the-platform';

const Example = () => {
  const {
    coords: { latitude, longitude },
  } = useGeoPosition();

  // ...
};

useNetworkStatus()

Retrieve network status from the browser.

Returns

Object containing:

  • isOnline: boolean: true if the browser has network access. false otherwise.

  • offlineAt?: Date: Date when network connection was lost.

Example

import { useNetworkStatus } from 'the-platform';

const Example = () => {
  const { isOnline, offlineAt } = useNetworkStatus();

  // ...
};

useMedia()

Arguments

query: string | object: media query string or object (parsed by json2mq). defaultMatches: boolean: a boolean providing a default value for matches

Returns

match: boolean: true if the media query matches, false otherwise.

Example

import { useMedia } from 'the-platform';

const Example = () => {
  const small = useMedia('(min-width: 400px)');
  const medium = useMedia({ minWidth: 800 });

  // ...
};

useScript()

This will throw a promise (must use with Suspense).

Arguments

Object containing:

  • src: string: The script's URI.
import { useScript } from 'the-platform';

const Example = () => {
  const _unused = useScript({ src: 'bundle.js' });

  // ...
};

useStylesheet()

This will throw a promise (must use with Suspense).

Arguments

Object containing:

  • href: string: The stylesheet's URI.
  • media?: string: Intended destination media for style information.
import { useStylesheet } from 'the-platform';

const Example = () => {
  const _unused = useStylesheet({ href: 'normalize.css' });

  // ...
};

useWindowScrollPosition()

Returns

Object containing:

  • x: number: Horizontal scroll in pixels (window.pageXOffset).
  • y: number: Vertical scroll in pixels (window.pageYOffset).

Example

import { useWindowScrollPosition } from 'the-platform';

const Example = () => {
  const { x, y } = useWindowScrollPosition();

  // ...
};

useWindowSize()

Returns

Object containing:

  • width: Width of browser viewport (window.innerWidth)
  • height: Height of browser viewport (window.innerHeight)

Example

import { useWindowSize } from 'the-platform';

const Example = () => {
  const { width, height } = useWindowSize();

  // ...
};

Components

<Img>

Props

  • src: string
  • anything else you can pass to an <img> tag
import React from 'react';
import { Img } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Hello</h1>
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Img src="https://source.unsplash.com/random/4000x2000" />
      </React.Suspense>
    </div>
  );
}

export default App;

<Script>

Props

  • src: string
  • children?: () => React.ReactNode - This render prop will only execute after the script has loaded.
  • anything else you can pass to a <script> tag
import React from 'react';
import { Script } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Load Stripe.js Async</h1>
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Script src="https://js.stripe.com/v3/" async>
          {() => console.log(window.Stripe) || null}
        </Script>
      </React.Suspense>
    </div>
  );
}

export default App;

<Video>

Props

  • src: string
  • anything else you can pass to a <video> tag
import React from 'react';
import { Video } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Ken Wheeler on a Scooter</h1>
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Video
          src="https://video.twimg.com/ext_tw_video/1029780437437014016/pu/vid/360x640/QLNTqYaYtkx9AbeH.mp4?tag=5"
          preload="auto"
          autoPlay
        />
      </React.Suspense>
    </div>
  );
}

export default App;

<Audio>

Props

  • src: string
  • anything else you can pass to a <audio> tag
import React from 'react';
import { Audio } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Meavy Boy - Compassion</h1>
      {/* source: http://freemusicarchive.org/music/Meavy_Boy/EP_71_to_20/Compassion */}
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Audio src="https://file-dnzavydoqu.now.sh/" preload="auto" autoPlay />
      </React.Suspense>
    </div>
  );
}

export default App;

<Preload>

Preload a resource with <link rel="preload">. For more information check out MDN or the Google Developer Blog.

Props

  • href: string
  • as: string - resource type
import React from 'react';
import { Preload, Script } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Preload</h1>
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Preload href="https://js.stripe.com/v3/" rel="preload" as="script" />
        <Script src="https://js.stripe.com/v3/" async />
      </React.Suspense>
    </div>
  );
}

export default App;

<Stylesheet>

Lazy load a stylesheet.

Props

  • href: string
import React from 'react';
import { Stylesheet } from 'the-platform';

function App() {
  return (
    <div>
      <h1>Styles</h1>
      <React.Suspense maxDuration={300} fallback={'loading...'}>
        <Stylesheet href="style.css" />
      </React.Suspense>
    </div>
  );
}

export default App;

Authors

Inspiration


MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].