Skip to content

Commit

Permalink
add profile section
Browse files Browse the repository at this point in the history
  • Loading branch information
eminos committed Mar 22, 2018
1 parent 33ec02f commit f5739d8
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 55 deletions.
2 changes: 1 addition & 1 deletion dist/instagram-feed.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/instagram-feed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eminos-instagram-feed",
"version": "1.0.0",
"version": "1.1.0",
"description": "Koken plugin that shows an Instagram feed in a grid.",
"author": "Emin Jasarevic",
"license": "MIT",
Expand Down
30 changes: 29 additions & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Instagram Feed",
"version": "1.0",
"version": "1.1",
"description": "Displays Instagram images in a grid.",
"author": {
"name": "Emin Jasarevic",
Expand Down Expand Up @@ -36,6 +36,34 @@
"comments": {
"label": "Show number of comments.",
"type": "boolean"
},
"profile": {
"label": "Show profile section.",
"type": "boolean"
},
"profile_pic": {
"label": "Show profile picture.",
"type": "boolean"
},
"profile_username": {
"label": "Show username.",
"type": "boolean"
},
"profile_full_name": {
"label": "Show full name.",
"type": "boolean"
},
"profile_stats": {
"label": "Show statistics (posts, followers, following).",
"type": "boolean"
},
"profile_biography": {
"label": "Show biography.",
"type": "boolean"
},
"profile_external_url": {
"label": "Show extern url.",
"type": "boolean"
}
}
}
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if (document.querySelector('#instagram-feed')) {
template: require('./template.html'),
data: {
settings: {},
user: null,
media: []
},
mounted() {
Expand All @@ -30,6 +31,7 @@ if (document.querySelector('#instagram-feed')) {
}

response.json().then((data) => {
this.user = data.graphql.user;
this.media = data.graphql.user.edge_owner_to_timeline_media.edges;
});
})
Expand Down
116 changes: 78 additions & 38 deletions src/main.scss
Original file line number Diff line number Diff line change
@@ -1,49 +1,89 @@
.instagram-feed-container {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 1em;
.item {
position: relative;
overflow: hidden;
a {
display: block;
text-decoration: none;
padding: 0;
margin: 0;
border: 0;
}
img {
max-width: 100%;
.profile {
display: flex;
align-items: center;
margin-bottom: 1rem;

.pic {
width: 33%;
max-width: 120px;
padding-right: 2rem;
a {
display: block;
}
img {
max-width: 100%;
border-radius: 100%;
border: 1px solid lightgray;
}
}
.info {
display: flex;
justify-content: center;
width: 100%;
font-size: 16px;
color: white;
position: absolute;
bottom: 0;
transform: translateY(25px);
transition: transform .3s ease-in-out;
.likes, .comments {
margin: 0 10px;
flex: 1;
.username, .full_name {
&:first-child {
margin-top: 0;
}
}
.stats {
display: flex;
div {
margin-right: 1rem;
&:last-child {
margin-right: 0;
}
}
}
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
background: rgb(30, 30, 30);
opacity: 0;
transition: opacity .2s ease-in-out;
}
&:hover {
}

.feed {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 1em;
.item {
position: relative;
overflow: hidden;
a {
display: block;
text-decoration: none;
padding: 0;
margin: 0;
border: 0;
}
img {
max-width: 100%;
}
.info {
transform: translateY(-10px);
display: flex;
justify-content: center;
width: 100%;
font-size: 16px;
color: white;
position: absolute;
bottom: 0;
transform: translateY(25px);
transition: transform .3s ease-in-out;
.likes, .comments {
margin: 0 10px;
}
}
.overlay {
opacity: .2;
position: absolute;
width: 100%;
height: 100%;
background: rgb(30, 30, 30);
opacity: 0;
transition: opacity .2s ease-in-out;
}
&:hover {
.info {
transform: translateY(-10px);
}
.overlay {
opacity: .2;
}
}
}
}
}
}

51 changes: 38 additions & 13 deletions src/template.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
<div id="instagram-feed" class="instagram-feed-container" :style="'grid-template-columns: repeat(' + settings.columns + ', 1fr); grid-gap: ' + settings.gap + ';'">
<div class="item" v-for="item, index in media" v-if="index < settings.count">
<div id="instagram-feed" class="instagram-feed-container">

<a :href="'https://www.instagram.com/p/' + item.node.shortcode + '/'" target="_blank">
<div class="profile" v-if="user && settings.profile">
<div class="pic" v-if="settings.profile_pic">
<a :href="'https://www.instagram.com/' + user.username + '/'" target="_blank">
<img :src="user.profile_pic_url_hd" :alt="user.username">
</a>
</div>
<div class="info">
<h2 class="username" v-if="settings.profile_username">
<a :href="'https://www.instagram.com/' + user.username + '/'">{{ user.username }}</a>
</h2>
<h4 class="full_name" v-if="settings.profile_full_name">{{ user.full_name }}</h4>
<div class="stats" v-if="settings.profile_stats">
<div><strong>{{ user.edge_owner_to_timeline_media.count }}</strong> posts</div>
<div><strong>{{ user.edge_followed_by.count }}</strong> followers</div>
<div><strong>{{ user.edge_follow.count }}</strong> following</div>
</div>
<div class="biography" v-if="settings.profile_biography">{{ user.biography }}</div>
<div class="external_url" v-if="settings.profile_external_url"><a :href="user.external_url" target="_blank">{{ user.external_url }}</a></div>
</div>
</div>

<div class="overlay"></div>
<div class="feed" :style="'grid-template-columns: repeat(' + settings.columns + ', 1fr); grid-gap: ' + settings.gap + ';'">
<div class="item" v-for="item, index in media" v-if="index < settings.count">

<img :src="item.node.thumbnail_src" alt="">
<a :href="'https://www.instagram.com/p/' + item.node.shortcode + '/'" target="_blank">

<div class="info" v-if="settings.likes || settings.comments">
<div class="likes" v-if="settings.likes">
<font-awesome-icon icon="heart" /> {{ item.node.edge_liked_by.count }}
</div>
<div class="comments" v-if="settings.comments">
<font-awesome-icon icon="comment" /> {{ item.node.edge_media_to_comment.count }}
<div class="overlay"></div>

<img :src="item.node.thumbnail_src" alt="">

<div class="info" v-if="settings.likes || settings.comments">
<div class="likes" v-if="settings.likes">
<font-awesome-icon icon="heart" /> {{ item.node.edge_liked_by.count }}
</div>
<div class="comments" v-if="settings.comments">
<font-awesome-icon icon="comment" /> {{ item.node.edge_media_to_comment.count }}
</div>
</div>
</div>

</a>
</a>

</div>
</div>

</div>

0 comments on commit f5739d8

Please sign in to comment.