OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add component pattern to lookbook
Mir Bhatiaeee438d61dbb
diff --git a/lookbook/docs/patterns/08-flash-banner.md.erb b/lookbook/docs/patterns/08-flash-banner.md.erbnew file mode 100644index 00000000000..1a34c2c5ac7--- /dev/null+++ b/lookbook/docs/patterns/08-flash-banner.md.erb@@ -0,0 +1,36 @@+This component defines a specific use case of the Primer `Banner` component, consisting of an overlay around it to simplify its use as a flash in OpenProject.++## Overview++To use a Primerised flash, the `Meetings::UpdateFlashComponent` was introduced.++<%= embed OpenProject::Common::FlashPreview, :default, panels: %i[source] %>++## Usage++When a Primerised flash is required, this component can be used by calling `update_flash_message_via_turbo_stream()`. Under the hood, this prepends via turbo stream the `UpdateFlashComponent` in the `flash-container` div within the base layout.++The icon, message, dismiss scheme, and scheme are configurable identically to the Primer `Banner` component.++Two widths are supported, selectable via `full`. Depending on this value, the max width is capped or left unrestricted.++A `button` is optionally possible. When enabled, a link is included in the flash banner. `button_message` and `button_path_object` are used to configure the button text and linked path.++## Further Examples++### Danger:++As this is a common use case, the method `render_error_flash_message_via_turbo_stream()` is provided, generating a flash with `scheme: :danger` and `icon: :stop` by default.++<%= embed OpenProject::Common::FlashPreview, :danger, panels: %i[source] %>++<% if false %>+### With optional button:++<%= embed OpenProject::Common::FlashPreview, :button, panels: %i[source] %>+<% end %>+++++diff --git a/lookbook/previews/open_project/common/flash_preview.rb b/lookbook/previews/open_project/common/flash_preview.rbnew file mode 100644index 00000000000..82605c4f69b--- /dev/null+++ b/lookbook/previews/open_project/common/flash_preview.rb@@ -0,0 +1,34 @@+module OpenProject+ module Common+ # @hidden+ class FlashPreview < Lookbook::Preview+ def default+ render(Meetings::UpdateFlashComponent.new(+ button_path_object: @meeting,+ message: I18n.t("notice_meeting_updated")+ ))+ end++ def danger+ render(Meetings::UpdateFlashComponent.new(+ button_path_object: @meeting,+ message: I18n.t("notice_meeting_updated"),+ scheme: :danger,+ icon: :stop+ ))+ end++ def button+ render(Meetings::UpdateFlashComponent.new(+ button_path_object: @meeting,+ message: I18n.t("notice_meeting_updated"),+ scheme: :success,+ icon: :check,+ button: true,+ button_message: I18n.t("label_meeting_reload")+ # button_path_object: # TODO+ ))+ end+ end+ end+end