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 PageHeader example to the patterns page
Henriette Darge48f1e13f7856
diff --git a/lookbook/docs/patterns/10-page-headers.md.erb b/lookbook/docs/patterns/10-page-headers.md.erbindex cf1750c71aa..99eb7105ac6 100644--- a/lookbook/docs/patterns/10-page-headers.md.erb+++ b/lookbook/docs/patterns/10-page-headers.md.erb@@ -1,6 +1,4 @@-# Page Headers--This component, Page Header, is an adaptation to fir OpenProject requirements of the React component Page Header of primer. This document will only state the points that differ from what **[Primer specifies](https://primer.style/components/page-header)** about this component in their documentation.+This component is an adaptation for OpenProject requirements of the React component `PageHeader` of Primer. This document will only state the points that differ from what **[Primer specifies](https://primer.style/components/page-header)** about this component in their documentation.## Anatomy@@ -8,27 +6,29 @@ There are minor adjustments on how the composition of this component is defined**[Context bar](https://primer.style/components/page-header#context-bar):** Will be always present in all pages and will change depending on the viewport:-- **Desktop:** the content of the context bar will be a [breadcrumb](https://primer.style/components/breadcrumbs).-- **Tablet:** the content of the context bar will be a [breadcrumb](https://primer.style/components/breadcrumbs).-- **Mobile:** the content will use the parent link style with context bar actions, moving all the page header actions to it in a single [Icon button](https://primer.style/components/icon-button).+- **Desktop:** The content of the context bar will be a [breadcrumb](https://primer.style/components/breadcrumbs).+- **Tablet:** The content of the context bar will be a [breadcrumb](https://primer.style/components/breadcrumbs).+- **Mobile:**+ - The content of the breadcrumb will collapse to a single element using the parent link style.+ - All the page header actions will merge into an [ActionMenu](https://primer.style/components/action-menu) triggered by a single [Icon button](https://primer.style/components/icon-button) in the context bar.**[Title bar](https://primer.style/components/page-header#title-bar):** The default (medium) size will be always used keeping the capability as optionals of adding leading and trailing visuals and actions.-**Actions:** A maximum amount of 5 actions can be displayed independently in the Page Header actions. If there are more than 5 actions the last one will be an [Icon button](https://primer.style/components/icon-button) with a more action, this one will trigger all the extra actions in a dropdown. All actions require their own icon.+**Actions:** If there are more than 5 actions, the last one will be an [Icon button](https://primer.style/components/icon-button) with a more (⋯) icon, which will display all the remaining actions in a dropdown. All actions require their own icon.**Divider**: The divider bellow the Page Header will be always present with the exception of displaying a [Tav nav](https://primer.style/components/tab-nav) as navigation element bellow.## **Exceptional behaviours**- A special behaviour occurs when the page can be saved (or saved as) as one of the Page Header actions will be used to display an informational text and a link to perform the action.-- Work packages details would be the only exceptional case where the breadcrumb will be used to display the parent work package instead of the navigational hierarchy.+- Work packages details are the only exceptional case, where the breadcrumb will be used to display the parent work package instead of the navigational hierarchy.## Best practices**Do**- Limit the actions of the Page Header to the global actions of the page (e. for a work package list: favourite, share, full-screen, …). *Note: this can not be 100% fulfilled until the Primer page sub-headers are implemented.*-- Use the H1 tag always for the Page Header even if the default Page Header doesn’t contain this tag in the code.+- Use the H1 tag always for the Page Header.- All actions require their own icon.- Use Icon buttons instead of buttons for actions only when the icon is clear enough to describe the action.@@ -40,3 +40,28 @@ There are minor adjustments on how the composition of this component is defined## Used inThe Page Header is a navigational mandatory component in all pages that will always use as title the name of the page where is contained.++## Examples++The PageHeader actions offer a set of predefined slots, to use specific components inside the the PageHeader actions, such as:++* **Primer::Alpha::Dialog** ([`with_action_dialog`](../../inspect/primer/open_project/page_header/dialog_actions))+ * The trigger button will be part of the actions and collapse on mobile into the mobile action menu. Therefore, an additional `mobile_label`, as well as a `mobile_label` have to passed.+* **Primer::Alpha::ActionMenu** ([`with_action_menu`](../../inspect/primer/open_project/page_header/menu_actions)):+ * The trigger button will be part of the actions. On mobile, the options of the menu will be added to the options of the mobile action menu.+* **Primer::OpenProject::ZenModeButton** ([`with_action_zen_mode_button`](../../inspect/primer/open_project/page_header/zen_mode_button_actions)):+ * The button will collapse on mobile into the mobile action menu.+* **Primer::Beta::IconButton** ([`with_action_icon_button`](../../inspect/primer/open_project/page_header/actions)):+ * The button will collapse on mobile into the mobile action menu. Therefore, an additional `mobile_label` has to passed.+* **Primer::Beta::Button** ([`with_action_button`](../../inspect/primer/open_project/page_header/actions)):+ * The button will collapse on mobile into the mobile action menu. Therefore, an additional `mobile_label`, as well as a `mobile_label` have to passed.+* **Primer::Beta::Link** ([`with_action_link`](../../inspect/primer/open_project/page_header/actions)):+ * The button will collapse on mobile into the mobile action menu. Therefore, an additional `mobile_label`, as well as a `mobile_label` have to passed.+* **Primer::Beta::Text** ([`with_action_text`](../../inspect/primer/open_project/page_header/actions)):+ * The text will be hidden on mobile.++For detailed examples have a look at the other [preview examples](../../inspect/primer/open_project/page_header/playground) of the component.++This is an exemplary call of the `Primer::OpenProject::PageHeader`.++<%= embed OpenProject::Common::PageHeaderPreview, :default, panels: %i[source] %>diff --git a/lookbook/previews/open_project/common/page_header_preview.rb b/lookbook/previews/open_project/common/page_header_preview.rbnew file mode 100644index 00000000000..84b32f7a919--- /dev/null+++ b/lookbook/previews/open_project/common/page_header_preview.rb@@ -0,0 +1,33 @@+module OpenProject+ module Common+ # @hidden+ class PageHeaderPreview < Lookbook::Preview+ def default+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { "Some important page" }+ header.with_description { "Some optional description" }+ header.with_breadcrumbs([{ href: "/foo", text: "Project A" },+ { href: "/bar", text: "Module B" },+ "Some important page"])++ header.with_action_button(mobile_icon: "star", mobile_label: "Star") do |button|+ button.with_leading_visual_icon(icon: "star")+ "Star"+ end++ header.with_action_icon_button(icon: :trash, mobile_icon: :trash, label: "Delete", scheme: :danger)++ header.with_action_menu(menu_arguments: { anchor_align: :end },+ button_arguments: { icon: "op-kebab-vertical", "aria-label": "Menu" }) do |menu|+ menu.with_item(label: "Subitem 1") do |item|+ item.with_leading_visual_icon(icon: :paste)+ end+ menu.with_item(label: "Subitem 2") do |item|+ item.with_leading_visual_icon(icon: :log)+ end+ end+ end+ end+ end+ end+end