diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/components/code-block/code-block.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/components/code-block/code-block.element.ts index 174c941f5a..666fb94ee2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/components/code-block/code-block.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/components/code-block/code-block.element.ts @@ -1,13 +1,5 @@ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; -import { - css, - html, - LitElement, - customElement, - property, - queryAssignedNodes, - state, -} from '@umbraco-cms/backoffice/external/lit'; +import { css, customElement, html, property, state, when, LitElement } from '@umbraco-cms/backoffice/external/lit'; //TODO consider adding a highlight prop to the code block, that could spin up/access monaco instance and highlight the code @@ -24,43 +16,49 @@ export class UmbCodeBlockElement extends LitElement { @property({ type: Boolean }) copy = false; - @queryAssignedNodes() - nodes!: NodeListOf; - @state() - copyState: 'idle' | 'success' = 'idle'; + private _copyState: 'idle' | 'success' = 'idle'; async copyCode() { const text = this.textContent; if (text) { await navigator.clipboard.writeText(text); - this.copyState = 'success'; + this._copyState = 'success'; setTimeout(() => { - this.copyState = 'idle'; + this._copyState = 'idle'; }, 2000); } } render() { return html` - ${this.language - ? html`` - : ''} -
+ ${this.#renderHeader()} +
`; // Avoid breaks between elements of

 	}
 
+	#renderHeader() {
+		if (!this.language && !this.copy) return;
+		return html`
+			
+		`;
+	}
+
 	static styles = [
 		UmbTextStyles,
 		css`
@@ -81,12 +79,6 @@ export class UmbCodeBlockElement extends LitElement {
 				background-color: var(--uui-color-surface-alt);
 				color: #303033;
 				display: block;
-				font-family:
-					Lato,
-					Helvetica Neue,
-					Helvetica,
-					Arial,
-					sans-serif;
 				margin: 0;
 				overflow-x: auto;
 				padding: 9.5px;
@@ -95,7 +87,7 @@ export class UmbCodeBlockElement extends LitElement {
 			pre,
 			code {
 				word-wrap: normal;
-				white-space: pre-line;
+				white-space: pre;
 			}
 
 			#header {
@@ -103,12 +95,12 @@ export class UmbCodeBlockElement extends LitElement {
 				justify-content: space-between;
 				align-items: center;
 				background-color: var(--uui-color-surface-alt);
+				border-bottom: 1px solid var(--uui-color-divider-emphasis);
 			}
 
 			#lang {
 				margin-left: 16px;
 				font-weight: bold;
-				text-transform: uppercase;
 			}
 
 			button {