mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
🆙 Init V3
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { CSSProperties, FC, useMemo } from 'react';
|
||||
import { Grid, GridProps } from './Grid';
|
||||
|
||||
export interface AutoGridProps extends GridProps
|
||||
{
|
||||
columnMinWidth?: number;
|
||||
columnMinHeight?: number;
|
||||
}
|
||||
|
||||
export const AutoGrid: FC<AutoGridProps> = props =>
|
||||
{
|
||||
const { columnMinWidth = 40, columnMinHeight = 40, columnCount = 0, fullHeight = false, maxContent = true, overflow = 'auto', style = {}, ...rest } = props;
|
||||
|
||||
const getStyle = useMemo(() =>
|
||||
{
|
||||
let newStyle: CSSProperties = {};
|
||||
|
||||
newStyle['--nitro-grid-column-min-height'] = (columnMinHeight + 'px');
|
||||
|
||||
if(columnCount > 1) newStyle.gridTemplateColumns = `repeat(auto-fill, minmax(${ columnMinWidth }px, 1fr))`;
|
||||
|
||||
if(Object.keys(style).length) newStyle = { ...newStyle, ...style };
|
||||
|
||||
return newStyle;
|
||||
}, [ columnMinWidth, columnMinHeight, columnCount, style ]);
|
||||
|
||||
return <Grid columnCount={ columnCount } fullHeight={ fullHeight } overflow={ overflow } style={ getStyle } { ...rest } />;
|
||||
};
|
||||
Reference in New Issue
Block a user