Skip to content

Commit

Permalink
Add: Add new components for row and column layouts
Browse files Browse the repository at this point in the history
Both components are based on mantine and flexbox. They are intended to
replace Layout especially in dialogs.
  • Loading branch information
bjoernricks committed Jun 6, 2024
1 parent b18c422 commit cf751df
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/web/components/layout/column.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* SPDX-FileCopyrightText: 2024 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import {Flex} from '@mantine/core';

import PropTypes from 'web/utils/proptypes';

/**
* React component that renders a stack (column) layout
*
*/
const Column = ({
children,
gap = 'md',
grow,
align = 'stretch',
wrap,
justify = 'flex-start',
...props
}) => {
return (
<Flex
{...props}
direction="column"
gap={gap}
grow={grow}
align={align}
wrap={wrap}
justify={justify}
>
{children}
</Flex>
);
};

Column.propTypes = {
align: PropTypes.string,
gap: PropTypes.string,
grow: PropTypes.numberOrNumberString,
justify: PropTypes.string,
wrap: PropTypes.string,
};

export default Column;
46 changes: 46 additions & 0 deletions src/web/components/layout/row.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* SPDX-FileCopyrightText: 2024 Greenbone AG
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import {Flex} from '@mantine/core';

import PropTypes from 'web/utils/proptypes';

/**
* React component that renders a row layout
*
*/
const Row = ({
children,
gap = 'md',
grow,
align = 'center',
wrap,
justify,
...props
}) => {
return (
<Flex
{...props}
direction="row"
gap={gap}
grow={grow}
align={align}
wrap={wrap}
justify={justify}
>
{children}
</Flex>
);
};

Row.propTypes = {
align: PropTypes.string,
gap: PropTypes.string,
grow: PropTypes.numberOrNumberString,
justify: PropTypes.string,
wrap: PropTypes.string,
};

export default Row;

0 comments on commit cf751df

Please # to comment.