From e912211ceea603640348ca8bfb3afbd326d7ebeb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 17:34:32 +1300 Subject: [PATCH] DRY the icons --- app/helpers/icons_helper.rb | 17 +++++++++++++++++ app/views/crops/_actions.html.haml | 5 ++++- app/views/shared/_global_actions.html.haml | 15 +++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/helpers/icons_helper.rb diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 000000000..636884133 --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,17 @@ +module IconsHelper + def garden_icon + icon('far', 'square') + end + + def planting_icon + icon('fas', 'seedling') + end + + def harvest_icon + icon('fas', 'carrot') + end + + def seed_icon + icon('fas', 'heart') + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 5cc80036b..92ae2b00f 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -2,12 +2,15 @@ .btn-group - if can? :create, Planting = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = planting_icon = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = harvest_icon = t('buttons.harvest_crop', crop_name: crop.name) - + - if can? :create, Seed = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = seed_icon = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 1fbfa2733..638ce87d0 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,19 +1,22 @@ - if signed_in? - .global-actions + .global-actions.pull-right .btn-group = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do - = t('links.my_gardens') - + = garden_icon + = t('links.my_gardens') + .btn-group = link_to new_planting_path, class: 'btn btn-default' do + = planting_icon = t('plantings.plant_something') + = link_to new_harvest_path, class: 'btn btn-default' do + = harvest_icon = t('harvests.harvest_something') + = link_to new_seed_path, class: 'btn btn-default' do + = seed_icon = t('buttons.save_seeds') .btn-group = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - -- content_for(:attributions) do - seed by Template from the Noun Project \ No newline at end of file