Skip to content

Commit

Permalink
Add processor to remove blue bar from nav menu
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinJJones committed Jul 20, 2023
1 parent ef1d9f7 commit bce60ab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/slimmer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def fetch(*)

module Processors
autoload :AccountsShower, "slimmer/processors/accounts_shower"
autoload :BlueBarRemover, "slimmer/processors/blue_bar_remover"
autoload :BodyClassCopier, "slimmer/processors/body_class_copier"
autoload :BodyInserter, "slimmer/processors/body_inserter"
autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
Expand Down
5 changes: 5 additions & 0 deletions lib/slimmer/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ module Headers
section: "Section",
skip: "Skip",
template: "Template",
remove_blue_bar: "Remove-Blue-Bar",
remove_search: "Remove-Search",
show_accounts: "Show-Accounts",
}.freeze

# @private
APPLICATION_NAME_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:application_name]}".freeze

# @private
REMOVE_BLUE_BAR_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_blue_bar]}".freeze

# @private
FORMAT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:format]}".freeze

Expand Down Expand Up @@ -66,6 +70,7 @@ module Headers
# @option hash [String] format
# @option hash [String] organisations
# @option hash [String] page_owner
# @option hash [String] remove_blue_bar
# @option hash [String] remove_search
# @option hash [String] result_count
# @option hash [String] search_parameters
Expand Down
14 changes: 14 additions & 0 deletions lib/slimmer/processors/blue_bar_remover.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Slimmer::Processors
class BlueBarRemover
def initialize(headers)
@headers = headers
end

def filter(_src, dest)
if @headers.include?(Slimmer::Headers::REMOVE_BLUE_BAR_HEADER)
blue_bar = dest.at_css(".gem-c-layout-for-public__blue-bar")
blue_bar.remove if blue_bar
end
end
end
end
1 change: 1 addition & 0 deletions lib/slimmer/skin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def success(source_request, response, body)
Processors::SearchPathSetter.new(response),
Processors::SearchRemover.new(response.headers),
Processors::AccountsShower.new(response.headers),
Processors::BlueBarRemover.new(response.headers),
]

template_name = response.headers[Headers::TEMPLATE_HEADER] || "gem_layout"
Expand Down

0 comments on commit bce60ab

Please sign in to comment.