GithubHelp home page GithubHelp logo

ptkdev-components / webcomponent-instagram-widget Goto Github PK

View Code? Open in Web Editor NEW
77.0 4.0 9.0 12.35 MB

๐Ÿ–ผ Simple Instagram Widget: Photos Box of your Instagram Profile for your blog or website with this WebComponent.

Home Page: https://npmjs.com/package/@ptkdev/webcomponent-instagram-widget

License: Other

JavaScript 73.91% Smarty 4.19% HTML 8.79% PHP 2.82% SCSS 8.79% Nunjucks 1.50%
instagram instagram-widget instagram-photos webcomponents instagram-box igwidget instagram-profile custom-elements shadow-dom

webcomponent-instagram-widget's Introduction

๐ŸŒ‰ WebComponent: Instagram Widget

Last 9 Photos: Instagram Widget of your Instagram Profile for your blog. Show latest 9 pics from your instagram account.

โ›” DISCLAIMER: This is an unofficial instagram library and offers no warranty! All trademarks and logos belong to their respective owners.

๐ŸŽ Support: Donate

This project is free, open source and I try to provide excellent free support. Why donate? I work on this project several hours in my spare time and try to keep it up to date and working. THANK YOU!

๐Ÿ“Ž Menu

๐Ÿ’ก Features

  • [โœ”๏ธ] Easy to use
  • [โœ”๏ธ] MIT License
  • [โœ”๏ธ] Without jQuery depencence
  • [โœ”๏ธ] Configurable with attributes
  • [โœ”๏ธ] Customization with CSS Style
  • [โœ”๏ธ] Work with: Browserify / Webpack / ReactJS / Angular / Wordpress
  • [โœ”๏ธ] Photos Widget of your Instagram Profile for your blog or website with this WebComponent
  • [โœ”๏ธ] Translations: ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ต๐Ÿ‡ฑ (Help me โค๏ธ)

๐Ÿ‘” Screenshot

See Demo here. Photos from @ptkdev account:

WebComponent: InstagramWidget

๐Ÿš€ Installation (Web)

  1. Add html code to your page (and replace @ptkdev with your instagram username):
<instagram-widget username="@ptkdev" grid="3x3"></instagram-widget>
  1. Require javascript in yourpage (before </body>):
<script src="https://cdn.jsdelivr.net/npm/@ptkdev/webcomponent-instagram-widget@latest/dist/lib/en/instagram-widget.min.js"></script>

You can replace en in jsdelivr cdn with it or pl and load different languages or replace @latest with specific version, example @2.0.1.

See folder examples, run with npm run example. Below is available a description of options values.

๐Ÿ“ฆ Installation (NPM Module - Browserify/Webpack)

  1. Install npm module: npm install @ptkdev/webcomponent-instagram-widget --save
  2. Add html code to your page (and replace @ptkdev with your instagram username):
<instagram-widget username="@ptkdev" grid="3x3"></instagram-widget>
  1. Require javascript in your app:
require("@ptkdev/webcomponent-instagram-widget");

or

import "@ptkdev/webcomponent-instagram-widget";

See folder examples, run with npm run example. Below is available a description of options values.

๐Ÿ“– Installation (Wordpress)

  1. Download wordpress plugin from official store or mirror and install it.
  2. Add code to your html widget, example: Appearance --> Widget --> insert HTML Widget and paste html code (and replace @ptkdev with your instagram username):
<instagram-widget username="@ptkdev" grid="3x3"></instagram-widget>

You can insert this html code in posts, widget, html box or theme. Where you want see instagram photos box.

โš›๏ธ Installation (React)

  1. Install npm module with npm install @ptkdev/webcomponent-instagram-widget@latest --save:
  2. Import module in your src/App.js on header:
import "@ptkdev/webcomponent-instagram-widget";
  1. Add html code to your App.js template (and replace @ptkdev with your instagram username):
