Skip to content

Commit

Permalink
Gizmo: SectionNavigation (#1964)
Browse files Browse the repository at this point in the history
- #709

Sprouts a tiny Gizmo for linking to Sections. At some point, we'll want
to add a UI for picking which `Sections` to include, preferably an
`AllowList` so that adding a `Section` doesn't immediately publish it.
  • Loading branch information
zspencer authored Nov 25, 2023
1 parent c50ba1f commit 76413a1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/furniture/section_navigation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

class SectionNavigation
def self.router
end
end
1 change: 1 addition & 0 deletions app/furniture/section_navigation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SectionNavigation
9 changes: 9 additions & 0 deletions app/furniture/section_navigation/section_navigation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SectionNavigation
class SectionNavigation < Furniture
location(parent: :room)

def rooms
space.rooms.where.not(id: space.entrance_id)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="mt-3 grid grid-cols-1 gap-5 sm:gap-6 sm:grid-cols-2 lg:grid-cols-4 items-center">
<% policy_scope(section_navigation.rooms).each do |room| %>
<%= link_to [room.space, room], class: "no-underline" do %>
<%= render CardComponent.new(
data: { access_level: room.access_level, slug: room.slug, model: "room", id: room.id },
classes: "group self-stretch hover:bg-orange-50"
) do %>
<div class="px-4 py-5 flex items-center justify-between">
<h3 class="text-base font-semibold text-orange-500 group-hover:text-orange-400">
<%= room.name %>
</h3>

<button class="rounded-full bg-orange-500 p-1 ml-2 text-white shadow-sm group-hover:bg-orange-400" data-role="enter">
<%= render SvgComponent.new(classes: "h-5 w-5") do %>
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
<% end %>
</button>
</div>
<%- end %>
<%- end %>
<% end %>
</div>
1 change: 1 addition & 0 deletions app/models/furniture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def self.registry
markdown_text_block: ::MarkdownTextBlock,
marketplace: ::Marketplace::Marketplace,
livestream: ::Livestream,
section_navigation: SectionNavigation::SectionNavigation,
embedded_form: EmbeddedForm
}
end
Expand Down

0 comments on commit 76413a1

Please sign in to comment.