diff options
Diffstat (limited to 'app/components')
-rw-r--r-- | app/components/diffs/overflow_warning_component.html.haml | 6 | ||||
-rw-r--r-- | app/components/pajamas/alert_component.html.haml | 12 | ||||
-rw-r--r-- | app/components/pajamas/alert_component.rb | 15 |
3 files changed, 26 insertions, 7 deletions
diff --git a/app/components/diffs/overflow_warning_component.html.haml b/app/components/diffs/overflow_warning_component.html.haml index 907d066e73d..b184fa1d527 100644 --- a/app/components/diffs/overflow_warning_component.html.haml +++ b/app/components/diffs/overflow_warning_component.html.haml @@ -1,9 +1,9 @@ = render Pajamas::AlertComponent.new(title: _('Too many changes to show.'), variant: :warning, - alert_class: 'gl-mb-5') do - .gl-alert-body + alert_class: 'gl-mb-5') do |c| + = c.body do = message - .gl-alert-actions + = c.actions do = diff_link = patch_link diff --git a/app/components/pajamas/alert_component.html.haml b/app/components/pajamas/alert_component.html.haml index a1d3c700e57..782ac8b9ca2 100644 --- a/app/components/pajamas/alert_component.html.haml +++ b/app/components/pajamas/alert_component.html.haml @@ -1,5 +1,6 @@ -.gl-alert{ role: 'alert', class: ["gl-alert-#{@variant}", @alert_class], data: @alert_data } - = sprite_icon(icon, css_class: icon_classes) +.gl-alert{ role: 'alert', class: [base_class, @alert_class], data: @alert_data } + - if @show_icon + = sprite_icon(icon, css_class: icon_classes) - if @dismissible %button.btn.gl-dismiss-btn.btn-default.btn-sm.gl-button.btn-default-tertiary.btn-icon.js-close{ type: 'button', aria: { label: _('Dismiss') }, @@ -10,4 +11,9 @@ - if @title %h4.gl-alert-title = @title - = content + - if body? + .gl-alert-body + = body + - if actions? + .gl-alert-actions + = actions diff --git a/app/components/pajamas/alert_component.rb b/app/components/pajamas/alert_component.rb index 4bb6c41661b..c1b2132da29 100644 --- a/app/components/pajamas/alert_component.rb +++ b/app/components/pajamas/alert_component.rb @@ -6,26 +6,39 @@ module Pajamas # @param [String] title # @param [Symbol] variant # @param [Boolean] dismissible + # @param [Boolean] show_icon # @param [String] alert_class # @param [Hash] alert_data # @param [String] close_button_class # @param [Hash] close_button_data def initialize( - title: nil, variant: :info, dismissible: true, + title: nil, variant: :info, dismissible: true, show_icon: true, alert_class: nil, alert_data: {}, close_button_class: nil, close_button_data: {}) @title = title @variant = variant @dismissible = dismissible + @show_icon = show_icon @alert_class = alert_class @alert_data = alert_data @close_button_class = close_button_class @close_button_data = close_button_data end + def base_class + classes = ["gl-alert-#{@variant}"] + classes.push('gl-alert-not-dismissible') unless @dismissible + classes.push('gl-alert-no-icon') unless @show_icon + + classes.join(' ') + end + private delegate :sprite_icon, to: :helpers + renders_one :body + renders_one :actions + ICONS = { info: 'information-o', warning: 'warning', |