merge: static shape styles to CSS classes + pointer-events fix (P3a) — resolve CCBaseShapeUtil conflict, update panel.css shape-title to --cc-text-inverse
This commit is contained in:
commit
9196af12f8
@ -1,7 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { BaseBoxShapeUtil, HTMLContainer, toDomPrecision } from '@tldraw/tldraw'
|
import { BaseBoxShapeUtil, HTMLContainer, toDomPrecision } from '@tldraw/tldraw'
|
||||||
import { CCBaseShape } from './cc-types'
|
import { CCBaseShape } from './cc-types'
|
||||||
import { CC_BASE_STYLE_CONSTANTS } from './cc-styles'
|
|
||||||
import { logger } from '../../../debugConfig'
|
import { logger } from '../../../debugConfig'
|
||||||
|
|
||||||
export interface ToolbarItem {
|
export interface ToolbarItem {
|
||||||
@ -40,44 +39,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: 'var(--cc-text-inverse)', 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 +76,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: 'var(--cc-text-inverse)',
|
|
||||||
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 +86,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>
|
||||||
|
|||||||
@ -268,4 +268,66 @@
|
|||||||
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;
|
||||||
|
pointer-events: all;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
background: var(--shape-header-color, var(--color-muted));
|
||||||
|
padding: 8px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cc-shape-header .shape-title {
|
||||||
|
color: var(--cc-text-inverse);
|
||||||
|
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;
|
||||||
|
pointer-events: all;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user