<instagram-widget username="@ptkdev" grid="3x3"></instagram-widget>

Go to examples/reactjs and run npm run start in folder for more info. Below is available a description of options values.

๐Ÿ…ฐ๏ธ Installation (Angular)

  1. Install npm module with npm install @ptkdev/webcomponent-instagram-widget@latest --save:
  2. Import module in your app/app.modules.ts on header:
import "@ptkdev/webcomponent-instagram-widget";
  1. Add html code to your html component (and replace @ptkdev with your instagram username):
<instagram-widget username="@ptkdev" grid="3x3"></instagram-widget>

Demo: https://webcomponents-60bc6.firebaseapp.com/instagram-widget

Go to examples/angular and run yarn install then yarn start in folder for more info. Below is available a description of options values.

๐Ÿงฐ Options / Attributes

Parameter Description Values Default value Available since
username Set your instagram username Your instagram username with or without @ @ptkdev v1.0.0
items-limit Set the max number of pictures number: from 0 to 12 9 v1.1.0
grid Set grid aspect ratio 1x1, 2x2, 3x3, etc... or responsive responsive v1.1.0
image-width Set width of images (NOTE: grid different than responsive overwrite this value) length units: 100%, 100px, 100pt 100% v1.1.0
image-height Set height of images length units: 100%, 100px, 100 100% v1.1.0
border-spacing Set spacing around images length units: 5%, 5px, 5pt 2px v2.1.0
border-corners Set border radius of corners: 0: square / 15: rounded / 100: circle number: from 0 to 100 5 v2.1.0
force-square Force square aspect ratio if you post photos with different size on your instagram yes / no yes v2.4.0
shadows Show shadows css type1, type2, type3, disabled disabled v2.6.0
mouse-hover Show animation with mouse hover type1, disabled disabled v2.6.0
show-title Show alt/title with hover of mouse enabled / disabled enabled v2.6.0
cache Enable/disable fetch() cache enabled / disabled enabled v2.1.0

HTML Code with attributes:

<instagram-widget
	username="@ptkdev"
	grid="3x3"
	force-square="yes"
	items-limit="9"
	image-width="100%"
	image-height="100%"
	border-corners="5"
	border-spacing="2px"
></instagram-widget>

๐ŸŽจ CSS Customization

You can overwrite default css with selector ::part, example:

<style>
	instagram-widget::part(photo) {
		border: 2px solid red;
	}
</style>

Part attribute is, generally, suffix of a class. Use chrome inspector for get the correct value of part="" attributes. See MDN selector ::part docs.

๐Ÿ”จ Developer Mode

  1. Download nightly, beta or stable.
  2. Remove .tpl suffix from config.js.tpl file in configs folder and fill it properly.
  3. Run npm install
  4. Run npm run dev

๐Ÿ“š Documentation

Run npm run docs

๐Ÿ‘‘ Sponsors

Support this project by becoming a sponsor. ๐Ÿ™ Become a sponsor on patreon or become top3 sponsor on ko-fi. Your logo will show up here with a link to your website.

๐Ÿฆ„ Backers

Thank you to all our backers! ๐Ÿ™ Become a backer on patreon.

๐Ÿ‘จโ€๐Ÿ’ป Contributing

I โค๏ธ contributions! I will happily accept your pull request! Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together ๐Ÿ‘ฏ and remember to insert your name in .all-contributorsrc and package.json file.

Thanks goes to these wonderful people (emoji key):


Patryk Rzucidล‚o

๐Ÿ’ป ๐ŸŒ ๐Ÿ“– ๐Ÿ›

Emanuele Fricano

๐Ÿ’ป ๐Ÿ›

Dominik Lubaล„ski

๐Ÿ›

๐Ÿ’ฐ In the future, if the donations allow it, I would like to share some of the success with those who helped me the most. For me open source is share of code, share development knowledges and share donations!

๐Ÿ“ฒ Tools

