` canvas: icon tile, label, one-line
* summary, and hover actions (duplicate / remove). Purely presentational — the builder
* wires up dragging, focus, selection and keyboard handling on the host element.
* @documentation https://zinc.style/components/page-section-card
* @status experimental
* @since 1.0
*
* @dependency zn-button
* @dependency zn-icon
*
* @event page-card-duplicate - The duplicate action was clicked (internal; not in the typed event map).
* @event page-card-remove - The remove action was clicked (internal; not in the typed event map).
*
* @csspart base - The card row.
*/
export default class ZnPageSectionCard extends ZincElement {
static styles: CSSResultGroup = unsafeCSS(styles);
static dependencies = {
'zn-button': ZnButton,
'zn-icon': ZnIcon,
};
@property() label = '';
@property() summary = '';
@property() icon = '';
@property({attribute: 'icon-library'}) iconLibrary: string;
@property() color = '';
@property({type: Boolean, reflect: true}) selected = false;
/** Set when the section's type has no registered template — renders greyed. */
@property({type: Boolean, reflect: true}) unknown = false;
protected updated(changed: PropertyValues) {
super.updated(changed);
this.style.setProperty('--section-accent', this.color || 'rgb(var(--zn-color-primary))');
}
private _action(e: Event, name: 'page-card-duplicate' | 'page-card-remove') {
e.stopPropagation();
this.dispatchEvent(new CustomEvent(name, {bubbles: true, composed: true}));
}
// Keep Enter/Space on the action buttons from reaching the host, where the
// builder's card keydown handler would preventDefault and suppress the
// button's native activation.
private _actionKeydown(e: KeyboardEvent) {
if (e.key === 'Enter' || e.key === ' ') e.stopPropagation();
}
render() {
return html`
${this.label}
${this.summary ? html`${this.summary}` : ''}
this._action(e, 'page-card-duplicate')}">
this._action(e, 'page-card-remove')}">
`;
}
}