Files
mywebbuilder.js/css/editor.css
wtz 905c7bb8dc feat: add resize handles for component size editing
Add resize handles to allow direct size editing of components.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-02 16:15:47 +08:00

518 lines
8.5 KiB
CSS

/* 基础样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: #f0f2f5;
color: #333;
}
/* 应用容器 */
.app-container {
display: flex;
flex-direction: column;
height: 100vh;
}
/* 顶部工具栏 */
.toolbar {
display: flex;
align-items: center;
padding: 12px 20px;
background: #fff;
border-bottom: 1px solid #e8e8e8;
gap: 20px;
}
.toolbar-title {
font-size: 18px;
font-weight: 600;
color: #1890ff;
}
.toolbar-actions {
display: flex;
gap: 10px;
flex: 1;
}
.toolbar-info {
font-size: 14px;
color: #666;
background: #f5f5f5;
padding: 6px 12px;
border-radius: 4px;
}
/* 按钮样式 */
.btn {
padding: 8px 16px;
border: 1px solid #d9d9d9;
border-radius: 4px;
background: #fff;
font-size: 14px;
cursor: pointer;
transition: all 0.3s;
}
.btn:hover {
border-color: #1890ff;
color: #1890ff;
}
.btn-primary {
background: #1890ff;
border-color: #1890ff;
color: #fff;
}
.btn-primary:hover {
background: #40a9ff;
border-color: #40a9ff;
color: #fff;
}
.btn-danger {
color: #ff4d4f;
border-color: #ff4d4f;
}
.btn-danger:hover {
background: #ff4d4f;
color: #fff;
}
.btn-delete {
width: 100%;
padding: 8px 16px;
background: #ff4d4f;
border: none;
border-radius: 4px;
color: #fff;
font-size: 14px;
cursor: pointer;
transition: background 0.3s;
}
.btn-delete:hover {
background: #ff7875;
}
/* 编辑器容器 */
.editor-container {
display: flex;
flex: 1;
overflow: hidden;
}
/* 工具箱 */
.webbuilder-toolbox {
width: 200px;
background: #fff;
border-right: 1px solid #e8e8e8;
display: flex;
flex-direction: column;
}
.webbuilder-toolbox-title {
padding: 16px;
font-size: 14px;
font-weight: 600;
border-bottom: 1px solid #e8e8e8;
color: #333;
}
.webbuilder-toolbox-list {
flex: 1;
padding: 12px;
overflow-y: auto;
}
.webbuilder-toolbox-item {
display: flex;
align-items: center;
gap: 10px;
padding: 12px;
margin-bottom: 8px;
background: #fafafa;
border: 1px solid #e8e8e8;
border-radius: 4px;
cursor: grab;
transition: all 0.3s;
}
.webbuilder-toolbox-item:hover {
border-color: #1890ff;
background: #e6f7ff;
}
.webbuilder-toolbox-item .icon {
font-size: 20px;
}
.webbuilder-toolbox-item .label {
font-size: 13px;
color: #333;
}
/* 画布容器 */
.webbuilder-canvas-wrapper {
flex: 1;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 20px;
overflow: auto;
background: #e8e8e8;
}
/* 画布 */
.webbuilder-canvas {
background: #fff;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
transition: all 0.3s;
}
.webbuilder-canvas.dropping {
outline: 2px dashed #1890ff;
outline-offset: -2px;
}
/* 组件 */
.webbuilder-component {
background: #fff;
border: 2px solid transparent;
border-radius: 4px;
transition: border-color 0.3s;
cursor: move;
position: relative;
overflow: visible;
}
.webbuilder-component:hover {
border-color: #91d5ff;
}
.webbuilder-component.selected {
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
/* 尺寸控制柄容器 */
.resize-handles-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
}
/* 尺寸控制柄 */
.resize-handle {
position: absolute;
width: 8px;
height: 8px;
background: #1890ff;
border: 1px solid #fff;
border-radius: 2px;
pointer-events: auto;
z-index: 11;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}
.resize-handle:hover {
background: #40a9ff;
transform: scale(1.2);
}
.resize-handle-nw {
cursor: nwse-resize;
}
.resize-handle-n {
cursor: ns-resize;
}
.resize-handle-ne {
cursor: nesw-resize;
}
.resize-handle-w {
cursor: ew-resize;
}
.resize-handle-e {
cursor: ew-resize;
}
.resize-handle-sw {
cursor: nesw-resize;
}
.resize-handle-s {
cursor: ns-resize;
}
.resize-handle-se {
cursor: nwse-resize;
}
/* 属性面板 */
.webbuilder-property-panel {
width: 280px;
background: #fff;
border-left: 1px solid #e8e8e8;
overflow-y: auto;
}
.property-title {
padding: 16px;
font-size: 14px;
font-weight: 600;
border-bottom: 1px solid #e8e8e8;
color: #333;
}
.property-section {
padding: 16px;
border-bottom: 1px solid #e8e8e8;
}
.property-section-title {
font-size: 12px;
color: #999;
margin-bottom: 12px;
text-transform: uppercase;
}
.property-row {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.property-row:last-child {
margin-bottom: 0;
}
.property-row label {
width: 60px;
font-size: 13px;
color: #666;
}
.property-row input {
flex: 1;
padding: 6px 10px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 13px;
}
.property-row input:focus {
outline: none;
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
.property-row input[type="checkbox"] {
flex: none;
width: 16px;
height: 16px;
}
/* 弹窗 */
.modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.modal-content {
width: 80%;
max-width: 800px;
max-height: 80vh;
background: #fff;
border-radius: 8px;
display: flex;
flex-direction: column;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
border-bottom: 1px solid #e8e8e8;
font-size: 16px;
font-weight: 600;
}
.modal-close {
background: none;
border: none;
font-size: 24px;
cursor: pointer;
color: #999;
}
.modal-close:hover {
color: #333;
}
.modal-body {
flex: 1;
padding: 20px;
overflow: auto;
}
.modal-body pre {
background: #f5f5f5;
padding: 16px;
border-radius: 4px;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
font-size: 13px;
line-height: 1.5;
white-space: pre-wrap;
word-wrap: break-word;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
padding: 16px 20px;
border-top: 1px solid #e8e8e8;
}
/* 示例组件样式 */
.iot-gauge {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 8px;
color: #fff;
height: 100%;
}
.iot-gauge .value {
font-size: 32px;
font-weight: bold;
}
.iot-gauge .label {
font-size: 14px;
opacity: 0.8;
}
.iot-switch {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #fff;
border: 1px solid #e8e8e8;
border-radius: 8px;
height: 100%;
}
.iot-switch .switch {
width: 60px;
height: 30px;
background: #ccc;
border-radius: 15px;
position: relative;
cursor: pointer;
}
.iot-switch .switch.active {
background: #52c41a;
}
.iot-switch .switch::after {
content: '';
position: absolute;
width: 26px;
height: 26px;
background: #fff;
border-radius: 50%;
top: 2px;
left: 2px;
transition: left 0.3s;
}
.iot-switch .switch.active::after {
left: 32px;
}
.iot-slider {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #fff;
border: 1px solid #e8e8e8;
border-radius: 8px;
padding: 20px;
height: 100%;
}
.iot-slider input[type="range"] {
width: 100%;
}
.iot-button {
display: flex;
align-items: center;
justify-content: center;
background: #1890ff;
border-radius: 8px;
color: #fff;
font-size: 16px;
font-weight: 500;
height: 100%;
cursor: pointer;
transition: background 0.3s;
}
.iot-button:hover {
background: #40a9ff;
}
.iot-value-display {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #fff;
border: 1px solid #e8e8e8;
border-radius: 8px;
height: 100%;
}
.iot-value-display .value {
font-size: 28px;
font-weight: bold;
color: #1890ff;
}
.iot-value-display .label {
font-size: 12px;
color: #999;
margin-top: 4px;
}