MCPcopy Index your code
hub / github.com/primer/react / SelectPanelFooter

Function SelectPanelFooter

packages/react/src/drafts/SelectPanel2/SelectPanel.tsx:476–517  ·  view source on GitHub ↗
({...props})

Source from the content-addressed store, hash-verified

474
475const FooterContext = React.createContext<boolean>(false)
476const SelectPanelFooter = ({...props}) => {
477 const {onCancel, selectionVariant} = React.useContext(SelectPanelContext)
478
479 const hidePrimaryActions = selectionVariant === 'instant'
480 const buttonSize = useResponsiveValue(responsiveButtonSizes, 'small')
481
482 if (hidePrimaryActions && !props.children) {
483 // nothing to render
484 // todo: we can inform them the developer footer will render nothing
485 return null
486 }
487
488 return (
489 <FooterContext.Provider value={true}>
490 <Box
491 sx={{
492 display: 'flex',
493 justifyContent: 'space-between',
494 alignItems: 'center',
495 flexShrink: 0,
496 padding: hidePrimaryActions ? 2 : 3,
497 minHeight: '44px',
498 borderTop: '1px solid',
499 borderColor: 'border.default',
500 }}
501 >
502 <Box sx={{flexGrow: hidePrimaryActions ? 1 : 0}}>{props.children}</Box>
503
504 {hidePrimaryActions ? null : (
505 <Box sx={{display: 'flex', gap: 2}}>
506 <Button type="button" size={buttonSize} onClick={() => onCancel()}>
507 Cancel
508 </Button>
509 <Button type="submit" size={buttonSize} variant="primary">
510 Save
511 </Button>
512 </Box>
513 )}
514 </Box>
515 </FooterContext.Provider>
516 )
517}
518
519const SecondaryButton: React.FC<ButtonProps> = props => {
520 const size = useResponsiveValue(responsiveButtonSizes, 'small')

Callers

nothing calls this directly

Calls 2

useResponsiveValueFunction · 0.90
onCancelFunction · 0.70

Tested by

no test coverage detected