mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
1955c3911b
commit
3d9a88c7af
@ -1,4 +1,4 @@
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user