From 568c30fa903d29988f24ad80c00bbc28a87eca68 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 20 Jun 2024 14:16:51 -0700 Subject: [PATCH] Wider tables for longer item names in Item Getting Guide If the item names are long, it helps to give them more room to breathe! Whereas if they're short, it looks silly and makes it harder to scan the table. Just an extra bit of help for e.g. Dyeworks items with long names! --- app/helpers/items_helper.rb | 5 +++++ app/views/items/sources.html.haml | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index f25d3144..fd905768 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -208,6 +208,11 @@ module ItemsHelper dyeworks_average_num_potions_for(items) * 125 end + def complexity_for(items) + max_name_length = items.map(&:name).map(&:length).max + max_name_length >= 40 ? "high" : "low" + end + def probability(p) case p when 1 diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index fb3db7c3..d16ae107 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -11,7 +11,7 @@ [nc]: https://secure.nc.neopets.com/get-neocash [gc]: https://secure.nc.neopets.com/nickcash-cards - %table.item-list + %table.item-list{"data-complexity": complexity_for(@items[:nc_mall])} %thead %tr %td @@ -46,7 +46,7 @@ [dyeworks]: https://www.neopets.com/mall/dyeworks/ - %table.item-list{"data-complexity": "high"} + %table.item-list{"data-complexity": complexity_for(@items[:dyeworks])} %thead %tr %td.thumbnail-cell @@ -120,7 +120,7 @@ [tp]: https://www.neopets.com/island/tradingpost.phtml?type=browse [ag]: https://www.neopets.com/genie.phtml - %table.item-list + %table.item-list{"data-complexity": complexity_for(@items[:np])} %thead %tr %td @@ -147,6 +147,7 @@ %table.item-list{ "data-group-type": "bundle", "data-group-owned": items.all?(&:owned?), + "data-complexity": complexity_for(items), } %thead %tr @@ -203,7 +204,7 @@ [owls]: https://www.neopets.com/~owls - %table.item-list + %table.item-list{"data-complexity": complexity_for(@items[:other_nc])} %thead %td %th.name-cell{colspan: 2}