feat: Introduce contextualBar surface renderer for UiKit blocks (#29697)
parent
e2d6aefc41
commit
dbdf45b0e5
@ -0,0 +1,7 @@ |
||||
--- |
||||
"@rocket.chat/meteor": minor |
||||
"@rocket.chat/fuselage-ui-kit": minor |
||||
"@rocket.chat/uikit-playground": minor |
||||
--- |
||||
|
||||
feat: Introduce contextualBar surface renderer for UiKit blocks |
||||
@ -0,0 +1,18 @@ |
||||
import { Margins } from '@rocket.chat/fuselage'; |
||||
import type { ReactElement, ReactNode } from 'react'; |
||||
|
||||
import { Surface } from './Surface'; |
||||
|
||||
type ContextualBarSurfaceProps = { |
||||
children?: ReactNode; |
||||
}; |
||||
|
||||
const ContextualBarSurface = ({ |
||||
children, |
||||
}: ContextualBarSurfaceProps): ReactElement => ( |
||||
<Surface type='contextualBar'> |
||||
<Margins blockEnd='x16'>{children}</Margins> |
||||
</Surface> |
||||
); |
||||
|
||||
export default ContextualBarSurface; |
||||
@ -0,0 +1,15 @@ |
||||
import { FuselageSurfaceRenderer } from './FuselageSurfaceRenderer'; |
||||
|
||||
export class FuselageContextualBarSurfaceRenderer extends FuselageSurfaceRenderer { |
||||
public constructor() { |
||||
super([ |
||||
'actions', |
||||
'context', |
||||
'divider', |
||||
'image', |
||||
'input', |
||||
'section', |
||||
'preview', |
||||
]); |
||||
} |
||||
} |
||||
@ -0,0 +1,67 @@ |
||||
import { |
||||
Avatar, |
||||
Box, |
||||
Button, |
||||
ButtonGroup, |
||||
Contextualbar, |
||||
ContextualbarAction, |
||||
ContextualbarFooter, |
||||
ContextualbarHeader, |
||||
ContextualbarTitle, |
||||
Margins, |
||||
} from '@rocket.chat/fuselage'; |
||||
import { Scrollbars } from 'rc-scrollbars'; |
||||
import { useLayoutSizes } from '@rocket.chat/ui-contexts'; |
||||
|
||||
import DraggableList from '../../../Draggable/DraggableList'; |
||||
import type { DraggableListProps } from '../../../Draggable/DraggableList'; |
||||
|
||||
const ContextualBarSurface = ({ blocks, onDragEnd }: DraggableListProps) => ( |
||||
<Contextualbar height='100%' width={useLayoutSizes().contextualBar} position='absolute'> |
||||
<ContextualbarHeader> |
||||
<Avatar url='data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==' /> |
||||
<ContextualbarTitle>{'Contextual Bar'}</ContextualbarTitle> |
||||
<ContextualbarAction data-qa='ContextualbarActionClose' title='Close' name='cross' /> |
||||
</ContextualbarHeader> |
||||
|
||||
<Box height='100%' p='12px'> |
||||
<Box |
||||
height='100%' |
||||
display='flex' |
||||
flexShrink={1} |
||||
flexDirection='column' |
||||
flexGrow={1} |
||||
overflow='hidden' |
||||
> |
||||
<Scrollbars |
||||
autoHide |
||||
autoHideTimeout={2000} |
||||
autoHideDuration={500} |
||||
style={{ |
||||
width: '100%', |
||||
height: '100%', |
||||
flexGrow: 1, |
||||
willChange: 'transform', |
||||
overflowY: 'hidden', |
||||
}} |
||||
renderThumbVertical={({ style, ...props }): JSX.Element => ( |
||||
<div {...props} style={{ ...style, backgroundColor: 'rgba(0, 0, 0, 0.5)', borderRadius: '7px' }} /> |
||||
)} |
||||
> |
||||
<Margins blockEnd='x16'> |
||||
<DraggableList surface={3} blocks={blocks} onDragEnd={onDragEnd} /> |
||||
</Margins> |
||||
</Scrollbars> |
||||
</Box> |
||||
</Box> |
||||
|
||||
<ContextualbarFooter> |
||||
<ButtonGroup stretch> |
||||
<Button>Cancel</Button> |
||||
<Button primary>Submit</Button> |
||||
</ButtonGroup> |
||||
</ContextualbarFooter> |
||||
</Contextualbar> |
||||
); |
||||
|
||||
export default ContextualBarSurface; |
||||
Loading…
Reference in new issue