Skip to content

Commit a0ebcaf

Browse files
evanyan13Evan Yan
andauthored
[CI-4303] Update Code Examples - Breadcrumbs (#148)
Co-authored-by: Evan Yan <evan.yan@constructor.io>
1 parent 1f8f7bf commit a0ebcaf

File tree

2 files changed

+27
-113
lines changed

2 files changed

+27
-113
lines changed

src/stories/components/Breadcrumbs/Breadcrumbs.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Meta } from '@storybook/react';
33
import Breadcrumbs from '../../../components/Breadcrumbs';
44
import CioPlp from '../../../components/CioPlp';
55
import { DEMO_API_KEY } from '../../../constants';
6+
import '../../../styles.css';
67

78
const meta = {
89
title: 'Components/Breadcrumbs',

src/stories/components/Breadcrumbs/Code Examples.mdx

Lines changed: 26 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Meta, Canvas, Story, Controls, Markdown } from '@storybook/blocks';
22
import meta, {
33
Primary,
44
FourOrLessParentBreadcrumbs,
5-
MoreThanFourParentBreadcrumbs
5+
MoreThanFourParentBreadcrumbs,
66
} from './Breadcrumbs.stories';
77

88
<Meta of={meta} />
@@ -25,32 +25,35 @@ A navigation component to render a visual trail of the current user position in
2525

2626
## Basic example
2727

28+
- This component is only available on **Browse Pages**.
29+
- To view the examples and see this component in action, append your URL with `/group_id/1035`, as this corresponds to a Browse Page.
30+
2831
```jsx
29-
import { Breadcrumbs, CioPlp } from '@constructor-io/constructorio-ui-plp'
30-
31-
function myApp() {
32-
const groups = [
33-
...
34-
{
35-
group_id: 'coffee',
36-
display_name: 'Coffee',
37-
count: 2,
38-
data: {},
39-
children: [],
40-
parents: [
41-
{
42-
display_name: 'All',
43-
group_id: 'all',
44-
},
45-
],
46-
}
47-
];
32+
import { Breadcrumbs, CioPlp, CioPlpGrid, utils } from '@constructor-io/constructorio-ui-plp';
33+
import '@constructor-io/constructorio-ui-plp/styles.css';
34+
35+
const DEMO_API_KEY = 'key_M57QS8SMPdLdLx4x';
4836

37+
/**
38+
* Append your URL with /group_id/1035 to see the component in action
39+
*/
40+
export default function MyComponent() {
4941
return (
50-
<CioPlp apiKey={YOUR_API_KEY}>
51-
<Breadcrumbs groups={groups} filterValue="coffee" />
42+
<CioPlp apiKey={DEMO_API_KEY}>
43+
<CioPlpGrid>
44+
{(props) => {
45+
if (utils.isPlpBrowseDataResults(props.data) && props.browseFilterValue) {
46+
return (
47+
<Breadcrumbs
48+
groups={props.data.response.groups}
49+
filterValue={props.browseFilterValue}
50+
/>
51+
);
52+
}
53+
}}
54+
</CioPlpGrid>
5255
</CioPlp>
53-
)
56+
);
5457
}
5558
```
5659

@@ -61,43 +64,6 @@ When there's four or less parent breadcrumbs relative to the current group, the
6164
<Canvas sourceState='none'>
6265
<Story of={FourOrLessParentBreadcrumbs} />
6366
</Canvas>
64-
```jsx
65-
import { Breadcrumbs, CioPlp} from '@constructor-io/constructorio-ui-plp'
66-
67-
function myApp() {
68-
const groups = [
69-
...
70-
{
71-
group_id: 'coffee-accessories',
72-
display_name: 'Coffee Accessories',
73-
count: 2,
74-
data: {},
75-
children: [],
76-
parents: [
77-
{
78-
display_name: 'All',
79-
group_id: 'all',
80-
},
81-
{
82-
display_name: 'Coffee',
83-
group_id: 'coffee',
84-
},
85-
{
86-
display_name: 'Coffee Tools',
87-
group_id: 'coffee-tools',
88-
},
89-
],
90-
},
91-
]
92-
93-
return (
94-
<CioPlp apiKey={YOUR_API_KEY}>
95-
<Breadcrumbs groups={groups} filterValue="coffee-accessories" />
96-
</CioPlp>
97-
)
98-
}
99-
100-
```
10167

10268
## More than four parent Breadcrumbs
10369

@@ -108,56 +74,3 @@ When more than four parent breadcrumbs are present relative to the current group
10874
<Story of={MoreThanFourParentBreadcrumbs} />
10975
</div>
11076
</Canvas>
111-
```jsx
112-
import { Breadcrumbs, CioPlp} from '@constructor-io/constructorio-ui-plp'
113-
114-
function myApp() {
115-
const groups = [
116-
...
117-
{
118-
group_id: 'coffee-manual-grinders-espresso-ceramic',
119-
display_name: 'Manual Coffee Grinders for Espresso with Ceramic Conical Burrs',
120-
count: 2,
121-
data: {},
122-
children: [],
123-
parents: [
124-
{
125-
display_name: 'All',
126-
group_id: 'all',
127-
},
128-
{
129-
display_name: 'Coffee',
130-
group_id: 'coffee',
131-
},
132-
{
133-
display_name: 'Coffee Tools',
134-
group_id: 'coffee-tools',
135-
},
136-
{
137-
display_name: 'Coffee Grinders',
138-
group_id: 'coffee-grinders',
139-
},
140-
{
141-
display_name: 'Manual Coffee Grinders',
142-
group_id: 'manual-coffee-grinders',
143-
},
144-
{
145-
display_name: 'Manual Espresso Grinders',
146-
group_id: 'manual-espresso-grinders',
147-
},
148-
{
149-
display_name: 'Manual Espresso Grinders with Conical Burrs',
150-
group_id: 'manual-espresso-grinders-conical',
151-
},
152-
],
153-
},
154-
]
155-
156-
return (
157-
<CioPlp apiKey={YOUR_API_KEY}>
158-
<Breadcrumbs groups={groups} filterValue="coffee-manual-grinders-espresso-ceramic" />
159-
</CioPlp>
160-
)
161-
}
162-
163-
```

0 commit comments

Comments
 (0)