diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index e3e801c8..8084afc5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -15,5 +15,6 @@ @import 'layouts/default'; // Components +@import 'components/list_keywords_group'; // Screens diff --git a/app/assets/stylesheets/components/_list_keywords_group.scss b/app/assets/stylesheets/components/_list_keywords_group.scss new file mode 100644 index 00000000..74e117c8 --- /dev/null +++ b/app/assets/stylesheets/components/_list_keywords_group.scss @@ -0,0 +1,6 @@ +.list-keywords-group { + &__header { + color: $gray-500; + min-width: 3em; + } +} diff --git a/app/decorators/keywords_decorator.rb b/app/decorators/keywords_decorator.rb index aa11d371..8969021f 100644 --- a/app/decorators/keywords_decorator.rb +++ b/app/decorators/keywords_decorator.rb @@ -5,7 +5,7 @@ def initialize(keywords) @keywords = keywords end - def sections + def groups @keywords.group_by { |keyword| keyword.name[0].upcase.to_sym } end end diff --git a/app/views/keywords/_list_keywords.html.erb b/app/views/keywords/_list_keywords.html.erb new file mode 100644 index 00000000..3dd1625e --- /dev/null +++ b/app/views/keywords/_list_keywords.html.erb @@ -0,0 +1,8 @@ +
+ <% keywords.groups.each do |group_key, group_keywords| %> + <%= render partial: 'list_keywords_group', locals: { group_key: group_key, group_keywords: group_keywords } %> + <% end %> +
+ <%== pagy_bootstrap_nav(pagy) %> +
+
diff --git a/app/views/keywords/_list_keywords_group.html.erb b/app/views/keywords/_list_keywords_group.html.erb new file mode 100644 index 00000000..603e74fb --- /dev/null +++ b/app/views/keywords/_list_keywords_group.html.erb @@ -0,0 +1,13 @@ +
+
+

+ <%= group_key %> +

+
+ +
+
diff --git a/app/views/keywords/index.html.erb b/app/views/keywords/index.html.erb index e66e56be..069dd02e 100644 --- a/app/views/keywords/index.html.erb +++ b/app/views/keywords/index.html.erb @@ -1,13 +1,3 @@
- <% keywords.sections.each do |key, section| %> -
-

<%= key %>

- -
- <% end %> - <%== pagy_bootstrap_nav(pagy) %> + <%= render partial: 'list_keywords', locals: { keywords: keywords, pagy: pagy } %>