lesli_view 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +8 -0
  3. data/app/assets/stylesheets/lesli_view/{view.tailwind.css → view.css} +303 -1522
  4. data/lib/lesli_view/components/header.html.erb +2 -2
  5. data/lib/lesli_view/components/panel.html.erb +44 -26
  6. data/lib/lesli_view/components/timeline.html.erb +38 -25
  7. data/lib/lesli_view/components/timeline.rb +18 -5
  8. data/lib/lesli_view/components/toolbar.css +12 -8
  9. data/lib/lesli_view/components/toolbar.html.erb +3 -1
  10. data/lib/lesli_view/elements/button.html.erb +2 -0
  11. data/lib/lesli_view/elements/button.rb +4 -0
  12. data/lib/lesli_view/forms/builder_horizontal.rb +4 -0
  13. data/lib/lesli_view/forms/fields.rb +14 -0
  14. data/lib/lesli_view/items/activities.html.erb +5 -1
  15. data/lib/lesli_view/items/activities.rb +111 -11
  16. data/lib/lesli_view/items/attachment.html.erb +45 -0
  17. data/lib/lesli_view/items/attachment.rb +63 -0
  18. data/lib/lesli_view/items/attachments.html.erb +69 -34
  19. data/lib/lesli_view/items/attachments.rb +38 -2
  20. data/lib/lesli_view/items/discussion.html.erb +7 -5
  21. data/lib/lesli_view/items/discussion.rb +26 -0
  22. data/lib/lesli_view/items/discussions.html.erb +32 -17
  23. data/lib/lesli_view/items/discussions.rb +27 -5
  24. data/lib/lesli_view/items/task.html.erb +15 -6
  25. data/lib/lesli_view/items/task.rb +14 -0
  26. data/lib/lesli_view/items/tasks.html.erb +28 -15
  27. data/lib/lesli_view/items/tasks.rb +27 -2
  28. data/lib/lesli_view/layout/navigation_sidebar.css +19 -0
  29. data/lib/lesli_view/layout/navigation_sidebar.html.erb +52 -0
  30. data/lib/lesli_view/layout/navigation_sidebar.rb +24 -0
  31. data/lib/lesli_view/version.rb +2 -2
  32. data/lib/lesli_view.rb +2 -0
  33. data/readme.md +5 -3
  34. metadata +15 -8
  35. data/lib/lesli_view/components/panel.scss +0 -37
@@ -29,40 +29,75 @@ Building a better future, one line of code at a time.
29
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
30
  // ·
31
31
  %>
32
- <style>
33
- .lesli-items-attachments {
34
- .files {
35
- display:flex;
36
- .file-list {
37
- padding: .2rem 1rem;
38
- text-align: center;
39
- span {
40
- font-size: 2.8rem;
41
- }
42
- }
43
- }
44
- }
45
- </style>
46
- <article class="lesli-items-attachments box p-6" id="lesli-items-attachments">
47
- <div class="file is-boxed">
48
- <label class="file-label">
49
- <input class="file-input" type="file" name="resume" />
50
- <span class="file-cta">
51
- <span class="material-symbols-outlined">
52
- upload_file
53
- </span>
54
- <span class="file-label"> Choose a file… </span>
55
- </span>
56
- </label>
57
- </div>
58
-
59
- <div class="files">
60
- <% ['file-word-2-line','file-excel-2-line','file-pdf-2-line'].each do |file| %>
61
- <div class="file-list">
62
- <span class="ri-<%= file %>"></span>
63
- <p><%= file %></p>
32
+ <article
33
+ class="lesli-items-attachments rounded-2xl border border-slate-200 bg-white p-6 shadow-sm"
34
+ id="<%= dom_id(resource, :attachments) %>">
35
+ <%= form_with(
36
+ scope: scope_key,
37
+ model: attachment,
38
+ builder: LesliView::Forms::Builder,
39
+ url: create_path,
40
+ multipart: true
41
+ ) do |form| %>
42
+ <div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(12rem,0.35fr)_auto] lg:items-end">
43
+ <div>
44
+ <%= form.label(
45
+ :file,
46
+ I18n.t("lesli.items.attachments_choose_file", default: "Choose a file"),
47
+ class: "mb-2 block text-sm font-medium text-slate-700"
48
+ ) %>
49
+ <%= form.file_field(
50
+ :file,
51
+ required: true,
52
+ accept: accepted_content_types,
53
+ class: "block w-full cursor-pointer rounded-lg border border-slate-300 bg-white text-sm text-slate-700 file:mr-4 file:border-0 file:bg-slate-100 file:px-4 file:py-2.5 file:text-sm file:font-medium file:text-slate-700 hover:file:bg-slate-200 focus:outline-none focus:ring-2 focus:ring-[var(--lesli-color-primary)]"
54
+ ) %>
55
+ <% if attachment.errors[:file].any? %>
56
+ <p class="mt-2 text-sm text-red-600">
57
+ <%= attachment.errors[:file].to_sentence %>
58
+ </p>
59
+ <% end %>
64
60
  </div>