๐Ÿ Sorry for snake_case

I love snake_case syntax sorry for this ๐Ÿ˜ญ don't hate me.

๐Ÿ’ซ License

  • Code and Contributions have MIT License
  • Images and logos have CC BY-NC 4.0 License (Freepik Premium License)
  • Documentations and Translations have CC BY 4.0 License

webcomponent-instagram-widget's People

Contributors

ptkdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

webcomponent-instagram-widget's Issues

error while retrieving images

Versions

  • WebComponent Version: v1.0.0
  • Node Version: v13.0.0
  • Operating System: Windows 10
  • Browser: Google Chrome v80

Expected Behavior

widget must show instagram pictures

Actual Behavior

instead of instagram pictures I got this error "error while retrieving images...", I have latest update of webcomponent and also
profile is public. Please help!

Steps to Reproduce

  1. ...
  2. ...
  3. ...

Screenshots (Optional)

[Feature request] User Friendly Error Messages / Fallback

Feature description

I would love to see a user-friendly error message fallback. I feel this is pretty important because Instagram has very low API rate limits. Rather than a user seeing the current error message (e.g. "error while retrieving images... check if your Instagram profile is public, don't use VPN, maybe you got a daily instagram api rate limit for your ip: try again after 48h or open a new bug report on github") it would be better to:

  • Show the user something helpful. For example, a nicely designed screen with an Instagram icon, profile "@user" and a link to their profile (in a new tab). The user doesn't even have to know it's an error.
  • Show the actual error message in the console log where a developer would look.

Feature motivation

I just don't want end users seeing error messages, links to GitHub, etc. when they're just trying to view content on a website. Most of the time with Instagram it's from API rate limits, so it's not like the user (or developer) can do anything to solve the issue. At least in this case, even if the Instagram API fails, the user could still see a link to the Instagram account and click through if they're interested.

image

Using `window.onresize` and `document.querySelector` is unsafe

Question

It's not a bug, so I've chosen the "question" template. I looked at the source code, and I've found some worrying parts:

document.querySelector("instagram-widget").shadowRoot.querySelector(".instagram-widget-photos").innerHTML = html;

Your code won't work if there will be more elements on the same page. It will always update the first one. You can just reference your element by this - so instead querying document to access shadowRoot, you can use this.shadowRoot (after initializing it).

window.onresize = () => {

This is unsafe and can break other code. You assume that the user won't use window.onresize syntax, but he can, and then your callback is gone. You should use window.addEventListener().

if (self.options["force-square"] === "yes") {

Because of that, the onresize will only refer to the last instance of your component, so the above setting will apply from the last instance.

[Bug] CORS: error while retrieving images...

Expected Behavior

Images from Instagram are loaded.

Actual Behavior

No images from Instagram are loaded.

Steps to Reproduce

  1. Visit https://codepen.io/ptkdev/pen/WNQOYqy
  2. See Error message console of developer tools:
    Access to fetch at 'https://www.instagram.com/ptkdev/?__a=1' from origin 'https://cdpn.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Instagram changed procedure to get his API

Versions

ALL

  • WebComponent Version: v1.0.0
  • Node Version: v13.0.0
  • Operating System: ALL
  • Browser: ALL

Expected Behavior

View the posts of an instagram profile

Actual Behavior

Get this error in chrome dev tools:
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
And the webcomponent doesn't show up

Steps to Reproduce

  1. include the code provided in the README.md in a website
  2. open the website
  3. open web dev tools
  4. got a JSON error
  5. the instagram posts plugin doesn't show posts on the web page

Probably Solution

https://www.instagram.com/developer/
this page states that the old api doesn't work anymore and provide the steps for register to the access to the new API

Can't change default username

Hello, I tried to set username into Angular version of the webcomponent-instagram-widget and also I tried to change default param at the demo-site, but it doesn't work: I saw photo from default profile.

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.