Skip to content

Commit

Permalink
fix: scroll when extending parent container
Browse files Browse the repository at this point in the history
  • Loading branch information
collinlokken committed Jan 19, 2024
1 parent de90a8d commit 014ed92
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"type": "PLUGINS:dm-core-plugins/grid/GridArea",
"rowStart": 4,
"columnStart": 1,
"rowEnd": 5,
"rowEnd": 4,
"columnEnd": 3
}
},
Expand All @@ -83,7 +83,7 @@
"type": "PLUGINS:dm-core-plugins/grid/GridArea",
"rowStart": 4,
"columnStart": 4,
"rowEnd": 5,
"rowEnd": 4,
"columnEnd": 6
}
},
Expand All @@ -101,7 +101,7 @@
"type": "PLUGINS:dm-core-plugins/grid/GridArea",
"rowStart": 5,
"columnStart": 1,
"rowEnd": 6,
"rowEnd": 5,
"columnEnd": 6
}
}
Expand Down
11 changes: 10 additions & 1 deletion example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ const Content = () => {
<DMSSProvider dmssBasePath={import.meta.env.VITE_DMSS_URL}>
<DMJobProvider dmJobPath={import.meta.env.VITE_DM_JOB_URL}>
<UiPluginProvider pluginsToLoad={plugins}>
<App />
<div
style={{
display: 'flex',
height: '100vh',
width: '100vw',
overflow: 'hidden',
}}
>
<App />
</div>
</UiPluginProvider>
<ToastContainer />
</DMJobProvider>
Expand Down
20 changes: 16 additions & 4 deletions packages/dm-core-plugins/src/data-grid/DataGridPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ export function DataGridPlugin(props: IUIPlugin) {
}

return !data ? null : (
<Stack alignItems='flex-end' spacing={1}>
<Stack
alignItems='flex-start'
spacing={1}
style={{ width: '100%', height: '100%', overflow: 'auto' }}
>
<DataGrid
attributeType={attribute?.attributeType || 'string'}
config={userConfig}
Expand All @@ -123,9 +127,17 @@ export function DataGridPlugin(props: IUIPlugin) {
title={document?.title}
/>
{config.editable && (
<Button onClick={saveDocument} disabled={!isDirty || loading}>
Save
</Button>
<div
style={{
width: '100%',
height: '100%',
overflow: 'hidden',
}}
>
<Button onClick={saveDocument} disabled={!isDirty || loading}>
Save
</Button>
</div>
)}
</Stack>
)
Expand Down
10 changes: 8 additions & 2 deletions packages/dm-core-plugins/src/explorer/ExplorerPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default () => {
undefined
)
return (
<div style={{ display: 'flex', height: '100vh', width: '100%' }}>
<div style={{ display: 'flex', height: '100%', width: '100%' }}>
{loading ? (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<Progress.Circular />
Expand All @@ -41,7 +41,13 @@ export default () => {
</Sidebar>
)}
{selectedType && selectedEntity && (
<div style={{ width: '100%', padding: '20px' }}>
<div
style={{
width: '100%',
height: '100%',
display: 'flex',
}}
>
<EntityView
type={selectedType}
idReference={selectedEntity}
Expand Down
1 change: 1 addition & 0 deletions packages/dm-core-plugins/src/form/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { AttributeList } from './AttributeList'
const Wrapper = styled.div`
max-width: 650px;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
`
Expand Down
21 changes: 14 additions & 7 deletions packages/dm-core-plugins/src/grid/GridElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const Element = styled.div<TElementProps>`
`${props.itemBorder.size} ${props.itemBorder.style} ${props.itemBorder.color}`};
border-radius: ${(props: TElementProps) =>
props.showItemBorders && props.itemBorder.radius};
padding: 10px;
`

type TGridItemProps = {
Expand All @@ -46,12 +45,20 @@ export const GridElement = (props: TGridItemProps): React.ReactElement => {
itemBorder={itemBorder}
>
{item?.title && <Typography variant='h4'>{item.title}</Typography>}
<ViewCreator
idReference={idReference}
viewConfig={item.viewConfig}
onSubmit={onSubmit}
onChange={onChange}
/>
<div
style={{
height: '100%',
width: '100%',
display: 'flex',
}}
>
<ViewCreator
idReference={idReference}
viewConfig={item.viewConfig}
onSubmit={onSubmit}
onChange={onChange}
/>
</div>
</Element>
)
}
11 changes: 5 additions & 6 deletions packages/dm-core-plugins/src/grid/GridPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import { TGridPluginConfig, TGridSize } from './types'

const Grid = styled.div<TGridSize>`
display: grid;
overflow: auto;
width: 100%;
height: 100%;
grid-template-rows: ${(props) =>
props.rowSizes
? props.rowSizes.join(' ')
: Array(props.rows + 1)
.fill('1fr')
.join('')};
: 'repeat(' + props.rows + ', 1fr)'};
grid-template-columns: ${(props) =>
props.columnSizes
? props.columnSizes.join(' ')
: Array(props.columns + 1)
.fill('1fr')
.join('')};
: 'repeat(' + props.columns + ', 1fr)'};
grid-column-gap: ${(props) => props.columnGap};
grid-row-gap: ${(props) => props.rowGap};
`
Expand Down
30 changes: 23 additions & 7 deletions packages/dm-core-plugins/src/header/HeaderPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,21 @@ export default (props: IUIPlugin): React.ReactElement => {
? config.uiRecipesList
: uiRecipes.map((recipe: TUiRecipe) => recipe.name)
return (
<div>
<div
style={{
display: 'flex',
width: '100%',
height: '100%',
flexDirection: 'column',
}}
>
<TopBar
style={{
display: 'flex',
justifyItems: 'center',
justifyContent: 'space-between',
marginBottom: '8px',
height: '64px',
}}
>
<TopBar.Header
Expand Down Expand Up @@ -169,12 +177,20 @@ export default (props: IUIPlugin): React.ReactElement => {
setIsOpen={setVisibleUserInfo}
applicationEntity={entity}
/>
<UIPlugin
key={idReference + selectedRecipe.name}
idReference={idReference}
type={entity.type}
config={selectedRecipe.config}
/>
<div
style={{
height: 'calc(100% - 64px)',
width: '100%',
display: 'flex',
}}
>
<UIPlugin
key={idReference + selectedRecipe.name}
idReference={idReference}
type={entity.type}
config={selectedRecipe.config}
/>
</div>
</div>
)
}
Loading

0 comments on commit 014ed92

Please sign in to comment.