65
- <% end %>
66
- </div>
61
+
62
+ <%= form.field_control_text(
63
+ :label,
64
+ label: I18n.t("lesli.items.attachments_label", default: "Label"),
65
+ maxlength: 255
66
+ ) %>
67
+
68
+ <%= form.field_control_button(
69
+ I18n.t("lesli.items.attachments_add", default: "Add file"),
70
+ {
71
+ data: {
72
+ turbo_submits_with: I18n.t(
73
+ "lesli.items.attachments_uploading",
74
+ default: "Uploading..."
75
+ )
76
+ }
77
+ },
78
+ icon: "upload_file"
79
+ ) %>
80
+ </div>
81
+ <% end %>
82
+
83
+ <hr class="my-6 border-0 border-t border-slate-200">
84
+
85
+ <% if attachments.any? %>
86
+ <ul class="m-0 list-none space-y-3 p-0">
87
+ <% attachments.each do |item| %>
88
+ <%= render LesliView::Items::Attachment.new(
89
+ item,
90
+ path: attachment_path(item)
91
+ ) %>
92
+ <% end %>
93
+ </ul>
94
+ <% else %>
95
+ <p class="py-6 text-center text-sm text-slate-500">
96
+ <%= I18n.t(
97
+ "lesli.items.attachments_empty",
98
+ default: "No files have been attached yet."
99
+ ) %>
100
+ </p>
101
+ <% end %>
67
102
  </article>
68
103
 
@@ -33,12 +33,48 @@ Building a better future, one line of code at a time.
33
33
  module LesliView
34
34
  module Items
35
35
  class Attachments < ViewComponent::Base
36
- attr_reader :resource, :path_to_create
36
+ attr_reader :resource, :attachment
37
37
 
38
- def initialize(resource, path_to_create:nil, path_to_update:nil)
38
+ def initialize(
39
+ resource,
40
+ attachment: nil,
41
+ path_to_create: nil,
42
+ path_to_update: nil
43
+ )
39
44
  @resource = resource
40
45
  @path_to_create = path_to_create
41
46
  @path_to_update = path_to_update
47
+ @attachment = attachment || attachment_class.new
48
+ end
49
+
50
+ def attachment_class
51
+ resource.class.lesli_attachments_class
52
+ end
53
+
54
+ def attachments
55
+ resource.attachments.with_attached_file
56
+ end
57
+
58
+ def create_path
59
+ @path_to_create || helpers.polymorphic_path(
60
+ [:items, :attachments],
61
+ attachable_type: resource.class.name,
62
+ attachable_id: resource.id
63
+ )
64
+ end
65
+
66
+ def attachment_path(item)
67
+ return @path_to_update.call(item) if @path_to_update.respond_to?(:call)
68
+
69
+ helpers.polymorphic_path(item)
70
+ end
71
+
72
+ def scope_key
73
+ ActiveSupport::Inflector.underscore(attachment_class.name).tr("/", "_")
74
+ end
75
+
76
+ def accepted_content_types
77
+ attachment_class.lesli_attachment_content_types.join(",")
42
78
  end
