100201组件拆分_编辑器-react-仿低代码平台项目

文章目录

    • [1 设计UI,组件拆分](#1 设计UI,组件拆分)
    • [2 实现](#2 实现)
    • 关于

1 设计UI,组件拆分

编辑器整体如上图所示,重点关注:

  • flex弹性布局
    • 上
      • 左
      • 中
      • 右
    • 下
      • 左
      • 中
      • 右
  • 画布居中
  • 画布Y轴滚动

2 实现

src/pages/question/Edit/index.tsx代码如下:

ts 复制代码
import { FC } from "react";
import useLoadQuestionData from "@/hooks/useLoadQuestionData";

import styles from "./index.module.scss";

const Edit: FC = () => {
  // 获取问卷信息
  const { loading } = useLoadQuestionData();

  return (
    <div className={styles.container}>
      <div style={{ backgroundColor: "#fff", height: "40px" }}>Header</div>
      <div className={styles["content-wrapper"]}>
        <div className={styles.content}>
          <div className={styles.left}>Left</div>
          <div className={styles.main}>
            <div className={styles["canvas-wrapper"]}>
            
            </div>
          </div>
          <div className={styles.right}>Right</div>
        </div>
      </div>
    </div>
  );
};

export default Edit;

src/pages/question/Edit/index.module.scss代码如下:

scss 复制代码
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f0f2f5;
}

.content-wrapper {
  flex: auto;
  padding: 12px 0;
}

.content {
  display: flex;
  margin: 0 24px;
  height: 100%;

  .left {
    width: 285px;
    background-color: #fff;
    padding: 0 12px;
  }

  .main {
    flex: 1;
    position: relative;
    overflow: hidden;

    .canvas-wrapper {
      position: absolute;
      width: 400px;
      height: 712px;
      top: 50%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
      overflow: auto;
      box-shadow: 0 2px 10px #00001f;
    }
  }

  .right {
    width: 300px;
    background-color: #fff;
    padding: 0 12px;
  }
}

效果如下图所示:

关于

❓QQ:806797785

⭐️仓库地址:https://gitee.com/gaogzhen

⭐️仓库地址:https://github.com/gaogzhen

1react官网CP/OL.

2Redux官网CP/OL.

相关推荐
用户2788607285671 小时前
别把 tool.completed 当成业务成功:AI 工具权限审计的四层事件链
前端
陆柒1451 小时前
跟着 Webpack 配置学习前端工程化
前端
用户6353300254791 小时前
Day 1|HTML5:一个商城首页的骨架,从 DOCTYPE 到语义化
前端
平凡的阿泽1 小时前
我用 Trae 实现了AI辩论赛
前端
对空六课1 小时前
指标口径生效时间的版本查询实现
大数据·服务器·前端·算法·数据分析
对空六课1 小时前
RFM分层边界变化的回溯计算
大数据·服务器·前端·数据库·人工智能·算法·数据分析
IT_陈寒2 小时前
Vite打包的诡异行为,让我差点提交了个错误版本
前端·人工智能·后端
鹏多多2 小时前
前端是如何死去的?| 完整时间线
前端·javascript·程序员
coding漫漫长路2 小时前
海报挪进Worker画,canvas字体又变回默认了
前端
看浪的路人2 小时前
第2讲:ReAct 模式从零实现——不用框架,手写一个 Agent 内核
前端·react.js·前端框架