1.2302271541.0 • Published 1 year ago

@bentoproject/reddit v1.2302271541.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Bento Reddit

Embeds a Reddit post or a comment on a Reddit post.

Web Component

You must include each Bento component's required CSS library before adding custom styles in order to guarantee proper loading. Or use the lightweight pre-uprgrade styles available inline. See Layout and Style.

Import via npm

npm install @bentoproject/reddit
import {defineElement as defineBentoReddit} from '@bentoproject/reddit';
defineBentoReddit();

Include via <script>

<script type="module" src="https://cdn.ampproject.org/bento.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/bento.js" crossorigin="anonymous"></script>
<script type="module" src="https://cdn.ampproject.org/v0/bento-reddit-1.0.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/v0/bento-reddit-1.0.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-reddit-1.0.css" crossorigin="anonymous">

Example

Embed a Reddit Post
<!DOCTYPE html>
<html>
    <head>
      <script type="module" src="https://cdn.ampproject.org/bento.mjs" crossorigin="anonymous"></script>
      <script nomodule src="https://cdn.ampproject.org/bento.js" crossorigin="anonymous"></script>
      <script type="module" src="https://cdn.ampproject.org/v0/bento-reddit-1.0.mjs" crossorigin="anonymous"></script>
      <script nomodule src="https://cdn.ampproject.org/v0/bento-reddit-1.0.js" crossorigin="anonymous"></script>
      <link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-reddit-1.0.css" crossorigin="anonymous">
      <style>
          bento-reddit {
              width: 300px;
              height: 400px;
          }
      </style>
    </head>
    <body>
      <bento-reddit
        style="width: 300; height: 400;"
        data-embed-type="post"
        data-src="https://www.reddit.com/r/me_irl/comments/52rmir/me_irl/?ref=share&amp;ref_source=embed"
      >
      </bento-reddit>
    </body>
</html>
Embed a Reddit Comment
<!DOCTYPE html>
<html>
    <head>
      <script type="module" src="https://cdn.ampproject.org/bento.mjs" crossorigin="anonymous"></script>
      <script nomodule src="https://cdn.ampproject.org/bento.js" crossorigin="anonymous"></script>
      <script type="module" src="https://cdn.ampproject.org/v0/bento-reddit-1.0.mjs" crossorigin="anonymous"></script>
      <script nomodule src="https://cdn.ampproject.org/v0/bento-reddit-1.0.js" crossorigin="anonymous"></script>
      <link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-reddit-1.0.css" crossorigin="anonymous">
      <style>
          bento-reddit {
              width: 300px;
              height: 400px;
          }
      </style>
    </head>
    <body>
      <bento-reddit
        style="width: 300; height: 400;"
        data-embed-type="comment"
        data-src="https://www.reddit.com/r/sports/comments/54loj1/50_cents_awful_1st_pitch_given_a_historical/d8306kw"
        data-uuid="b1246282-bd7b-4778-8c5b-5b08ac0e175e"
        data-embed-created="2016-09-26T21:26:17.823Z"
        data-embed-parent="true"
        data-embed-live="true"
      >
      </bento-reddit>
    </body>
</html>

Layout and Style

Each Bento component has a small CSS library you must include to guarantee proper loading without content shifts. Because of order-based specificity, you must manually ensure that stylesheets are included before any custom styles.

<link
  rel="stylesheet"
  type="text/css"
  href="https://cdn.ampproject.org/v0/bento-reddit-1.0.css"
/>

Alternatively, you may also make the light-weight pre-upgrade styles available inline:

<style>
  bento-reddit{
    display: block;
    overflow: hidden;
    position: relative;
  }
</style>

Attributes

data-embedtype

The type of the embed, either post or comment.

data-src

The permalink uri for the post or comment.

data-uuid(optional)

The provided UUID for the comment embed. Supported when data-embedtype is comment.

data-embedcreated (optional)

The datetime string for the comment embed. Supported when data-embedtype is comment.

data-embedparent (optional)

Indicates whether the parent comment for the embedded comment should be displayed. Supported when data-embedtype is comment.

data-embedlive (optional)

Indicates whether the embedded comment should update if the original comment is updated. Supported when data-embedtype is comment.

title (optional)

Define a title attribute for the component. The default is Reddit.

Preact/React Component

Import via npm

npm install @bentoproject/reddit
import React from 'react';
import {BentoReddit} from '@bentoproject/reddit/react';
import '@bentoproject/reddit/styles.css';

function App() {
  return (
      <BentoReddit
        style={{width: 300, height: 200, border: '8px solid red'}}
        embedType="post"
        src="https://www.reddit.com/r/me_irl/comments/52rmir/me_irl/?ref=share&amp;ref_source=embed"
      ></BentoReddit>
  );
}