43
79
  end
44
80
  end
@@ -1,10 +1,12 @@
1
1
  <li class="lesli-items-discussions-comments-comment flex flex-col gap-3 border-b border-slate-200 pb-6 last:border-b-0 last:pb-0 sm:flex-row sm:gap-4">
2
2
  <div class="shrink-0 text-sm leading-5 text-slate-500 sm:w-40 sm:text-right">
3
- <strong class="block font-semibold text-slate-800">Luis Donis</strong>
4
- <%= discussion['created_at_string'] || Date2.new.date_time %>
3
+ <strong class="block font-semibold text-slate-800">
4
+ <%= author_name %>
5
+ </strong>
6
+ <time datetime="<%= created_at_iso8601 %>">
7
+ <%= created_at_label %>
8
+ </time>
5
9
  </div>
6
10
 
7
- <div class="lexxy-content min-w-0 flex-1 break-words text-slate-700">
8
- <%== discussion.message %>
9
- </div>
11
+ <div class="min-w-0 flex-1 whitespace-pre-wrap break-words text-slate-700"><%= discussion.message %></div>
10
12
  </li>
@@ -37,6 +37,32 @@ module LesliView
37
37
  def initialize(discussion)
38
38
  @discussion = discussion
39
39
  end
40
+
41
+ def author_name
42
+ author = discussion.author
43
+ full_name = author.full_name if author.respond_to?(:full_name)
44
+ name = author.name if author.respond_to?(:name)
45
+
46
+ full_name.presence || name.presence || I18n.t(
47
+ "lesli.items.discussions_unknown_author",
48
+ default: "Unknown user"
49
+ )
50
+ end
51
+
52
+ def created_at_label
53
+ return if discussion.created_at.blank?
54
+
55
+ I18n.l(
56
+ discussion.created_at,
57
+ format: "%Y-%m-%d · %H:%M"
58
+ )
59
+ end
60
+
61
+ def created_at_iso8601
62
+ return if discussion.created_at.blank?
63
+
64
+ discussion.created_at.strftime("%Y-%m-%dT%H:%M:%S%:z")
65
+ end
40
66
  end
41
67
  end
42
68
  end
@@ -29,31 +29,46 @@ Building a better future, one line of code at a time.
29
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
30
  // ·
31
31
  %>
32
- <article class="lesli-items-discussions bg-white p-4 sm:p-8" id="lesli-items-discussions">
32
+ <article
33
+ class="lesli-items-discussions bg-white p-4 sm:p-8"
34
+ id="<%= dom_id(resource, :discussions) %>">
33
35
  <div class="lesli-items-discussions-form p-4">
34
- <% discussion_class = "#{@resource.class.name.deconstantize}::Items::Discussion".constantize %>
35
- <% scope_key = ActiveSupport::Inflector.underscore(discussion_class.name).tr("/", "_") %>
36
36
  <%= form_with(
37
37
  scope: scope_key,
38
- model: discussion_class.new,
38
+ model: comment,
39
39
  builder: LesliView::Forms::Builder,
40
- url: helpers.polymorphic_path([:items, :discussions],
41
- discussable_type:@resource.class.name,
42
- discussable_id: @resource.id
43
- )) do |form| %>
44
- <%= form.field_control_textarea(:message) %>
45
- <%= form.field_control_submit("Add comment") %>
40
+ url: create_path
41
+ ) do |form| %>
42
+ <%= form.field_control_textarea(:message, rows: 4) %>
43
+ <% if comment.errors[:message].any? %>
44
+ <p class="mt-2 text-sm text-red-600">
45
+ <%= comment.errors.full_messages_for(:message).to_sentence %>
46
+ </p>
47
+ <% end %>
48
+ <%= form.field_control_submit I18n.t(
49
+ "lesli.items.discussions_add",
50
+ default: "Add comment"
51
+ ) %>
46
52
  <% end %>
