npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

origen-react-instagram-feed

v0.0.3

Published

Get the information from a public Instagram profile without need to access the API

Downloads

95

Readme

origen-react-instagram-feed

Yes, react-instagram-feed would be a better name but it was taken...

Quick start

  1. Install
npm install --save origen-react-instagram-feed || yarn add origen-react-instagram-feed
  1. Use it in a component

Quick recipe for use with Material-UI

// @flow

import * as React from 'react';
import withInstagramFeed from 'origen-react-instagram-feed';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import ButtonBase from '@material-ui/core/ButtonBase';
import compose from 'recompose/compose';

const styles = () => ({
  wrapper: {},
  image: {
    width: '100%',
    height: '100%',
  },
});

export type Props = {
  media?: Array<{
    displayImage: string,
    id?: string,
    postLink?: string,
    accessibilityCaption?: string,
  }>,
  account: string,
  classes: { [$Keys<$Call<typeof styles>>]: string },
  status: 'completed' | 'loading' | 'failed',
};

const InstaGrid = ({ classes, media, account, status}: Props) => {
  return (
    <Grid container spacing={32} className={classes.wrapper}>
      {media &&
        status === 'completed' &&
        media.map(({ displayImage, id, postLink, accessibilityCaption }) => (
          <Grid item xs={12} sm={6} md={4} key={id || displayImage}>
            <ButtonBase
              href={postLink || `https://www.instagram.com/${account}/`}
            >
              <img
                src={displayImage}
                alt={accessibilityCaption || 'Instagram picture'}
                className={classes.image}
              />
            </ButtonBase>
          </Grid>
        ))}
      {status === 'loading' && <p>loading...</p>}
      {status === 'failed' && <p>Check instagram here</p>}
    </Grid>
  );
};

InstaGrid.defaultProps = {
  media: undefined,
};

export default compose(
  withInstagramFeed,
  withStyles(styles),
)(InstaGrid);
  1. Use the component
//...
<InstaGrid account="origenstudio" numberOfMediaElements={9} />
//...

API

Table of Contents

withInstagramData

This is a HoC that injects instagram data as props. See supported props below:

Type: HOC<Base, Enhanced>

Parameters

  • account string account from where to get data from.
  • numberOfMediaElements number number of media elements to get. Max 12. (optional, default 12)
  • discardVideos boolean discard videos from media elements. (optional, default false)

Returns any injects the data from getInstagramFeedInfo to the props of the wrapped component.

getInstagramFeedInfo

This function returns a promise that when resolves return data extracted from the public profile page of an instagram account.

Parameters

  • account string
  • options {numberOfMediaElements: number, discardVideos: boolean} (optional, default {numberOfMediaElements:12,discardVideos:false})

Returns Promise<{accountInfo: any, accountFollowedBy: number, accountFollow: number, postsCount: number, profilePic: string, accountName: string, media: Array<{id: string, displayImage: string, thumbnail: string, likes: number, caption: string, commentsNumber: number, accessibilityCaption: string, dimensions: {width: number, height: number}, postLink: string}>}>

License

MIT © Origen Studio

Package generated using Nod

Features

  • Babel - Write next generation JavaScript today.
  • Jest - JavaScript testing framework used by Facebook.
  • ESLint - Make sure you are writing a quality code.
  • Prettier - Enforces a consistent style by parsing your code and re-printing it.
  • Flow - A static type checker for JavaScript used heavily within Facebook.
  • Travis CI - Automate tests and linting for every push or pull request.
  • Documentation - A documentation system so good, you'll actually write documentation.
  • Conventional Changelog - Generate a changelog from git metadata.

Commands

$ yarn test # run tests with Jest
$ yarn run coverage # run tests with coverage and open it on browser
$ yarn run lint # lint code
$ yarn run docs # generate docs
$ yarn run build # generate docs and transpile code

Publish

$ yarn run version patch|minor|major
$ yarn publish

It'll automatically run test, lint, docs, build, generate CHANGELOG.md, and push commits and tags to the remote repository.