UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

73 lines (72 loc) 2.78 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Grid = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const styled_1 = __importDefault(require("@emotion/styled")); const common_1 = require("@workday/canvas-kit-react/common"); const Box_1 = require("./Box"); const grid_1 = require("./utils/grid"); const StyledGrid = (0, styled_1.default)(Box_1.Box)({ display: 'grid', }, grid_1.grid); const GridItem = (0, common_1.createComponent)('div')({ displayName: 'Grid.Item', Component: ({ children, ...elemProps }, ref, Element) => { return ((0, jsx_runtime_1.jsx)(Box_1.Box, { as: Element, ref: ref, ...elemProps, children: children })); }, }); /** * `Grid` is a two-dimensional layout system for the web. It lets you lay content out in rows and columns. * It is highly flexible, and can be used on its own or to build other components. * `Grid` is built on top of `Box` and has access to all `BoxProps`. * * @example * ```tsx * import { Grid } from '@workday/canvas-kit-react/layout'; * * interface CardProps extends GridProps { * // card-specific props * } * * // `Card`'s default values are set using `GridProps` * const Card = (props: CardProps) => ( * <Grid gridAutoFlow="row" alignItems="start" depth={1} space="m" {...props}> * <h1>Hello, Card!</h1> * <p>This card uses grid to set its layout.</p> * </Grid> * ); *``` */ exports.Grid = (0, common_1.createComponent)('div')({ displayName: 'Grid', Component: ({ children, ...elemProps }, ref, Element) => { return ((0, jsx_runtime_1.jsx)(StyledGrid, { as: Element, ref: ref, ...elemProps, children: children })); }, subComponents: { /** * `<Grid.Item />` is the child specific sub-component to `<Grid/>`. `<Grid.Item />` gets child specific props, whereas `<Grid./>` gets parent container props. * * @example * ``` * import { Grid } from '@workday/canvas-kit-react/layout'; * `Grid` is built on top of `Box` so `<Grid.Item />` gets all `BoxProps` as well. * * interface CardProps extends GridItemStyleProps { * // card-specific props * } * * // `Card`'s default values are set using `GridItemStyleProps` * const Card = (props: CardProps) => ( * <Grid.Item gridRowStart="1" gridArea="Card" {...props}> * <h1>Hello, Card!</h1> * <p>This card uses grid child specific props to set its layout.</p> * </Grid.Item> * ); *``` */ Item: GridItem, }, });