47
53
  </div>
48
54
  <hr class="my-6 border-0 border-t border-slate-200">
49
55
 
50
56
  <div class="lesli-items-discussions-container p-4">
51
- <ul
52
- id="<%= "#{scope_key}-lesli-items-discussions-list" %>"
53
- class="m-0 list-none space-y-6 p-0">
54
- <% @resource.discussions.order(created_at: :desc).each do |comment| %>
55
- <%= render(LesliView::Items::Discussion.new(comment)) %>
56
- <% end %>
57
- </ul>
57
+ <% if discussions.any? %>
58
+ <ul
59
+ id="<%= "#{scope_key}-lesli-items-discussions-list" %>"
60
+ class="m-0 list-none space-y-6 p-0">
61
+ <% discussions.each do |item| %>
62
+ <%= render(LesliView::Items::Discussion.new(item)) %>
63
+ <% end %>
64
+ </ul>
65
+ <% else %>
66
+ <p class="py-6 text-center text-sm text-slate-500">
67
+ <%= I18n.t(
68
+ "lesli.items.discussions_empty",
69
+ default: "No comments have been added yet."
70
+ ) %>
71
+ </p>
72
+ <% end %>
58
73
  </div>
59
74
  </article>
@@ -32,13 +32,35 @@ Building a better future, one line of code at a time.
32
32
  module LesliView
33
33
  module Items
34
34
  class Discussions < ViewComponent::Base
35
- attr_reader :resource, :path
36
-
37
- delegate :lexxy_rich_textarea_tag, to: :helpers
35
+ attr_reader :comment, :resource
38
36
 
39
- def initialize(resource, path=nil)
37
+ def initialize(resource, comment: nil)
40
38
  @resource = resource
41
- @path = path
39
+ @comment = comment || discussion_class.new
40
+ end
41
+
42
+ def discussion_class
43
+ resource.class.lesli_discussions_class
44
+ end
45
+
46
+ def discussions
47
+ resource.public_send(
48
+ resource.class.lesli_discussions_association_name
49
+ )
50
+ end
51
+
52
+ def create_path
53
+ helpers.polymorphic_path(
54
+ [:items, :discussions],
55
+ discussable_type: resource.class.name,
56
+ discussable_id: resource.id
57
+ )
58
+ end
59
+
60
+ def scope_key
61
+ ActiveSupport::Inflector
62
+ .underscore(discussion_class.name)
63
+ .tr("/", "_")
42
64
  end
43
65
  end
44
66
  end
@@ -32,7 +32,7 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  <li
34
34
  id="<%= dom_id(@resource, @scope_key) %>"
