0.1.3 • Published 6 years ago

react-link-preview v0.1.3

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

LinkPreview React Component

A Thinkingbox Endeavour

Demo: LinkPreview Github Page

Adding it to your react project

import 'LinkPreview' from 'react-link-preview';

Forking this component

Start the dev server:
npm run dev

Compile the production version of the demo (do this before pushing to master or making an MR/PR):
npm run docs:prod

Compile the distribution version of the component (do this before pushing to master or to NPM):
npm run dist-build

What it is

This wrapper adds a modal preview to links or buttons -- on long-press -- that displays any react component you provide. A small progress bar shows the long-press progress. This is a very simple component that wraps the react-router-dom <Link /> component with a bit of added functionality.

How it works

Wrap any link or button with <LinkPreview></LinkPreview to get a modal pop-up preview of the component you supply. This might be the react route component you intend to send the user to, or another component with useful preview information.

This component is intended for use on mobile devices primarily, but can be toggled to be used on desktop as well.

Example usage:

<LinkPreview to="/preview-me"
              mobileOnly={false}
              loadBarAbove={false}
              previewComponent={<PreviewMe />}>
  This text can be any element you like instead
</LinkPreview>

Available properties:

PropertyDefaultRequired?Description
previewComponentN/AyesA component to show in the preview.
clickWindow500noThe window of time (ms) where a regular click is registered.
longPressTime1000noThe time (ms) it takes the user to hold before it's considered a longpress.
mobileOnlytruenoSetting this to false allows the preview to work on desktop, too.
loadBarAbovetruenoSettings this to false moves the longpress bar below your link.