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 technical notes to the SubHeader
Henriette Darge3f041781b9c4
diff --git a/lookbook/docs/components/sub-header.md.erb b/lookbook/docs/components/sub-header.md.erbindex 6a781d1e7bd..fe84ba38242 100644--- a/lookbook/docs/components/sub-header.md.erb+++ b/lookbook/docs/components/sub-header.md.erb@@ -8,33 +8,31 @@ This component is an own implementation for OpenProject requirements of contextu### Desktop-The sub header accepts a number of additional components.+The SubHeader accepts a number of additional components. **All buttons** within the SubHeader require an icon to be shown, either as leading icon or as an icon-only variant.On the left side:- **Search filter**: (Optional) A basic [text input](https://primer.style/components/text-input) with a [search icon](https://primer.style/components/text-input#with-leading-and-trailing-visuals) which is mostly used on index pages to filter the elements below.- **Filter button:** (Optional) A button which is shown next to the filter input (or on the very left, if there is no filter input)- **Segmented controls** (optional) to switch two pre-filtered views-- **Action buttons**: (Optional) A set of buttons-At the center of the sub header:+At the center of the SubHeader:- **Text:** (Optional) A bold text shown in the middle of the SubHeader-On the right side:+On the right side:-- **A primary button**: (Optional) This is often an *add* action-- **Secondary buttons**: (Optional) Rarer but additional actions can be offered to the user.+- **Action buttons**: (Optional) A set of buttons, e.g.+ - **A primary button**: (Optional) This is often an *add* action+ - **Secondary buttons**: (Optional) Additional action can be offered to the user.+ - **An icon-only ButtonGroup**: (Optional) Rarer but additional actions can be grouped to show their connection.### Mobile-The Sub header automatically adapts to mobile screens:--- The actions on the left side always turn into icon buttons without labels. * Note: All sub header items must have an icon specified, even if the desktop version does not show it.*-- The search button is also just an icon; on click, it takes the full length (hiding all other actions), with a cancel button to go back to the previous state-- The right-side actions (usually a solitary primary add "+ {Object} button) will remain in its full form. They will not go into icon-only mode.-- All actions that do not have a visible label need a title or ARIA label for accessibility+The SubHeader automatically adapts to mobile screens:+- All actions on both sides (including Buttons, SegmentedControls, ButtonGroups, etc) always turn into icon only variants without labels.+- There is a search IconButton; on click, it reveals the search input takes the full length (hiding all other actions), with a cancel button to go back to the previous state## Best practices@@ -43,7 +41,6 @@ The Sub header automatically adapts to mobile screens:- Restrict SubHeader actions to the page's content-specific actions (e.g. filtering or creating a new object).- Use IconButtons instead of Buttons for actions only when the icon is clear enough to describe the action.- When more actions are necessary, or if a menu is needed, use an ActionMenu instead of the ActionButtons.-- Specify an icon for all items, even if it is not displayed int he desktop version**Don't**@@ -64,3 +61,64 @@ For detailed examples have a look at the other [preview examples](../../inspect/This is an exemplary playground of the `Primer::OpenProject::SubHeader`.<%= embed OpenProject::Common::SubHeaderPreview, :playground, panels: %i[params source] %>++## Technical notes++### Buttons+In order to enforce the icons to be visible we introduced an extra argument for each slot called `leading_visual` which you have to pass. As a consequence you cannot call the default Button slot `with_leading_visual_icon` any more. We do that internally with the provided `leading_visual`.++The filter button is an exception to this as we already provide the `filter` icon per default.++```rb+ render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_action_button(leading_icon: :plus, label: "Create", scheme: :primary) do+ "Create"+ end+ end+```++If you need an icon-only Button, you can pass an addition argument called `icon_only: true`++```rb+ render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_action_button(icon_only: true, leading_icon: :plus, label: "Create", scheme: :primary)+ end+```++### ActionMenu++The syntax for an `ActionMenu` within the SubHeader is a bit special due to the constraint of enforcing the icon. Here as well, you cannot use the `with_show_button` slot but rather pass the arguments when calling a dedicated slot:++```html+ <%=+ render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_action_menu(leading_icon: :plus, label: "Create", button_arguments: { scheme: :primary, "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+ %>+```+++### Dialogs++We currently only allow async dialogs to be rendered from the SubHeader. So you can render a normal action button that directs to an endpoint which returns the async dialog. For more details on how async dialogs work, please have a look [here](../patterns/dialogs).++```html+ <%=+ render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_action_button(leading_icon: :alert,+ label: "Open Dialog",+ tag: :a,+ href: "show_dialog_path",+ data: { controller: "async-dialog" }) do+ "Open Dialog"+ end+ end+ %>+```