35
- class="lesli-items-tasks-item rounded-xl border transition-colors <%= @resource.done ? "lesli-items-tasks-task-done cursor-not-allowed border-slate-200 bg-slate-50" : "border-slate-200 hover:border-slate-300 hover:bg-slate-50" %>">
35
+ class="lesli-items-tasks-item rounded-xl border transition-colors <%= @resource.done ? "lesli-items-tasks-task-done border-slate-200 bg-slate-50 hover:border-slate-300 hover:bg-slate-100" : "border-slate-200 hover:border-slate-300 hover:bg-slate-50" %>">
36
36
  <%= form_with(
37
37
  url: helpers.polymorphic_path(@resource),
38
38
  method: :patch,
@@ -42,8 +42,11 @@ Building a better future, one line of code at a time.
42
42
  <%= form.hidden_field :id, value: @resource.id %>
43
43
  <%= form.button(
44
44
  type: "submit",
45
- disabled: @resource.done?,
46
- class: "flex w-full cursor-pointer items-center rounded-xl px-4 py-3 text-left text-sm font-medium text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--lesli-color-primary)] disabled:cursor-not-allowed"
45
+ aria: {
46
+ label: toggle_label,
47
+ pressed: @resource.done?
48
+ },
49
+ class: "flex w-full cursor-pointer items-center rounded-xl px-4 py-3 text-left text-sm font-medium text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--lesli-color-primary)]"
47
50
  ) do %>
48
51
  <span class="flex min-w-0 items-center gap-3">
49
52
  <span
@@ -51,9 +54,15 @@ Building a better future, one line of code at a time.
51
54
  aria-hidden="true">
52
55
  <%= @resource.done ? "check_box" : "check_box_outline_blank" %>
53
56
  </span>
54
- <span class="min-w-0 break-words <%= "text-slate-500 line-through" if @resource.done %>">
55
- <%= @resource.title %>
56
- </span>
57
+ <% if @resource.done? %>
58
+ <del class="min-w-0 break-words text-slate-500 line-through">
59
+ <%= @resource.title %>
60
+ </del>
61
+ <% else %>
62
+ <span class="min-w-0 break-words">
63
+ <%= @resource.title %>
64
+ </span>
65
+ <% end %>
57
66
  </span>
58
67
  <% end %>
59
68
  <% end %>
@@ -39,6 +39,20 @@ module LesliView
39
39
  @resource = task
40
40
  @scope_key = scope
41
41
  end
42
+
43
+ def toggle_label
44
+ if resource.done?
45
+ I18n.t(
46
+ "lesli.items.tasks_reopen_action",
47
+ default: "Mark task as incomplete"
48
+ )
49
+ else
50
+ I18n.t(
51
+ "lesli.items.tasks_complete_action",
52
+ default: "Mark task as complete"
53
+ )
54
+ end
55
+ end
42
56
  end
43
57
  end
44
58
  end
@@ -33,29 +33,42 @@ Building a better future, one line of code at a time.
33
33
  class="lesli-items-tasks rounded-2xl border border-slate-200 bg-white p-6 shadow-sm"
34
34
  id="<%= dom_id(@resource, :tasks) %>">
35
35
  <div class="lesli-items-tasks-form">
36
- <% task_class = "#{@resource.class.name.deconstantize}::Items::Task".constantize %>
37
- <% scope_key = ActiveSupport::Inflector.underscore(task_class.name).tr("/", "_") %>
38
36
  <%= form_with(
39
37
  scope: scope_key,
40
- model: task_class.new,
38
+ model: task,
41
39
  builder: LesliView::Forms::Builder,
42
- url: helpers.polymorphic_path([:items, :tasks],
43
- taskable_type:@resource.class.name,
44
- taskable_id: @resource.id
45
- )) do |form| %>
40
+ url: create_path
41
+ ) do |form| %>
46
42
  <%= form.field_control_text :title %>
47
- <%= form.field_control_submit "Add task" %>
43
+ <% if task.errors[:title].any? %>
44
+ <p class="mt-2 text-sm text-red-600">
45
+ <%= task.errors.full_messages_for(:title).to_sentence %>
46
+ </p>
47
+ <% end %>
48
+ <%= form.field_control_submit I18n.t(
49
+ "lesli.items.tasks_add",
50
+ default: "Add task"
51
+ ) %>
48
52
  <% end %>
49
53
  </div>
50
54
  <hr class="my-6 border-0 border-t border-slate-200">
51
55
 
52
56
  <div class="lesli-items-tasks-container">
53
- <ul
54
- id="<%= "#{scope_key}-lesli-items-tasks-list" %>"
55
- class="m-0 list-none space-y-3 p-0">
56
- <% @resource.tasks.each do |task| %>
57
- <%= render(LesliView::Items::Task.new(task, scope_key)) %>
58
- <% end %>
59
- </ul>
57
+ <% if tasks.any? %>
58
+ <ul
59
+ id="<%= "#{scope_key}-lesli-items-tasks-list" %>"
60
+ class="m-0 list-none space-y-3 p-0">
61
+ <% tasks.each do |item| %>
62
+ <%= render(LesliView::Items::Task.new(item, scope_key)) %>
63
+ <% end %>
64
+ </ul>
65
+ <% else %>
66
+ <p class="py-6 text-center text-sm text-slate-500">
67
+ <%= I18n.t(
68
+ "lesli.items.tasks_empty",
69
+ default: "No tasks have been added yet."
70
+ ) %>
71
+ </p>
72
+ <% end %>
60
73
  </div>
