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

[chore] added stories for breadcrumbs

Eric Schubert902dcb98e812
diff --git a/frontend/src/app/spot/styles/sass/components/breadcrumbs.sass b/frontend/src/app/spot/styles/sass/components/breadcrumbs.sass
index 47c3b6176c7..f944ae333a1 100644
--- a/frontend/src/app/spot/styles/sass/components/breadcrumbs.sass
+++ b/frontend/src/app/spot/styles/sass/components/breadcrumbs.sass
@@ -39,6 +39,7 @@
&-divider
font-size: 0.5rem
flex-shrink: 0
+ margin-left: $spot-spacing-0_25
&:not(:first-child)
margin-left: $spot-spacing-0_25
diff --git a/frontend/src/stories/Breadcrumbs.example.html b/frontend/src/stories/Breadcrumbs.example.html
new file mode 100644
index 00000000000..7a131a2920e
--- /dev/null
+++ b/frontend/src/stories/Breadcrumbs.example.html
@@ -0,0 +1 @@
+<spot-breadcrumbs [content]="content"></spot-breadcrumbs>
diff --git a/frontend/src/stories/Breadcrumbs.example.ts b/frontend/src/stories/Breadcrumbs.example.ts
new file mode 100644
index 00000000000..66d3dbbfe0d
--- /dev/null
+++ b/frontend/src/stories/Breadcrumbs.example.ts
@@ -0,0 +1,14 @@
+import { ChangeDetectionStrategy, Component } from '@angular/core';
+import { BreadcrumbsContent } from 'core-app/spot/components/breadcrumbs/breadcrumbs-content';
+
+@Component({
+ templateUrl: './Breadcrumbs.example.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class SbBreadcrumbsExample {
+ content = new BreadcrumbsContent([
+ { icon: 'folder', text: 'OpenProject storage' },
+ { text: 'Public' },
+ { text: 'Shared' },
+ ]);
+}
diff --git a/frontend/src/stories/Breadcrumbs.stories.mdx b/frontend/src/stories/Breadcrumbs.stories.mdx
index b69420ae6a1..58e09f436f5 100644
--- a/frontend/src/stories/Breadcrumbs.stories.mdx
+++ b/frontend/src/stories/Breadcrumbs.stories.mdx
@@ -1,10 +1,29 @@
import { Meta, Story, Canvas } from '@storybook/addon-docs';
-
-<Meta title="Patterns/Breadcrumbs" />
+import { moduleMetadata } from '@storybook/angular';
+
+import { OpSpotModule } from "../app/spot/spot.module";
+import { SbBreadcrumbsExample } from './Breadcrumbs.example';
+import { SbBreadcrumbsFourLevelsExample } from './BreadcrumbsFourLevels.example';
+import { SbBreadcrumbsFiveLevelsExample } from './BreadcrumbsFiveLevels.example';
+
+<Meta
+ title="Patterns/Breadcrumbs"
+ decorators={[
+ moduleMetadata({
+ imports: [
+ OpSpotModule,
+ ],
+ }),
+ ]}
+/>
# Breadcrumbs
-> Example: A 3-level breadcrumb, root with icon
+<Canvas>
+ <Story name="Default example">
+ {{ component: SbBreadcrumbsExample }}
+ </Story>
+</Canvas>
Breadcrumbs provide important semantic context to information being presented on the screen by allowing users to identify where they are in a hierarchical structure.
@@ -17,7 +36,11 @@ Breadcrumbs allow users to:
Breadcrumbs consist of a series of "levels" presented horizontally, separated by a right arrow (▶). Each level is a child of the level preceding it, except the first level, which is the root.
-> Example: A 4-level breadcrumb, root with icon
+<Canvas>
+ <Story name="Four levels">
+ {{ component: SbBreadcrumbsFourLevelsExample }}
+ </Story>
+</Canvas>
## Behaviour
@@ -26,18 +49,22 @@ The last level is always the current level; this is never clickable. All other l
Because the length of the breadcrumb can vary significantly (depending on the title of each level and the available space), it can condense to fit the available space:
- The breadcrumb can show four (4) levels in full, space permitting, before going to "collapsed" mode.
-- If the available space in the parent container not does afford sufficient width to display the four levels in full, the middle levels are truncated with ellipses ("Root ▶ Second le... ▶ Third le... ▶ Fourth level").
+- If the available space in the parent container not does afford sufficient width to display the four levels in full, the middle levels are truncated with ellipses ("Root ▶ Second le... ▶ Third le... ▶ Fourth level").
-> *Example: A 5-level breadcrumb, collapsed*
+<Canvas>
+ <Story name="Five levels">
+ {{ component: SbBreadcrumbsFiveLevelsExample }}
+ </Story>
+</Canvas>
There are special rules on mobile:
- The root level shows only an icon and ellipses ("...", fully truncated).
- The direct parent (...) is displayed as non-shrinkable ellipses that are clickable
- Further parents (between the direct parent and the root) are not displayed
-- The current level maybe be truncated with ellipses ("Icon ▶ ... ▶Current le...) if needed.
+- The current level maybe be truncated with ellipses ("[Icon] ... ▶ ... ▶ Current le...) if needed.
-> Example: A 4-level breadcrumb, mobile
+To view the mobile style, reduce the viewport width of your browser below 680px.
## Options
@@ -56,4 +83,4 @@ The text for each level is always a link, except for:
## Margins and Spacing
-The breadcrumb component does not inherently have margins or padding. There is a 0.25 rem spacing between each level and a right arrow (that is, 0.25 to the left and right of every right arrow).
\ No newline at end of file
+The breadcrumb component does not inherently have margins or padding. There is a 0.25 rem spacing between each level and a right arrow (that is, 0.25 to the left and right of every right arrow).
diff --git a/frontend/src/stories/BreadcrumbsFiveLevels.example.html b/frontend/src/stories/BreadcrumbsFiveLevels.example.html
new file mode 100644
index 00000000000..7a131a2920e
--- /dev/null
+++ b/frontend/src/stories/BreadcrumbsFiveLevels.example.html
@@ -0,0 +1 @@
+<spot-breadcrumbs [content]="content"></spot-breadcrumbs>
diff --git a/frontend/src/stories/BreadcrumbsFiveLevels.example.ts b/frontend/src/stories/BreadcrumbsFiveLevels.example.ts
new file mode 100644
index 00000000000..b64b7fdf045
--- /dev/null
+++ b/frontend/src/stories/BreadcrumbsFiveLevels.example.ts
@@ -0,0 +1,16 @@
+import { ChangeDetectionStrategy, Component } from '@angular/core';
+import { BreadcrumbsContent } from 'core-app/spot/components/breadcrumbs/breadcrumbs-content';
+
+@Component({
+ templateUrl: './BreadcrumbsFiveLevels.example.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class SbBreadcrumbsFiveLevelsExample {
+ content = new BreadcrumbsContent([
+ { icon: 'folder', text: 'Root folder with a long name' },
+ { text: 'Second level' },
+ { text: 'Third level with an even longer name' },
+ { text: 'Fourth level with the longest name from all' },
+ { text: 'Current level and even this one has a long name' },
+ ]);
+}
diff --git a/frontend/src/stories/BreadcrumbsFourLevels.example.html b/frontend/src/stories/BreadcrumbsFourLevels.example.html
new file mode 100644
index 00000000000..7a131a2920e
--- /dev/null
+++ b/frontend/src/stories/BreadcrumbsFourLevels.example.html
@@ -0,0 +1 @@
+<spot-breadcrumbs [content]="content"></spot-breadcrumbs>
diff --git a/frontend/src/stories/BreadcrumbsFourLevels.example.ts b/frontend/src/stories/BreadcrumbsFourLevels.example.ts
new file mode 100644
index 00000000000..32bdc9ead8f
--- /dev/null
+++ b/frontend/src/stories/BreadcrumbsFourLevels.example.ts
@@ -0,0 +1,15 @@
+import { ChangeDetectionStrategy, Component } from '@angular/core';
+import { BreadcrumbsContent } from 'core-app/spot/components/breadcrumbs/breadcrumbs-content';
+
+@Component({
+ templateUrl: './BreadcrumbsFourLevels.example.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class SbBreadcrumbsFourLevelsExample {
+ content = new BreadcrumbsContent([
+ { icon: 'folder', text: 'Root' },
+ { text: 'Second level' },
+ { text: 'Third level' },
+ { text: 'Current level' },
+ ]);
+}
diff --git a/frontend/src/stories/HowToUse.stories.mdx b/frontend/src/stories/HowToUse.stories.mdx
index 086d7b0dd01..8bf60226680 100644
--- a/frontend/src/stories/HowToUse.stories.mdx
+++ b/frontend/src/stories/HowToUse.stories.mdx
@@ -48,7 +48,7 @@ Radio options can also be "checked" (as in, in a set of three options, only one
Switches can be _ON_ (true) or _OFF_ (false).
-## Browing through the docs
+## Browsing through the docs
This Storybook is divided in three sections:
@@ -64,4 +64,4 @@ This Storybook is divided in three sections:
- How to find linked/dependent elements
- Contributing:
- As a developer
- - As a designer
\ No newline at end of file
+ - As a designer