Skip to content

Commit

Permalink
Responsive right sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
noracato committed Oct 31, 2024
1 parent a10724f commit 8b2f16a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 89 deletions.
2 changes: 1 addition & 1 deletion app/views/layouts/_block_right.html.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.border-solid.border.border-gray-200.p-2.pt-5.mr-0.ml-auto.h-full.flex.flex-col.rounded-md{class: 'basis-1/4 max-w-[300px]'}
.border-solid.border.border-gray-200.p-2.pt-5.mb-5.mr-0.flex.rounded-md.justify-between{class: 'basis-full lg:h-full lg:basis-1/4 lg:ml-auto lg:mb-0 lg:max-w-[300px] lg:flex-col lg:justify-normal'}
= yield(:block_right)
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
= render partial: "layouts/buttons"
.text-xl.mb-5.mt-5
= yield(:menu_title)
.grow.flex.overflow-y-auto
%div.height-0.overflow-y-auto{class: 'basis-3/4'}
.grow.flex.overflow-y-auto.flex-wrap-reverse{class: 'lg:flex-nowrap'}
%div.height-0.overflow-y-auto.pr-5{class: 'basis-full lg:basis-3/4'}
= yield
= render partial: "layouts/block_right"
= render partial: "layouts/footer"
Expand Down
175 changes: 89 additions & 86 deletions app/views/saved_scenarios/_block_right_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,97 +1,100 @@
<% content_for :block_right do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.info'),
icon: 'information-circle',
active: controller_name == 'saved_scenarios' && action_name == 'show')
)%>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.history'),
icon: 'clock',
active: controller_name == 'history')
)%>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.manage_access'),
icon: 'user-group',
active: controller_name == 'saved_scenario_users')
)%>
<div class="flex flex-col">
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.info'),
icon: 'information-circle',
active: controller_name == 'saved_scenarios' && action_name == 'show')
)%>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.history'),
icon: 'clock',
active: controller_name == 'history')
)%>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_path(saved_scenario),
title: t('scenario_bar.manage_access'),
icon: 'user-group',
active: controller_name == 'saved_scenario_users')
)%>
</div>

<div class="border-t border-solid border-gray-200 my-10"></div>
<div class="border-l lg:border-l-0 lg:border-t flex flex-col border-solid border-gray-200 pr-5 lg:pr-0 lg:mt-10 lg:pt-10">

<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.private.description.#{saved_scenario.private}")
)) do %>
<%= render(SavedScenarios::Publish::Component.new(
path_on: publish_saved_scenario_path(saved_scenario),
path_off: unpublish_saved_scenario_path(saved_scenario),
status: saved_scenario.private,
title: t("scenario_bar.private.#{saved_scenario.private}"),
icon_on:'eye-slash',
icon_off: 'eye',
available: saved_scenario.collaborator?(current_user) && !saved_scenario.discarded?
))%>
<% end %>
<% if current_user&.admin? && !saved_scenario.discarded? %>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.featured.description.#{saved_scenario.featured?}")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_feature_path(saved_scenario),
title: t("scenario_bar.featured.#{saved_scenario.featured?}"),
icon: saved_scenario.featured? ? 'star' : 'sparkles',
active: controller_name == 'featured_scenarios',
static: true)
)%>
<% end %>
<% end %>
<% if
!(current_user&.admin? && saved_scenario.featured?) &&
(saved_scenario.collaborator?(current_user) && !saved_scenario.discarded?)%>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.edit.description")
text: t("scenario_bar.private.description.#{saved_scenario.private}")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: edit_saved_scenario_path(saved_scenario),
title: t("scenario_bar.edit.title"),
icon: 'pencil',
static: true,
active: action_name == 'edit'
))%>
<% end %>
<% end %>
<% if saved_scenario.collaborator?(current_user)%>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.discarded.description.#{saved_scenario.discarded?}")
)) do %>
<%= render(SavedScenarios::Publish::Component.new(
path_on: undiscard_saved_scenario_path(saved_scenario),
path_off: discard_saved_scenario_path(saved_scenario),
status: saved_scenario.discarded?,
title: t("scenario_bar.discarded.#{saved_scenario.discarded?}"),
icon_on: 'arrow-uturn-up',
icon_off: 'trash',
available: saved_scenario.collaborator?(current_user)
path_on: publish_saved_scenario_path(saved_scenario),
path_off: unpublish_saved_scenario_path(saved_scenario),
status: saved_scenario.private,
title: t("scenario_bar.private.#{saved_scenario.private}"),
icon_on:'eye-slash',
icon_off: 'eye',
available: saved_scenario.collaborator?(current_user) && !saved_scenario.discarded?
))%>
<% end %>
<% end %>
<% if saved_scenario.collaborator?(current_user) && saved_scenario.discarded? %>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.destroy.description")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: confirm_destroy_saved_scenario_path(saved_scenario),
title: t("scenario_bar.destroy.title"),
icon: 'x-mark',
static: true,
data: { turbo_frame: 'modal' }
))%>
<% if current_user&.admin? && !saved_scenario.discarded? %>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.featured.description.#{saved_scenario.featured?}")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: saved_scenario_feature_path(saved_scenario),
title: t("scenario_bar.featured.#{saved_scenario.featured?}"),
icon: saved_scenario.featured? ? 'star' : 'sparkles',
active: controller_name == 'featured_scenarios',
static: true)
)%>
<% end %>
<% end %>
<% if
!(current_user&.admin? && saved_scenario.featured?) &&
(saved_scenario.collaborator?(current_user) && !saved_scenario.discarded?)%>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.edit.description")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: edit_saved_scenario_path(saved_scenario),
title: t("scenario_bar.edit.title"),
icon: 'pencil',
static: true,
active: action_name == 'edit'
))%>
<% end %>
<% end %>
<% if saved_scenario.collaborator?(current_user)%>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.discarded.description.#{saved_scenario.discarded?}")
)) do %>
<%= render(SavedScenarios::Publish::Component.new(
path_on: undiscard_saved_scenario_path(saved_scenario),
path_off: discard_saved_scenario_path(saved_scenario),
status: saved_scenario.discarded?,
title: t("scenario_bar.discarded.#{saved_scenario.discarded?}"),
icon_on: 'arrow-uturn-up',
icon_off: 'trash',
available: saved_scenario.collaborator?(current_user)
))%>
<% end %>
<% end %>
<% if saved_scenario.collaborator?(current_user) && saved_scenario.discarded? %>
<%= render(Hovercard::Component.new(
path: '',
text: t("scenario_bar.destroy.description")
)) do %>
<%= render(SavedScenarios::NavItem::Component.new(
path: confirm_destroy_saved_scenario_path(saved_scenario),
title: t("scenario_bar.destroy.title"),
icon: 'x-mark',
static: true,
data: { turbo_frame: 'modal' }
))%>
<% end %>
<% end %>
<% end %>
</div>
<% end %>

0 comments on commit 8b2f16a

Please sign in to comment.