Commit 3d9a88c7 by Alex Khomenko Committed by GitHub

Grafana-UI: Extend Layout props (#23771)

* Grafana-UI: Extend Layout props

* Grafana-UI: Merge container styles

* Search: Fix prop types

* Grafana-UI: remove className prop
parent 1955c391
import React from 'react';
import React, { HTMLProps } from 'react';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';
import { stylesFactory, useTheme } from '../../themes';
......@@ -11,7 +11,7 @@ type Spacing = 'none' | 'xs' | 'sm' | 'md' | 'lg';
type Justify = 'flex-start' | 'flex-end' | 'space-between' | 'center';
type Align = 'normal' | 'flex-start' | 'flex-end' | 'center';
export interface LayoutProps {
export interface LayoutProps extends Omit<HTMLProps<HTMLDivElement>, 'align' | 'children' | 'wrap'> {
children: React.ReactNode[] | React.ReactNode;
orientation?: Orientation;
spacing?: Spacing;
......@@ -34,11 +34,12 @@ export const Layout: React.FC<LayoutProps> = ({
align = 'normal',
wrap = false,
width = 'auto',
...rest
}) => {
const theme = useTheme();
const styles = getStyles(theme, orientation, spacing, justify, align, wrap);
return (
<div className={styles.layout} style={{ width }}>
<div className={styles.layout} style={{ width }} {...rest}>
{React.Children.toArray(children)
.filter(Boolean)
.map((child, index) => {
......@@ -110,7 +111,6 @@ const getStyles = stylesFactory(
margin-right: ${orientation === Orientation.Horizontal ? finalSpacing : 0};
display: flex;
align-items: ${align};
// height: 100%;
&:last-child {
margin-bottom: 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment