Skip to content

Commit

Permalink
Merge pull request #28 from anthony-robin/extra-content
Browse files Browse the repository at this point in the history
Add `extra_content` configuration option
  • Loading branch information
anthony-robin authored Dec 9, 2023
2 parents daa9987 + 26db051 commit 65bb59f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Ribbonit.configure do |config|
# git_branch: Current git branch (only displayed in development)
config.infos_to_display = %i[rails_version ruby_version git_branch]

# additional extra content to display at the bottom of ribbon
config.extra_content = nil # 'Foo bar'

config.root_link = false # Wrap ribbon with root_url link ?

config.hide_for_small = true # Display ribbon in small devices ?
Expand Down
25 changes: 21 additions & 4 deletions app/assets/stylesheets/ribbon.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,48 @@
transform: rotate(-45deg);
}

/* 3 lines */

.ribbon--3-lines {
width: calc(var(--ribbon-width) + 15px);
height: calc(var(--ribbon-height) + 15px);
}

.ribbon--3-lines--top-left {
.ribbon--3-lines.ribbon--top-left,
.ribbon--4-lines.ribbon--top-left {
top: var(--ribbon-offset);
left: var(--ribbon-offset);
}

.ribbon--3-lines--top-right {
.ribbon--3-lines.ribbon--top-right,
.ribbon--4-lines.ribbon--top-right {
top: var(--ribbon-offset);
right: var(--ribbon-offset);
}

.ribbon--3-lines--bottom-left {
.ribbon--3-lines.ribbon--bottom-left,
.ribbon--4-lines.ribbon--bottom-left {
bottom: var(--ribbon-offset);
left: var(--ribbon-offset);
}

.ribbon--3-lines--bottom-right {
.ribbon--3-lines.ribbon--bottom-right,
.ribbon--4-lines.ribbon--bottom-right {
right: var(--ribbon-offset);
bottom: var(--ribbon-offset);
}

/* 4 lines */

.ribbon--4-lines {
width: calc(var(--ribbon-width) + 30px);
height: calc(var(--ribbon-height) + 30px);
}

.ribbon--4-lines .ribbon__container {
width: 280px;
}

@media only screen and (max-width: 40em) {
.ribbon--hide-for-small {
display: none;
Expand Down
6 changes: 6 additions & 0 deletions app/views/application/_lines.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
Branch: <strong><%= branch_name %></strong>
</span>
<% end %>
<% if config.extra_content.present? %>
<span class="ribbon__container__extra">
<%= config.extra_content %>
</span>
<% end %>
5 changes: 5 additions & 0 deletions lib/generators/ribbonit/templates/ribbonit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#
config.infos_to_display = %i[rails_version ruby_version git_branch]

###
# Extra content to add at the end
#
config.extra_content = nil

###
# Wrap ribbon with link that goes to root_url ?
#
Expand Down
1 change: 1 addition & 0 deletions lib/ribbonit/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Configuration
config_accessor(:infos_to_display) do
%i[rails_version ruby_version]
end
config_accessor(:extra_content) { nil }
config_accessor(:root_link) { false }
config_accessor(:hide_for_small) { true }
config_accessor(:position) { 'top-left' }
Expand Down
9 changes: 8 additions & 1 deletion lib/ribbonit/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ def branch_name

def line_count
height = 1
items = Ribbonit.configuration.infos_to_display
items = configuration.infos_to_display
height += 1 if items.include?(:ruby_version) || items.include?(:rails_version)
height += 1 if items.include?(:git_branch)
height += 1 if configuration.extra_content.present?
height
end

private

def configuration
Ribbonit.configuration
end
end
end

0 comments on commit 65bb59f

Please sign in to comment.