Skip to content

Commit

Permalink
Update to ViewComponent v3 with new Slots API
Browse files Browse the repository at this point in the history
  • Loading branch information
Bramjetten committed May 8, 2023
1 parent 1aac049 commit f5c3f5f
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions app/components/spina/pages/new_page_button_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<% if view_templates.many? %>

<%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %>
<% dropdown.button(classes: "btn btn-primary w-full") do %>
<% dropdown.with_button(classes: "btn btn-primary w-full") do %>
<%= helpers.heroicon("document-plus", style: :solid, class: "w-5 h-5 -ml-1 mr-1") %>
<%=t 'spina.pages.new' %>
<% end %>

<% dropdown.menu do %>
<% dropdown.with_menu do %>
<% view_templates.each do |template| %>
<%= link_to helpers.spina.new_admin_page_path(view_template: template.name, resource_id: @resource&.id), class: "block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900", data: {turbo_frame: "modal", action: "reveal#hide"} do %>
<div class="font-medium text-gray-700">
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/accounts/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_with model: current_spina_account, url: spina.admin_account_path do |f| %>

<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>

<%= button_tag type: :submit, class: 'btn btn-primary', data: {controller: "button hotkeys", hotkeys: "command+s, ctrl+s", hotkeys_target: "button", action: "button#loading", loading_message: t("spina.ui.saving")} do %>
<%= heroicon('check', style: :mini, class: 'w-5 h-5 -ml-1 mr-1') %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/spina/admin/attachments/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<%= form_with model: [:admin, Spina::Attachment.new], url: spina.admin_attachments_path, data: {controller: "form loading-button", loading_message: t('spina.media_library.uploading'), action: "turbo:submit-end->loading-button#doneLoading"} do |f| %>

<%= f.file_field :files, multiple: true, id: "new_attachment_file_field", class: 'hidden', data: {action: "loading-button#loading form#requestSubmit"} %>
Expand All @@ -10,7 +10,7 @@
</button>
<% end %>
<% end %>
<% header.navigation do %>
<% header.with_navigation do %>
<nav class="-mb-3 mt-4">
<ul class="inline-flex w-auto rounded-md bg-white">
<%= render Spina::UserInterface::TabLinkComponent.new(spina.admin_images_path) do %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/spina/admin/images/_image.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

<% if @media_folders.present? %>
<%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %>
<% dropdown.button(classes: 'btn btn-default h-7 px-2 text-xs') do %>
<% dropdown.with_button(classes: 'btn btn-default h-7 px-2 text-xs') do %>
<%= heroicon('folder', style: :mini, class: 'w-4 h-4 mr-1 text-gray-600') %>
<%=t 'spina.ui.move_to' %>
<%= heroicon('chevron-down', style: :solid, class: 'w-4 h-4') %>
<% end %>

<% dropdown.menu do %>
<% dropdown.with_menu do %>
<% if image.media_folder_id.present? %>
<%= form_with model: image, url: spina.admin_image_path(image) do |f| %>
<%= f.hidden_field :media_folder_id, value: nil %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/spina/admin/images/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<% if @media_folder.blank? %>
<%= link_to spina.new_admin_media_folder_path, class: "btn btn-default", data: {turbo_frame: "modal"} do %>
<%= heroicon("folder", style: :solid, class: 'w-4 h-4 mr-1 -ml-1') %>
Expand All @@ -24,7 +24,7 @@
<% end %>
<% end %>

<% header.navigation do %>
<% header.with_navigation do %>
<nav class="-mb-3 mt-4">
<ul class="inline-flex w-auto rounded-md bg-white">
<%= render Spina::UserInterface::TabLinkComponent.new(spina.admin_images_path, active: true) do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/layout/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<%= render Spina::UserInterface::TranslationsComponent.new(@account, label: @locale.upcase) %>

<% if Spina::Current.theme.layout_parts.any? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/navigations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.navigation do %>
<% header.with_navigation do %>
<nav class="-mb-3 mt-4">
<ul class="inline-flex flex-wrap w-auto rounded-md bg-white">
<% @navigations.each do |navigation| %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/spina/admin/pages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div data-controller="tabs" data-tabs-active="cursor-default text-gray-900 bg-spina-dark bg-opacity-10" data-tabs-inactive="cursor-pointer bg-transparent text-gray-400 border-transparent">
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.after_breadcrumbs do %>
<% header.with_after_breadcrumbs do %>
<% if @page.draft? %>
<span class="text-gray-400 ml-2 text-sm">(<%= Spina::Page.human_attribute_name(:draft) %>)</span>
<% end %>
<%= link_to @page.materialized_path(locale: @locale), class: 'px-3 py-2 flex items-center text-gray-400 hover:text-gray-700', target: :blank, data: {turbo: false} do %>
<%= heroicon("external-link", style: :mini, class: "w-4 h-4") %>
<% end %>
<% end %>
<% header.actions do %>
<% header.with_actions do %>
<%= render Spina::Pages::ActionsComponent.new(page: @page, locale: @locale) %>
<% end %>
<% header.navigation do %>
<% header.with_navigation do %>
<nav class="-mb-3 mt-4">
<ul class="inline-flex w-auto rounded-md bg-white">
<% @tabs.each do |tab_name| %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/spina/admin/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<% if @resource %>
<%= link_to spina.edit_admin_resource_path(@resource), class: 'btn btn-default' do %>
<%= heroicon('cog-8-tooth', style: :solid, class: 'text-gray-300 w-5 h-5 -ml-1 mr-1') %>
Expand All @@ -12,7 +12,7 @@
</div>
<% end %>

