Giter VIP home page Giter VIP logo

cardboard's Introduction

Cardboard

An OEmbed data fetch service and component for React.

Features

  • Fetches OEmbed data from a URL, e.g. YouTube, Twitter, etc.
  • Implements discovery of OEmbed data from HTML pages
  • Centralizes scripts in a provider to avoid duplicates

Service

POST to https://cardboard-web.vercel.app/api/v1 with a JSON body containing a url property with the URL to fetch.

Optional properties:

  • maxwidth - The maximum width of the embed
  • maxheight - The maximum height of the embed

Full request and response details can be found on the OEmbed spec.

You can deploy your own service by cloning this repository and deploying packages/web. Vercel is recommended.

Component

NPM link: https://www.npmjs.com/package/@sarim.garden/cardboard

npm install @sarim.garden/cardboard

You can also use yarn or pnpm.

Use the component like so:

import { CardboardProvider, Cardboard } from "@sarim.garden/cardboard";

const App = () => {
  return (
    <CardboardProvider>
      <Cardboard url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" />
    </CardboardProvider>
  );
};

Here are the props:

export interface CardboardProviderProps {
  children: React.ReactNode;
  // override the provider to use. Default: https://cardboard-web.vercel.app/api/v1
  providerService?: string;
}

export interface CardboardProps {
  // the url to embed
  url: string;
  // the max width of the embed
  maxwidth?: string;
  // the max height of the embed
  maxheight?: string;
  // the placeholder to show while loading
  placeholder?: React.ReactNode;
  // the error to show if the embed fails
  error?: React.ReactNode;
  // classes to apply to the embed
  className?: string;
  // attempt to make the embed responsive (experimental)
  forceFit?: boolean;
}

cardboard's People

Contributors

sarimabbas avatar

Watchers

 avatar  avatar

cardboard's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.