feat: extract static shape styles to CSS classes in CCBaseShapeUtil

This commit is contained in:
CC Worker 2026-05-31 21:46:33 +00:00
parent 3afba919c4
commit 2a6359e247
2 changed files with 72 additions and 51 deletions

View File

@ -40,44 +40,32 @@ export abstract class CCBaseShapeUtil<T extends CCBaseShape> extends BaseBoxShap
component(shape: T) { component(shape: T) {
const { const {
props: { w, h, isLocked }, props: { w, h, isLocked, headerColor },
} = shape } = shape
const toolbarItems = this.getToolbarItems(shape) const toolbarItems = this.getToolbarItems(shape)
return ( return (
<HTMLContainer <HTMLContainer
id={shape.id} id={shape.id}
className="cc-shape-container"
style={{ style={{
width: toDomPrecision(w), width: toDomPrecision(w),
height: toDomPrecision(h), height: toDomPrecision(h),
backgroundColor: shape.props.headerColor, '--shape-header-color': headerColor,
borderRadius: CC_BASE_STYLE_CONSTANTS.CONTAINER.borderRadius, } as React.CSSProperties}
boxShadow: CC_BASE_STYLE_CONSTANTS.CONTAINER.boxShadow,
overflow: 'hidden',
position: 'relative',
}}
> >
{/* Header */} {/* Header */}
<div <div
style={{ className="cc-shape-header"
backgroundColor: shape.props.headerColor, style={{ cursor: isLocked ? 'not-allowed' : 'move' }}
padding: CC_BASE_STYLE_CONSTANTS.HEADER.padding,
height: CC_BASE_STYLE_CONSTANTS.HEADER.height,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
cursor: isLocked ? 'not-allowed' : 'move',
pointerEvents: 'all',
position: 'relative',
zIndex: 1,
}}
> >
<span style={{ color: 'white', fontWeight: 'bold' }}>{shape.props.title}</span> <span className="shape-title">{shape.props.title}</span>
<div style={{ display: 'flex', gap: '4px', alignItems: 'center', pointerEvents: 'all' }}> <div className="cc-shape-toolbar">
{toolbarItems.map((item) => ( {toolbarItems.map((item) => (
<button <button
key={item.id} key={item.id}
title={item.label} title={item.label}
style={{ opacity: item.isActive ? 1 : 0.7 }}
onClick={(e) => { onClick={(e) => {
logger.info('cc-base-shape-util', 'toolbar item clicked', item.id) logger.info('cc-base-shape-util', 'toolbar item clicked', item.id)
e.preventDefault() e.preventDefault()
@ -89,25 +77,6 @@ export abstract class CCBaseShapeUtil<T extends CCBaseShape> extends BaseBoxShap
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
}} }}
style={{
background: 'transparent',
border: 'none',
padding: '4px',
cursor: 'pointer',
color: 'white',
opacity: item.isActive ? 1 : 0.7,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
pointerEvents: 'all',
fontSize: '16px',
width: '24px',
height: '24px',
zIndex: 100,
userSelect: 'none',
position: 'relative',
touchAction: 'none',
}}
> >
<div style={{ pointerEvents: 'none' }}> <div style={{ pointerEvents: 'none' }}>
{item.icon} {item.icon}
@ -118,17 +87,9 @@ export abstract class CCBaseShapeUtil<T extends CCBaseShape> extends BaseBoxShap
</div> </div>
</div> </div>
{/* Content */} {/* Content */}
<div <div
style={{ className="cc-shape-content"
position: 'absolute', style={{ backgroundColor: shape.props.backgroundColor }}
top: CC_BASE_STYLE_CONSTANTS.HEADER.height,
left: 0,
right: 0,
bottom: 0,
overflow: 'auto',
padding: CC_BASE_STYLE_CONSTANTS.CONTENT.padding,
backgroundColor: shape.props.backgroundColor,
}}
> >
{this.renderContent(shape)} {this.renderContent(shape)}
</div> </div>

View File

@ -268,4 +268,64 @@
text-align: center; text-align: center;
color: var(--color-text-2); color: var(--color-text-2);
padding: 16px; padding: 16px;
}
/* CC Base Shape Styles */
.cc-shape-container {
overflow: hidden;
position: relative;
border-radius: 4px;
box-shadow: 0 2px 4px var(--color-muted-1);
}
.cc-shape-header {
display: flex;
justify-content: space-between;
align-items: center;
cursor: not-allowed;
position: relative;
z-index: 1;
background: var(--shape-header-color, var(--color-muted));
padding: 8px;
height: 32px;
}
.cc-shape-header .shape-title {
color: white;
font-weight: bold;
}
.cc-shape-toolbar {
display: flex;
gap: 4px;
align-items: center;
}
.cc-shape-toolbar button {
background: transparent;
border: none;
padding: 4px;
cursor: pointer;
color: white;
opacity: 0.7;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
width: 24px;
height: 24px;
z-index: 100;
user-select: none;
position: relative;
touch-action: none;
}
.cc-shape-content {
position: absolute;
top: 32px;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
padding: 8px;
} }