Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-block/block-grid-block.element.ts
Niels Lyngsø 0d61ff3411 Fix: Block Editors — use create labels and hide 'edit'-action if no properties (#2424)
use create labels and hide edit if no properties

Co-authored-by: Mads Rasmussen <madsr@hey.com>
Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
2024-10-11 08:33:26 +02:00

64 lines
1.8 KiB
TypeScript

import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { css, customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
import type { UmbBlockDataType } from '@umbraco-cms/backoffice/block';
import type { UmbBlockEditorCustomViewConfiguration } from '@umbraco-cms/backoffice/block-custom-view';
import '@umbraco-cms/backoffice/ufm';
import '../block-grid-areas-container/index.js';
import '../ref-grid-block/index.js';
/**
* @element umb-block-grid-block
*/
@customElement('umb-block-grid-block')
export class UmbBlockGridBlockElement extends UmbLitElement {
//
@property({ attribute: false })
label?: string;
@property({ type: String, reflect: false })
icon?: string;
@property({ attribute: false })
config?: UmbBlockEditorCustomViewConfiguration;
@property({ type: Boolean, reflect: true })
unpublished?: boolean;
@property({ attribute: false })
content?: UmbBlockDataType;
override render() {
return html`<umb-ref-grid-block
standalone
href=${(this.config?.showContentEdit ? this.config?.editContentPath : undefined) ?? ''}>
<umb-icon slot="icon" .name=${this.icon}></umb-icon>
<umb-ufm-render slot="name" inline .markdown=${this.label} .value=${this.content}></umb-ufm-render>
<umb-block-grid-areas-container slot="areas"></umb-block-grid-areas-container>
</umb-ref-grid-block>`;
}
static override styles = [
css`
umb-block-grid-areas-container {
margin-top: calc(var(--uui-size-2) + 1px);
}
umb-block-grid-areas-container::part(area) {
margin: var(--uui-size-2);
}
:host([unpublished]) umb-icon,
:host([unpublished]) umb-ufm-render {
opacity: 0.6;
}
`,
];
}
export default UmbBlockGridBlockElement;
declare global {
interface HTMLElementTagNameMap {
'umb-block-grid-block': UmbBlockGridBlockElement;
}
}