<% header.navigation do %>
<% header.with_navigation do %>
<nav class="-mb-1 md:-mb-3 mt-4">
<ul class="inline-flex flex-wrap w-auto rounded-md bg-white">
<%= render Spina::UserInterface::TabLinkComponent.new(spina.admin_pages_path, active: @resource.nil?) do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/resources/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<%= render Spina::UserInterface::TranslationsComponent.new(@resource, label: @locale.upcase) %>

<%= button_tag type: :submit, form: dom_id(@resource), class: 'btn btn-primary', data: {controller: "button", action: "button#loading", loading_message: t('spina.ui.saving')} do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/settings/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_with model: @setting, scope: :setting, url: admin_settings_path do |f| %>

<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>

<%= button_tag type: :submit, class: 'btn btn-primary', data: {controller: "button", action: "button#loading", loading_message: t('spina.ui.saving')} do %>
<%= heroicon('check', style: :solid, class: 'w-5 h-5 mr-1 -ml-2') %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/spina/admin/shared/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<ul class="flex md:flex-col">
<%= render Spina::MainNavigation::SubNavComponent.new(:content) do |nav| %>
<% nav.icon do %>
<% nav.with_icon do %>
<%= heroicon('document-text', style: :solid, class: 'hidden md:block w-8 h-8 text-white md:mr-3') %>
<%= heroicon('menu', style: :solid, class: 'md:hidden w-8 h-8 text-white md:mr-3') %>

Expand All @@ -12,7 +12,7 @@
</div>
<% end %>

<% nav.links do %>
<% nav.with_links do %>

<%= render Spina::MainNavigation::LinkComponent.new t('spina.website.pages'), spina.admin_pages_path, active: controller_name.in?(%w(pages resources)) %>

Expand All @@ -29,15 +29,15 @@
<%= render Spina::Hooks::HookComponent.new(partial: "primary_navigation") %>

<%= render Spina::MainNavigation::SubNavComponent.new(:settings) do |nav| %>
<% nav.icon do %>
<% nav.with_icon do %>
<%= heroicon('cog-8-tooth', style: :solid, class: 'w-8 h-8 text-white md:mr-3') %>

<div class="text-white font-semibold hidden md:block transform -translate-x-2 ease-in-out duration-300 absolute md:relative opacity-0 transition-all" data-navigation-target="label">
<%= t('spina.website.settings') %>
</div>
<% end %>

<% nav.links do %>
<% nav.with_links do %>
<%= render Spina::MainNavigation::LinkComponent.new(t('spina.settings.general'), spina.edit_admin_account_path, active: controller_name == "accounts") %>
<%= render Spina::MainNavigation::LinkComponent.new(t('spina.website.theme'), spina.edit_admin_theme_path, active: controller_name == "theme") %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/theme/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_with model: Spina::Current.account, url: spina.admin_theme_path do |f| %>

<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>

<%= button_tag type: :submit, class: 'btn btn-primary', data: {controller: "button hotkeys", hotkeys: "command+s, ctrl+s", hotkeys_target: "button", action: "button#loading", loading_message: t("spina.ui.saving")} do %>
<%= heroicon('check', style: :mini, class: 'w-5 h-5 -ml-1 mr-1') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.actions do %>
<% header.with_actions do %>
<%= button_tag type: :submit, form: dom_id(@user), class: 'btn btn-primary', data: {controller: "button hotkeys", hotkeys: "command+s, ctrl+s", hotkeys_target: "button", action: "button#loading", loading_message: t('spina.ui.saving')} do %>
<%= heroicon('check', style: :mini, class: 'w-5 h-5 -ml-1 mr-1') %>
<%=t 'spina.users.save' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spina/admin/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
<% header.after_breadcrumbs do %>
<% header.with_after_breadcrumbs do %>
<% if current_spina_user.admin? %>
<%= link_to spina.new_admin_user_path, class: 'btn btn-default h-8 px-2 ml-3' do %>
<%= heroicon('plus', style: :mini, class: 'w-4 h-4') %>
Expand Down

0 comments on commit f5c3f5f

Please sign in to comment.