Skip to content

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

Add code example for SidePanel component

Henriette Darge448696490f39
diff --git a/lookbook/docs/components/side-panel.md.erb b/lookbook/docs/components/side-panel.md.erb
index 8e160374c60..d136fc088ba 100644
--- a/lookbook/docs/components/side-panel.md.erb
+++ b/lookbook/docs/components/side-panel.md.erb
@@ -1,10 +1,12 @@
-The <strong>Side panel</strong> is right-side pane that is used to show information relevant to the current page. This information normally concerns the contents of the entire page and can generally directly be modified or adjusted via the side panel.
+The <strong>SidePanel</strong> is right-side pane that is used to show information relevant to the current page. This information normally concerns the contents of the entire page and can generally directly be modified or adjusted via the SidePanel.
-A good example is a meeting occurrence; the side panel is used to show key meeting details (time, location, duration...), status, a list of participants and attachments.
+A good example is a meeting occurrence; the SidePanel is used to show key meeting details (time, location, duration...), status, a list of participants and attachments.
+
+<%= embed Patterns::LayoutPreview, :default %>
## Anatomy
-The side panel consists of a series of sections (or just one section). Each section has a fixed format and contains:
+The SidePanel consists of a series of sections (or just one section). Each section has a fixed format and contains:
- A section header
- with counter (optional)
@@ -17,14 +19,14 @@ These sections are stacked vertically.
The content slot can take a number of different types of content and is relatively free. However, the content has to make sense in visual and semantic hierarchy. It's also best to make sure all objects are aligned to the left edge of the panel.
-The content of the side panel should always be secondary to the main content area.
+The content of the SidePanel should always be secondary to the main content area.
## Best practices
**Do**
-- Do use the side panel for contextual information on the page
-- Ensure that elements on a side panel respect the hierarchy of the page and elements in other side panels (the content in each side panel should roughly be at the same hierarchical and visual level)
+- Do use the SidePanel for contextual information on the page
+- Ensure that elements on a SidePanel respect the hierarchy of the page and elements in other SidePanels (the content in each SidePanel should roughly be at the same hierarchical and visual level)
- Use `color-fg-subtle` if the text is meant to be helpful guideline text or a caption; use `color-fg-default` for key information.
**Don't**
@@ -34,22 +36,26 @@ The content of the side panel should always be secondary to the main content are
## Used in
-Some pages where the side panel is used:
+Some pages where the SidePanel is used:
-- Meeting occurence (displays meeting details, meeting status, participants and attachments)
+- Meeting occurrence (displays meeting details, meeting status, participants and attachments)
- Project overview (displays project attributes)
- Project list
- Some admin index pages (eg. SAML or OpenID provider details page; file storage details page)
## Mobile considerations
-By default, side panel move to the bottom of the main content area on mobile. However, there are other considerations to keep in mind:
+By default, SidePanel move to the bottom of the main content area on mobile. However, there are other considerations to keep in mind:
-- Some sections have to manually be moved to the top if they contain critical information (eg. the meeting details for a meeting occurence go to the top, but the participant list goes to the bottom)
+- Some sections have to be moved to the top if they contain critical information (eg. the meeting details for a meeting occurence go to the top). This can be done via tha surrounding Layout component
- Sections can be simplified (certain actions hidden) or indeed completely left out on mobile if they are judged to be not critical on smaller screens
-
## Technical notes
+To achieve that the SidePanel moves to the right side, you have to wrap it into the `with_sidebar` slot of the `Primer::Alpha::Layout` component.
+
+<%= embed Patterns::LayoutPreview, :default, panels: %i[source] %>
+
## Examples
+For detailed examples have a look at the other [preview examples](/lookbook/inspect/primer/open_project/side_panel/default) of the component.
diff --git a/lookbook/docs/patterns/01-layout.md.erb b/lookbook/docs/patterns/01-layout.md.erb
index d173d816f9b..1f9a83360a5 100644
--- a/lookbook/docs/patterns/01-layout.md.erb
+++ b/lookbook/docs/patterns/01-layout.md.erb
@@ -9,8 +9,8 @@ you a layout with a side panel and a main content area, stacking behavior for mo
These are the involved primer components:
-- `Primer::Beta::Layout` - The main layout component. For more information, see https://primer.style/components/layout/rails/alpha and [the preview for the component](/lookbook/inspect/primer/alpha/layout/playground)
-- `Primer::OpenProject::SidePanel` - Side panel component for one or multiple sections
+- `Primer::Beta::Layout` - The main layout component. For more information, see the [Primer docs](https://primer.style/product/getting-started/rails/components/layout/) and [the preview for the component](/lookbook/inspect/primer/alpha/layout/playground)
+- `Primer::OpenProject::SidePanel` - SidePanel component for one or multiple sections. Please have a look at the docs for the [SidePanel component](./../components/side_panel).
Here is an example on how this would be used:
diff --git a/lookbook/previews/patterns/layout_preview/default.html.erb b/lookbook/previews/patterns/layout_preview/default.html.erb
index aee423aa4c3..3886f16fb00 100644
--- a/lookbook/previews/patterns/layout_preview/default.html.erb
+++ b/lookbook/previews/patterns/layout_preview/default.html.erb
@@ -1,6 +1,7 @@
<%=
render(Primer::Alpha::Layout.new) do |component|
- component.with_main do
+ # The border is only for visualization in the preview
+ component.with_main(border: true, p: 6) do
"Main content"
end
component.with_sidebar(row_placement: :start, col_placement: :end) do