Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions lib/notion/views/shared/_database_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@

<div class="item">
<div class="meta bg--gray-60">
<% unless item.dig(:icon, :svg) %>
<span class="index"><%= index + 1 %></span>
<% end %>
</div>
<% if item.dig(:icon, :svg) %>
<div class="icon"><%= item[:icon][:svg].html_safe %></div>
<% else %>
<div class="meta">
<span class="index"><%= index + 1 %></span>
</div>
<% end %>
<div class="content">
<div class="flex w--full gap pb--2">
<span class="<%= notion_title_size_class(item_size) %>" data-pixel-perfect="true"><%= item[:title] %></span>
<% if status_field.present? %>
<% status_properties = filter_properties_by_names(item[:properties], [status_field]) %>
<% if status_properties.any? %>
<span class="label label--small label--inverted" data-pixel-perfect="true"><%= status_properties.first[:value] %></span>
<% end %>
<% end %>
</div>

<% labeled_property_names = labeled_properties || [] %>
<% if labeled_property_names.any? %>
<% matched_labeled_properties = filter_properties_by_names(item[:properties], labeled_property_names) %>
<span class="<%= notion_title_size_class(item_size) %>" data-clamp="1" data-pixel-perfect="true"><%= item[:title] %></span>

<% patterns = ["label--inverted", "label--outline", "label--underline"] %>
<% status_properties = if status_field.present?
filter_properties_by_names(item[:properties], [status_field]).select { |property| property[:value].present? }
else
[]
end %>
<% labeled_property_names = labeled_properties || [] %>
<% matched_labeled_properties = filter_properties_by_names(item[:properties], labeled_property_names).select { |property| property[:value].present? } %>
<% label_background_classes = ["bg--gray-40", "bg--gray-60"] %>
<% if status_properties.any? %>
<span class="label label--base label--filled <%= label_background_classes.first %>" data-pixel-perfect="true"><%= status_properties.first[:value] %></span>
<% end %>

<div class="flex w--full gap pb--1">
<% if matched_labeled_properties.any? %>
<% label_background_offset = status_properties.any? ? 1 : 0 %>
<div class="flex w--full gap">
<% matched_labeled_properties.each_with_index do |label, index| %>
<% pattern = patterns[index % patterns.length] %>
<% label_classes = "label label--small #{pattern}" %>
<span class="<%= label_classes %>" data-pixel-perfect="true"><%= label[:value] %></span>
<% background_class = label_background_classes[(index + label_background_offset) % label_background_classes.length] %>
<span class="label label--base label--filled <%= background_class %>" data-pixel-perfect="true"><%= label[:value] %></span>
<% end %>
</div>
<% end %>

<% listed_property_names = listed_properties || [] %>
<% if listed_property_names.any? %>
<% matched_listed_properties = filter_properties_by_names(item[:properties], listed_property_names) %>
<% matched_listed_properties = filter_properties_by_names(item[:properties], listed_property_names).select { |property| property[:value].present? } %>

<% if matched_listed_properties.any? %>
<div class="flex w--full gap--xsmall">
Expand Down