@@ -8,6 +8,7 @@ storybookPath: 'design-system-components-sidepanel'
88packageTypes :
99 [
1010 ' clay-core/src/side-panel/SidePanel.tsx' ,
11+ ' clay-core/src/side-panel/SidePanelWithDrilldown.tsx' ,
1112 ' clay-core/src/side-panel/Header.tsx' ,
1213 ' clay-core/src/side-panel/Title.tsx' ,
1314 ' clay-core/src/side-panel/Body.tsx' ,
@@ -162,3 +163,147 @@ The SidePanel is designed to use either `absolute` or `fixed` positioning.
162163``` jsx
163164< SidePanel position= " fixed" / >
164165```
166+
167+ ## Variants
168+
169+ ### Drilldown
170+
171+ This variant provides a Drilldown in the Side Panel, allowing users to explore more detailed content without losing their navigation context. It facilitates the visualization of hierarchical or related information within the side panel.
172+
173+ ``` jsx preview
174+ import Button from ' @clayui/button' ;
175+ import {Provider , SidePanel , SidePanelWithDrilldown } from ' @clayui/core' ;
176+ import React , {useRef , useState } from ' react' ;
177+
178+ import ' @clayui/css/lib/css/atlas.css' ;
179+
180+ export default function App () {
181+ const [open , setOpen ] = React .useState (true );
182+ const [panelKey , setPanelKey ] = useState (' x1' );
183+
184+ const ref = React .useRef ();
185+
186+ return (
187+ < Provider spritemap= " /public/icons.svg" >
188+ < div className= " p-4" ref= {ref} style= {{minHeight: ' 100vh' }}>
189+ < Button
190+ aria- controls= " sidepanel-example"
191+ aria- pressed= {open}
192+ onClick= {() => setOpen (! open)}
193+ >
194+ Open
195+ < / Button>
196+ < SidePanelWithDrilldown
197+ containerRef= {ref}
198+ id= " sidepanel-example"
199+ onOpenChange= {setOpen}
200+ onSelectedPanelKeyChange= {setPanelKey}
201+ open= {open}
202+ panels= {{
203+ x1: {
204+ component: (
205+ < SidePanel .Body >
206+ < button
207+ className= " list-group-item list-group-item-action"
208+ onClick= {() => setPanelKey (' x2' )}
209+ >
210+ List Item 1
211+ < / button>
212+ < button
213+ className= " list-group-item list-group-item-action"
214+ onClick= {() => setPanelKey (' x3' )}
215+ >
216+ List Item 2
217+ < / button>
218+ < / SidePanel .Body >
219+ ),
220+ title: ' Drilldown Title' ,
221+ },
222+ x2: {
223+ component: (
224+ < SidePanel .Body >
225+ This is more detailed content without losing
226+ the navigation context.
227+ < / SidePanel .Body >
228+ ),
229+ headerMessages: {
230+ backAriaLabel: ' Back to previous panel' ,
231+ },
232+ parentKey: ' x1' ,
233+ title: ' List Item 1 Detail' ,
234+ },
235+ x3: {
236+ component: (
237+ < SidePanel .Body >
238+ This is more detailed content without losing
239+ the navigation context.
240+ < / SidePanel .Body >
241+ ),
242+ headerMessages: {
243+ backAriaLabel: ' Back to previous panel' ,
244+ },
245+ parentKey: ' x1' ,
246+ title: ' List Item 2 Detail' ,
247+ },
248+ }}
249+ position= " fixed"
250+ selectedPanelKey= {panelKey}
251+ / >
252+ < / div>
253+ < / Provider>
254+ );
255+ }
256+ ```
257+
258+ The Drilldown component establishes navigation by referencing panels through their keys, so each panel must have a unique ` key ` .
259+
260+ ``` js
261+ const panels = {
262+ of23: {
263+ component: < SidePanel .Body > Drilldown Body< / SidePanel .Body > ,
264+ title: ' Drilldown Title' ,
265+ },
266+ };
267+ ```
268+
269+ Using the ` key ` , you can link a panel to its parent by setting its ` parentKey ` property.
270+
271+ ``` js
272+ const panels = {
273+ of23: {
274+ component: (
275+ < SidePanel .Body >
276+ Drilldown Body
277+ < button onClick= {() => setPanelKey (' of09' )}> List Item< / button>
278+ < / SidePanel .Body >
279+ ),
280+ title: ' Drilldown Title' ,
281+ },
282+ of09: {
283+ component: (
284+ < SidePanel .Body >
285+ This is more detailed content without losing the navigation
286+ context.
287+ < / SidePanel .Body >
288+ ),
289+ title: ' List Item Detail' ,
290+ parentKey: ' of23' ,
291+ },
292+ };
293+ ```
294+
295+ <div className = " clay-site-alert alert alert-info" >
296+ <strong className = " lead" >Info</strong >
297+ The <code className = " language-text" >SidePanelWithDrilldown</code > component always
298+ displays a header. If a panel defines a <code className = " language-text" >
299+ parentKey
300+ </code > (i.e., it is part of a hierarchy), the header includes a back button
301+ that lets users return to the parent panel.
302+ </div >
303+
304+ <div className = " clay-site-alert alert alert-warning" >
305+ An important thing to keep in mind is that the ` SidePanelWithDrilldown `
306+ component renders panels in the order in which they are defined. If the
307+ panels are defined in the wrong order, the panel animation may not behave
308+ correctly.
309+ </div >
0 commit comments