denise-oneill-inbox-ru's picture
D8 staging from 92665ef4298ecff6735b080ff7901f2c19f719a7
5010ad7 verified
Raw History Blame Contribute Delete
4.41 kB
<div data-controller="language-tabs" data-language-tabs-active-value="<%= I18n.locale %>" class="space-y-6">
<!-- Language Tabs -->
<div class="border-b border-gray-200 bg-gray-50 -mx-6 -mt-6 px-6 pt-6 rounded-t-lg">
<nav class="-mb-px flex space-x-6 overflow-x-auto" role="tablist">
<% I18n.available_locales.each do |locale| %>
<button
type="button"
data-language-tabs-target="tab"
data-locale="<%= locale %>"
data-action="click->language-tabs#switch keydown->language-tabs#navigate"
role="tab"
id="post-language-tab-<%= locale %>"
aria-controls="post-language-panel-<%= locale %>"
aria-selected="<%= locale == I18n.locale %>"
tabindex="<%= locale == I18n.locale ? 0 : -1 %>"
class="language-tab whitespace-nowrap pb-4 px-1 border-b-2 font-semibold text-sm transition-colors duration-150 <%= locale == I18n.locale ? 'border-indigo-500 text-indigo-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' %>">
<span class="flex items-center gap-2">
<span class="text-xs font-bold bg-white px-2 py-0.5 rounded"><%= locale.upcase %></span>
<%= t("locales.#{locale}") %>
</span>
</button>
<% end %>
</nav>
</div>
<!-- Language Panels -->
<% I18n.available_locales.each do |locale| %>
<div id="post-language-panel-<%= locale %>" data-language-tabs-target="panel" data-locale="<%= locale %>" role="tabpanel" aria-labelledby="post-language-tab-<%= locale %>" class="<%= "hidden" unless locale == I18n.locale %> space-y-5">
<div class="space-y-1">
<%= f.label :title, t("admin.posts.title_for", lang: locale.upcase), class: "block text-sm font-semibold text-gray-700" %>
<%= f.text_field :title,
name: "post[title_translations][#{locale}]",
value: post.title_for(locale),
placeholder: t("admin.posts.title_placeholder"),
class: "mt-1 block w-full px-4 py-2.5 rounded-xl border-2 border-gray-200 bg-gray-50 text-gray-900 placeholder:text-gray-400 focus:bg-white focus:border-indigo-400 focus:ring-4 focus:ring-indigo-100 transition-all duration-200 sm:text-sm" %>
</div>
<div class="space-y-1">
<%= f.label :content, t("admin.posts.content_for", lang: locale.upcase), class: "block text-sm font-semibold text-gray-700" %>
<div class="mt-1 rounded-xl border-2 border-gray-200 bg-gray-50 overflow-hidden focus-within:bg-white focus-within:border-indigo-400 focus-within:ring-4 focus-within:ring-indigo-100 transition-all duration-200">
<%= f.rich_text_area :"content_#{locale}",
name: "post[content_#{locale}]",
class: "prose prose-sm sm:prose lg:prose-lg max-w-none" %>
</div>
</div>
</div>
<% end %>
<!-- Post Settings -->
<div class="grid grid-cols-1 gap-5 pt-6 border-t border-gray-200 sm:grid-cols-2">
<%= admin_select_field f, :category_id,
Category.all.map { |c| [c.name, c.id] },
label: t("activerecord.attributes.post.category"),
prompt: t("admin.posts.select_category") %>
<%= admin_select_field f, :status,
Post::STATUSES.map { |s| [s.humanize, s] },
label: t("activerecord.attributes.post.status") %>
<%= admin_datetime_field f, :scheduled_at,
label: t("activerecord.attributes.post.scheduled_at") %>
</div>
<!-- Tags -->
<div class="pt-6 border-t border-gray-200 space-y-3">
<label class="block text-sm font-semibold text-gray-700">
<%= t("activerecord.attributes.post.tags") %>
</label>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3">
<% Tag.all.each do |tag| %>
<label class="relative flex items-center p-3 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition duration-150 ease-in-out has-[:checked]:bg-indigo-50 has-[:checked]:border-indigo-500">
<%= check_box_tag "post[tag_ids][]", tag.id, post.tag_ids.include?(tag.id),
class: "h-4 w-4 rounded border-gray-300 text-indigo-600 transition duration-150 ease-in-out focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50" %>
<span class="ml-2 text-sm font-medium text-gray-700"><%= tag.name %></span>
</label>
<% end %>
</div>
</div>
</div>