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

1\][react官网](https://reactjs.org/)\[CP/OL\]. \[2\][Redux官网](https://redux.js.org/)\[CP/OL\].

相关推荐
ppandss18 分钟前
JavaWeb从0到1-DAY4-AJAX
前端·ajax·okhttp
涵涵(互关)25 分钟前
语法大全-only-writer-two
前端·vue.js·typescript
huangql52027 分钟前
浏览器 Location API、History API、路由记录与支付跳转完全指南
前端
木斯佳29 分钟前
前端八股文面经大全:腾讯前端实习一面(2026-04-27)·面经深度解析
前端·八股·面经
天天进步201530 分钟前
魔音漫创源码解析:架构总览:Electron 30 + React 18 + Zustand,构建桌面级影视生产工具
react.js·架构·electron
sayamber34 分钟前
Kubernetes 生产环境避坑指南:10 个真实故障案例与解决方案
前端
清寒_1 小时前
分层理解AI架构,降低对AI复杂度的恐惧
前端·人工智能·ai编程
牧码岛1 小时前
Web前端之JavaScrip中的Array、Object、Map和Set详解
前端·javascript·web·web前端
Bigger1 小时前
😮‍💨 有了 AI 之后,我怎么感觉反而更累了?
前端·aigc·ai编程
Dxy12393102161 小时前
HTML中使用Canvas动态图形渲染:解锁Web交互新维度
前端·html·图形渲染