UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

69 lines (68 loc) 2.65 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Flex = void 0; const React = __importStar(require("react")); const styled_1 = __importDefault(require("@emotion/styled")); const common_1 = require("@workday/canvas-kit-react/common"); const Box_1 = require("./Box"); const flex_1 = require("./utils/flex"); const StyledFlex = (0, styled_1.default)(Box_1.Box)({ display: 'flex', }, flex_1.flex); /** * `Flex` is a low-level layout component that provides a common, ergonomic API for applying CSS flexbox styles. * It is highly flexible, and can be used on its own or to build other components. * `Flex` is built on top of `Box` and has access to all `BoxProps`. * * @example * ```tsx * import { Flex, FlexProps } from '@workday/canvas-kit-react/layout'; * * interface CardProps extends FlexProps { * // card-specific props * } * * // `Card`'s default values are set using `FlexProps` * const Card = (props: CardProps) => ( * <Flex flexDirection="column" alignItems="flex-start" depth={1} space="m" {...props}> * <h1>Hello, Card!</h1> * <p>This card uses flexbox to set its layout.</p> * </Flex> * ); * ``` */ exports.Flex = (0, common_1.createComponent)('div')({ displayName: 'Flex', Component: ({ children, ...elemProps }, ref, Element) => { return (React.createElement(StyledFlex, { as: Element, ref: ref, ...elemProps }, children)); }, subComponents: { Item: Box_1.Box, }, });