61
74
  </article>
@@ -33,10 +33,35 @@ Building a better future, one line of code at a time.
33
33
  module LesliView
34
34
  module Items
35
35
  class Tasks < ViewComponent::Base
36
- attr_reader :resource, :path_to_create
36
+ attr_reader :resource, :task
37
37
 
38
- def initialize(resource)
38
+ def initialize(resource, task: nil)
39
39
  @resource = resource
40
+ @task = task || task_class.new
41
+ end
42
+
43
+ def task_class
44
+ resource.class.lesli_tasks_class
45
+ end
46
+
47
+ def tasks
48
+ resource.public_send(
49
+ resource.class.lesli_tasks_association_name
50
+ )
51
+ end
52
+
53
+ def create_path
54
+ helpers.polymorphic_path(
55
+ [:items, :tasks],
56
+ taskable_type: resource.class.name,
57
+ taskable_id: resource.id
58
+ )
59
+ end
60
+
61
+ def scope_key
62
+ ActiveSupport::Inflector
63
+ .underscore(task_class.name)
64
+ .tr("/", "_")
40
65
  end
41
66
  end
42
67
  end
@@ -0,0 +1,19 @@
1
+ /* Component-owned visibility avoids collisions with engine utility bundles,
2
+ which load after LesliView and may redefine .hidden or .block. */
3
+ .lesli-navigation-sidebar-mobile {
4
+ display: block;
5
+ }
6
+
7
+ .lesli-navigation-sidebar-desktop {
8
+ display: none;
9
+ }
10
+
11
+ @media (min-width: 64rem) {
12
+ .lesli-navigation-sidebar-mobile {
13
+ display: none;
14
+ }
15
+
16
+ .lesli-navigation-sidebar-desktop {
17
+ display: block;
18
+ }
19
+ }
@@ -0,0 +1,52 @@
1
+ <%
2
+ selected_icon = items.find { |item| item[:selected] }&.dig(:icon) || "ri-folder-line"
3
+
4
+ navigation_items = capture do
5
+ items.each do |item|
6
+ selected = item[:selected]
7
+ %>
8
+ <li>
9
+ <%= link_to item[:path],
10
+ class: class_names(
11
+ "flex min-h-11 items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-sky-500/20",
12
+ "bg-sky-50 text-sky-700" => selected,
13
+ "text-slate-700 hover:bg-slate-100" => !selected
14
+ ),
15
+ aria: { current: ("page" if selected) },
16
+ data: { turbo_frame: "_top" } do %>
17
+ <span class="<%= item[:icon] || 'ri-folder-line' %> text-lg" aria-hidden="true"></span>
18
+ <span class="min-w-0 flex-1 truncate"><%= item[:label] %></span>
19
+ <% if item[:count] %><span class="text-xs text-slate-500"><%= item[:count] %></span><% end %>
20
+ <% end %>
21
+ </li>
22
+ <%
23
+ end
24
+ end
25
+ %>
26
+
27
+ <details class="lesli-navigation-sidebar-mobile group overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
28
+ <summary
29
+ class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-sm font-semibold text-slate-700 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-inset focus-visible:ring-sky-500/20 [&::-webkit-details-marker]:hidden"
30
+ aria-label="<%= selected_label %>">
31
+ <span class="flex min-w-0 items-center gap-3">
32
+ <span class="<%= selected_icon %> shrink-0 text-lg text-slate-400" aria-hidden="true"></span>
33
+ <span class="truncate"><%= selected_label %></span>
34
+ </span>
35
+ <span class="material-symbols shrink-0 text-xl text-slate-400 transition-transform group-open:rotate-180" aria-hidden="true">expand_more</span>
36
+ </summary>
37
+
38
+ <nav class="max-h-72 overflow-y-auto border-t border-slate-200 p-2" aria-label="<%= label %>">
39
+ <ul class="space-y-1">
40
+ <%= navigation_items %>
41
+ </ul>
42
+ </nav>
43
+ </details>
44
+
45
+ <nav class="lesli-navigation-sidebar-desktop rounded-xl border border-slate-200 bg-white p-3 shadow-sm lg:sticky lg:top-4 lg:w-60 lg:shrink-0" aria-label="<%= label %>">
46
+ <p class="px-3 pb-2 text-xs font-semibold uppercase tracking-wide text-slate-500">
47
+ <%= label %>
48
+ </p>
49
+ <ul class="space-y-1">
50
+ <%= navigation_items %>
51
+ </ul>
52
+ </nav>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LesliView
4
+ module Layout
5
+ # Page-level navigation: sticky on desktop, native disclosure on mobile.
6
+ # Callers own translations, routes, authorization, and selected state.
7
+ class NavigationSidebar < ViewComponent::Base
8
+ attr_reader :items, :label
9
+
10
+ # Each item has :label, :path, :selected, and optional :count and :icon (a Remix Icon CSS class).
11
+ # empty_selection_label describes pages without a selected item.
12
+ def initialize(items:, label:, empty_selection_label: nil)
13
+ @items = items
14
+ @label = label
15
+ @empty_selection_label = empty_selection_label
16
+ end
17
+
18
+ def selected_label
19
+ selected = items.find { |item| item[:selected] }
20
+ selected ? selected.fetch(:label) : (@empty_selection_label || label)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LesliView
4
- VERSION = "1.1.5"
5
- BUILD = ""
4
+ VERSION = "1.1.7"
5
+ BUILD = "1794793139"
6
6
  end