Props

embedType

The type of the embed, either post or comment.

src

The permalink uri for the post or comment.

uuid(optional)

The provided UUID for the comment embed. Supported when data-embedtype is comment.

embedCreated (optional)

The datetime string for the comment embed. Supported when data-embedtype is comment.

embedParent (optional)

Indicates whether the parent comment for the embedded comment should be displayed. Supported when data-embedtype is comment.

embedLive (optional)

Indicates whether the embedded comment should update if the original comment is updated. Supported when data-embedtype is comment.

title (optional)

Define a title attribute for the component. The default is "Reddit".

1.2302171719.0

1 year ago

1.2302271541.0

1 year ago

1.2302031721.0

1 year ago

1.2301301810.0

1 year ago

1.2301041800.0

1 year ago

1.2301112346.0

1 year ago

1.2302021743.0

1 year ago

1.2301031703.0

1 year ago

1.2301181928.0

1 year ago

1.2301032153.0

1 year ago

1.2301261900.0

1 year ago

1.2301100345.0

1 year ago

1.2302012254.0

1 year ago

1.2212151632.2

1 year ago

1.2211042305.0

2 years ago

1.2210272257.0

2 years ago

1.2211111611.0

1 year ago

1.2211060024.0

2 years ago

1.2211182146.0

1 year ago

1.2210191347.0

2 years ago

1.2211250451.0

1 year ago

1.2211302304.0

1 year ago

1.2211302304.2

1 year ago

1.2211302304.1

1 year ago

1.2211151402.0

1 year ago

1.2210251605.0

2 years ago

1.2210172057.0

2 years ago

1.2212092023.0

1 year ago

1.2212151632.1

1 year ago

1.2210211855.0

2 years ago

1.2212151632.0

1 year ago

1.2212071834.0

1 year ago

1.2210112333.0

2 years ago

1.2210142102.0

2 years ago

1.2210052034.0

2 years ago

1.2210010655.0

2 years ago

1.2210071758.0

2 years ago

1.2210041838.0

2 years ago

1.2208242209.0

2 years ago

1.2208242209.1

2 years ago

1.2209142312.0

2 years ago

1.2209072154.0

2 years ago

1.2209131909.0

2 years ago

1.2208172101.0

2 years ago

1.2208112015.0

2 years ago

1.2207201724.0

2 years ago

1.2206082301.0

2 years ago

1.2208081650.0

2 years ago

1.2205270638.4

2 years ago

1.2206071918.0

2 years ago

1.2206071918.1

2 years ago

1.2205120110.1

2 years ago

1.2205270638.0

2 years ago

1.2206131450.0

2 years ago

1.2208092047.0

2 years ago

1.2207071723.0

2 years ago

1.2208121708.0

2 years ago

1.2208021808.0

2 years ago

1.2206291614.0

2 years ago

1.2207181727.0

2 years ago

1.2206221455.0

2 years ago

1.2207221643.0

2 years ago

1.2208042017.0

2 years ago

1.2205232225.0

2 years ago

1.2208051912.0

2 years ago

1.2208051912.1

2 years ago

1.2206072228.0

2 years ago

1.2207281718.2

2 years ago

1.2207281718.1

2 years ago

1.2207281718.0

2 years ago

1.2207261725.0

2 years ago

1.2206101637.0

2 years ago

1.2205251942.0

2 years ago

1.2206162023.0

2 years ago

1.2205031420.0

2 years ago

1.2205181800.0

2 years ago

1.2204281949.0

2 years ago

1.2205120110.0

2 years ago

1.2204252045.0

2 years ago

1.2205161914.0

2 years ago

1.2205051832.0

2 years ago

1.2205191749.0

2 years ago

1.2204292129.0

2 years ago

1.2204272205.0

2 years ago

1.2205090810.0

2 years ago

1.2205101904.0

2 years ago

1.2205041533.0

2 years ago

1.2204221712.0

2 years ago

1.2204211736.0

2 years ago

1.2204191429.0

2 years ago

1.2204182206.0

2 years ago

1.2204160405.0

2 years ago

1.2204142048.0

2 years ago

1.2204132005.0

2 years ago

1.2204122000.0

2 years ago

1.2204121632.0

2 years ago

1.2203281422.0

2 years ago

1.2203101844.0

2 years ago

1.2203231914.0

2 years ago

1.2203221937.0

2 years ago

1.2203172113.0

2 years ago

1.2203151539.0

2 years ago

1.2203041950.0

2 years ago