Skip to content

Commit 0a1be63

Browse files
committed
feature/Add snippets/followers/following to tabs on profile page
1 parent 3974c44 commit 0a1be63

File tree

8 files changed

+53
-59
lines changed

8 files changed

+53
-59
lines changed

app/assets/stylesheets/follow.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
}
88

99
.follow {
10+
&--container {
11+
display: block;
12+
padding: 8px;
13+
14+
&:hover {
15+
background-color: $color-light;
16+
text-decoration: none;
17+
}
18+
}
19+
1020
&--description {
1121
display: block;
1222
margin-top: 8px;

app/assets/stylesheets/user-preview.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
&-name {
1818
display: block;
19-
font-weight: bold;
20-
font-size: 14px;
19+
font-weight: 500;
20+
font-size: 16px;
2121
font-family: Helvetica, sans-serif;
2222
}
2323

app/assets/stylesheets/variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $color-primary: #3AAFA9;
22
$color-secondary: #2B7A78;
33
$color-purple: #b853ba;
44
$color-light: #DEF2F1;
5-
$color-lighter: #FEFFFF;
5+
$color-lighter: #c5ece5;
66
$color-white: white;
77
$color-black: #17252A;
88
$color-grey: #808080;

app/controllers/users_controller.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
class UsersController < ApplicationController
22
def show
3-
@user = User.find_by(id: params[:id])
4-
@following = current_user.following?(@user)
5-
end
6-
7-
def followers
83
@user = User.find_by(id: params[:id])
94
@serialized_user = @user.serialize.to_json
105
@is_following = current_user.following?(@user)
116
@followers = @user.followers
12-
end
13-
14-
def following
15-
@user = User.find_by(id: params[:id])
16-
@serialized_user = @user.serialize.to_json
17-
@is_following = current_user.following?(@user)
187
@following = @user.following
198
end
209

app/javascript/packs/snippet_app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ import SnippetListItem from '../snippet-list-item.vue'
7676
import Snipt from '../snipt.vue'
7777
import SnippetPreview from '../snippet-preview.vue'
7878
import SnippetShow from '../snippet-show.vue'
79+
import Tabs from '../tabs.vue';
80+
import Tab from '../tab.vue';
7981
import Toast from '../toast.vue';
8082
import UserPreview from '../user-preview.vue';
8183
import UserProfile from '../user-profile.vue'
@@ -110,6 +112,8 @@ document.addEventListener('DOMContentLoaded', () => {
110112
SnippetListItem,
111113
SnippetPreview,
112114
SnippetShow,
115+
Tab,
116+
Tabs,
113117
Toast,
114118
UserPreview,
115119
UserProfile

app/views/users/followers.html.erb

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/views/users/following.html.erb

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/views/users/show.html.erb

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
11
<card>
22
<user-profile
3-
:user="<%= @user.serialize.to_json %>"
4-
:is-following="<%= @following %>"
3+
:user="<%= @serialized_user %>"
4+
:is-following="<%= @is_following %>"
55
/>
66
</card>
77

8-
<% @user.snippets.order(created_at: :desc).each do |snippet| %>
9-
<snippet-preview
10-
:key="<%= snippet.id %>"
11-
:snippet="<%= snippet.serialize(current_user).to_json %>">
12-
</snippet-preview>
13-
<% end %>
8+
<card>
9+
<tabs>
10+
<tab name="<%= @user.snippets_count %> Snippets" selected="true">
11+
<% @user.snippets.order(created_at: :desc).each do |snippet| %>
12+
<snippet-preview
13+
:key="<%= snippet.id %>"
14+
:snippet="<%= snippet.serialize(current_user).to_json %>">
15+
</snippet-preview>
16+
<% end %>
17+
</tab>
18+
<tab name="<%= @followers.size %> Followers">
19+
<% @followers.each_with_index do |follower, index| %>
20+
<% if index > 0 %>
21+
<div class="horizontal-line"></div>
22+
<% end %>
23+
<a href="<%= user_path(follower)%>" class="follow--container">
24+
<user-preview :user="<%= follower.serialize.to_json %>"></user-preview>
25+
<span class="follow--description"><%= follower.description %></span>
26+
</a>
27+
<% end %>
28+
</tab>
29+
<tab name="<%= @following.size %> Following">
30+
<% @following.each_with_index do |following_user, index| %>
31+
<% if index > 0 %>
32+
<div class="horizontal-line"></div>
33+
<% end %>
34+
<a href="<%= user_path(following_user)%>" class="follow--container">
35+
<user-preview :user="<%= following_user.serialize.to_json %>"></user-preview>
36+
<span class="follow--description"><%= following_user.description %></span>
37+
</a>
38+
<% end %>
39+
</tab>
40+
</tabs>
41+
</card>

0 commit comments

Comments
 (0)