All files / src/grid/_example GridGapExample.jsx

50% Statements 3/6
100% Branches 0/0
40% Functions 2/5
50% Lines 3/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55            1x   1x                                                                 3x                          
import React, { Fragment, useState } from "react";
import { Row, Col } from "@tencent/tea-component/lib/grid";
import { Slider } from "@tencent/tea-component/lib/slider";
import { InputNumber } from "@tencent/tea-component/lib/inputnumber";
 
export default function GridGapExample() {
  const [gap, setGap] = useState(20);
 
  return (
    <Fragment>
      <Slider
        min={0}
        max={50}
        value={gap}
        onUpdate={value => setGap(value)}
        after={
          <InputNumber
            min={0}
            max={50}
            value={gap}
            onChange={value => setGap(value)}
          />
        }
        tipFormatter={value => `间距:${value}`}
      />
      <Row gap={gap}>
        <Col span={8}>
          <Box>col-8</Box>
        </Col>
        <Col span={8}>
          <Box>col-8</Box>
        </Col>
        <Col span={8}>
          <Box>col-8</Box>
        </Col>
      </Row>
    </Fragment>
  );
}
 
function Box({ children }) {
  return (
    <div
      style={{
        height: 30,
        lineHeight: "30px",
        textAlign: "center",
        background: "#eee",
      }}
    >
      {children}
    </div>
  );
}