data/lib/lesli_view.rb CHANGED
@@ -44,11 +44,13 @@ require "lesli_view/items/actions"
44
44
  require "lesli_view/items/activities"
45
45
  require "lesli_view/items/discussion"
46
46
  require "lesli_view/items/discussions"
47
+ require "lesli_view/items/attachment"
47
48
  require "lesli_view/items/attachments"
48
49
 
49
50
 
50
51
  # loading layout
51
52
  require "lesli_view/layout/container"
53
+ require "lesli_view/layout/navigation_sidebar"
52
54
 
53
55
 
54
56
  # loading partials
data/readme.md CHANGED
@@ -8,10 +8,10 @@
8
8
  <br />
9
9
 
10
10
  <div align="center">
11
- <a target="_blank" href="https://github.com/LesliTech/LesliView/actions/workflows/main.yml">
11
+ <a target="_blank" href="https://github.com/LesliTech/LesliView/actions/workflows/lesli-ci-gem.yaml">
12
12
  <img
13
13
  alt="LesliView test status"
14
- src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliView/main.yml?branch=main&style=for-the-badge&logo=github&label=tests">
14
+ src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliView/lesli-ci-gem.yaml?branch=main&style=for-the-badge&logo=github&label=tests">
15
15
  </a>
16
16
  <a target="_blank" href="https://rubygems.org/gems/lesli_view">
17
17
  <img alt="Gem Version" src="https://img.shields.io/gem/v/lesli_view?style=for-the-badge&logo=ruby">
@@ -53,7 +53,7 @@ LesliView provides:
53
53
 
54
54
  The current development baseline is:
55
55
 
56
- - Ruby 3.2 or newer
56
+ - Ruby 3.3 or newer (the release workflow uses Ruby 3.3.5)
57
57
  - Rails 8.1
58
58
  - LesliAssets, configured in the host application's asset build
59
59
 
@@ -178,6 +178,8 @@ Then run `bundle install` from the host application so changes to the local gem
178
178
 
179
179
  ## Documentation
180
180
 
181
+ For page-level sidebars, follow the [navigation sidebar standard](docs/layout/navigation_sidebar.md).
182
+
181
183
  - [Lesli website](https://www.lesli.dev/)
182
184
  - [LesliView documentation](https://www.lesli.dev/gems/view/)
183
185
  - [Releases and changelog](https://github.com/LesliTech/LesliView/releases)