getFlexString (Grid/col.tsx)

arco-design · components/Grid/col.tsx · typescript · MIT
ui

Responsive grid column component with flexbox and gutter support

// Source: https://github.com/arco-design/arco-design | License: MIT | Copyright 2021 Bytedance, Inc. and its affiliates
// Provided via justclaw.it.com; keep this notice with the code.
import React, { useContext, useMemo, forwardRef } from 'react';
import cs from '../_util/classNames';
import { isNumber, isObject } from '../_util/is';
import { ConfigContext } from '../ConfigProvider';
import { ColProps, FlexType } from './interface';
import useMergeProps from '../_util/hooks/useMergeProps';
import { RowContext } from './context';

const defaultProps: ColProps = {
  span: 24,
};

function getFlexString(flex: FlexType) {
  if (typeof flex === 'string' && /\d+[px|%|em|rem|]{1}/.test(flex)) {
    return `0 0 ${flex}`;
  }
  return flex;
}

function Col(baseProps: ColProps, ref) {
  const { ge

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key