1- import { Icon , Stack } from '@openedx/paragon' ;
1+ import {
2+ Dropdown ,
3+ Icon ,
4+ IconButton ,
5+ Stack ,
6+ } from '@openedx/paragon' ;
7+ import { MoreVert } from '@openedx/paragon/icons' ;
28
39export interface SidebarSectionProps {
410 /** Title of the section */
511 title : string ;
612 /** Icon to be displayed in the section */
713 icon ?: React . ComponentType ;
14+ /** Actions to be displayed in the section */
15+ actions ?: [
16+ {
17+ /** Label of the action */
18+ label : string ;
19+ /** Function to be called when the action is clicked */
20+ onClick : ( ) => void ;
21+ } ,
22+ ] ;
823 /** Content of the section */
924 children : React . ReactNode ;
1025}
@@ -26,13 +41,35 @@ export interface SidebarSectionProps {
2641 * </SidebarSection>
2742 * ```
2843 */
29- export const SidebarSection = ( { title, icon, children } : SidebarSectionProps ) => (
44+ export const SidebarSection = ( {
45+ title, icon, actions, children,
46+ } : SidebarSectionProps ) => (
3047 < Stack gap = { 2 } >
3148 < Stack direction = "horizontal" gap = { 2 } >
3249 { icon && < Icon src = { icon } className = "mr-1 text-primary" size = "sm" /> }
3350 < h3 className = "h5 font-weight-bold text-primary mb-0" >
3451 { title }
3552 </ h3 >
53+ { actions && (
54+ < Dropdown className = "ml-auto" >
55+ < Dropdown . Toggle
56+ as = { IconButton }
57+ src = { MoreVert }
58+ iconAs = { Icon }
59+ size = "sm"
60+ />
61+ < Dropdown . Menu >
62+ { actions . map ( ( action ) => (
63+ < Dropdown . Item
64+ key = { action . label }
65+ onClick = { action . onClick }
66+ >
67+ { action . label }
68+ </ Dropdown . Item >
69+ ) ) }
70+ </ Dropdown . Menu >
71+ </ Dropdown >
72+ ) }
3673 </ Stack >
3774 { children }
3875 </ Stack >
0 commit comments