File tree Expand file tree Collapse file tree 7 files changed +41
-8
lines changed
Expand file tree Collapse file tree 7 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 1919 }
2020
2121 & --icon {
22-
22+ margin-left : 12 px ;
2323 }
2424
2525 & --name {
26- margin-left : 18 px ;
26+ margin-left : 14 px ;
2727 }
2828
2929 & --item {
Original file line number Diff line number Diff line change 100100 display : inline-block ;
101101}
102102
103+ .folder-tag {
104+ display : flex ;
105+ align-items : center ;
106+ font-size : 11px ;
107+ background-color : $color-primary ;
108+ padding : 2px 6px ;
109+ border-radius : 4px ;
110+ color : white ;
111+ }
112+
103113.date-tag {
104114 font-size : 11px ;
105115 padding : 2px 0px ;
Original file line number Diff line number Diff line change 3535.no-margin-top { margin-top : 0px ; }
3636.margin-top { margin-top : 16px }
3737.margin-top { margin-top : 16px }
38- .margin-left { margin-left : 16px }
38+ .margin-left {
39+ margin-left : 16px ;
40+
41+ & --tiny {
42+ margin-left : 4px ;
43+ }
44+ }
3945.margin-right { margin-right : 16px }
4046
4147.text-center { text-align : center ; }
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ def index
99 @page_title = "Snippets"
1010 @user = User . find_by ( id : params [ :user_id ] ) || current_user
1111 @display_popover = true
12- @snippets = @user . filed_snippets . includes ( :user )
12+ @snippets = @user . filed_snippets . includes ( :user , :folders )
1313
1414 # TODO: Extract this logic to model/service
1515 @snippets = @snippets . where ( 'description ILIKE ?' , "%#{ params [ :search ] } %" ) if params [ :search ]
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ class Snippet < ApplicationRecord
1010
1111 attr_accessor :folder_id
1212
13+ def folder_for_user ( user )
14+ folders . find_by ( user_id : user . id )
15+ end
16+
1317 # TODO: Don't call serializers from model - just instantiate in controller
1418 def serializable ( current_user )
1519 SnippetSerializer . new ( self , scope : current_user )
Original file line number Diff line number Diff line change 1+ <% folder = snippet.folder_for_user(current_user) %>
2+
13 <div
24 id ="<%= snippet . client_id %> "
35 data-controller ="snippets "
1012 < div >
1113 < div style ="display: flex; flex-direction: column; ">
1214 < div style ="display: flex; justify-content: flex-end; margin-bottom: 8px; align-items: center; ">
13- < span class ="language-tag "> <%= snippet . language %> </ span >
15+ <% if folder %>
16+ < div class ="folder-tag ">
17+ < img src ="/icons/icons8-folder-white.svg " width ="12 ">
18+ < span class ="block margin-left--tiny "> <%= folder . name %> </ span >
19+ </ div >
20+ <% end %>
1421 <% if @display_popover %>
1522 <%= render partial : 'shared/popover_trigger' , locals : { popover_path : popover_snippet_path ( snippet ) } %>
1623 <% end %>
Original file line number Diff line number Diff line change 1+ <% folder = snippet.folder_for_user(current_user) %>
2+
13 <div
24 id ="<%= snippet . client_id %> "
35 data-controller ="snippets "
46 data-action ="click->snippets#view_snippet "
57 data-snippet-url ="<%= snippet_path ( snippet ) %> "
6- class ="card--container card--container-padding snippet--container-preview "
7- >
8+ class ="card--container card--container-padding snippet--container-preview ">
89 < div class ="snippet--author-wrapper ">
910 <%= render partial : 'users/preview' , locals : { user : snippet . user , resource : snippet } %>
1011 < div >
1112 < div style ="display: flex; flex-direction: column; ">
1213 < div style ="display: flex; justify-content: flex-end; margin-bottom: 8px; align-items: center; ">
13- < span class ="language-tag "> <%= snippet . language %> </ span >
14+ <% if folder %>
15+ < div class ="folder-tag ">
16+ < img src ="/icons/icons8-folder-white.svg " width ="12 ">
17+ < span class ="block margin-left--tiny "> <%= folder . name %> </ span >
18+ </ div >
19+ <% end %>
1420 <% if @display_popover %>
1521 <%= render partial : 'shared/popover_trigger' , locals : { popover_path : popover_snippet_path ( snippet ) } %>
1622 <% end %>
You can’t perform that action at this time.
0 commit comments