Skip to content

Commit 3c35244

Browse files
committed
feat: make the header apps inherit from the default header app button so we can define the style in one place
1 parent a0366a2 commit 3c35244

File tree

3 files changed

+18
-35
lines changed

3 files changed

+18
-35
lines changed

src/packages/core/components/header-app/header-app-button.element.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
22
import type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit';
3-
import { css, html, LitElement, customElement, ifDefined } from '@umbraco-cms/backoffice/external/lit';
3+
import { css, html, customElement, ifDefined } from '@umbraco-cms/backoffice/external/lit';
44
import type {
55
ManifestHeaderAppButtonKind,
66
UmbBackofficeManifestKind,
77
} from '@umbraco-cms/backoffice/extension-registry';
88
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
9+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
910

1011
const manifest: UmbBackofficeManifestKind = {
1112
type: 'kind',
@@ -21,7 +22,7 @@ const manifest: UmbBackofficeManifestKind = {
2122
umbExtensionsRegistry.register(manifest);
2223

2324
@customElement('umb-header-app-button')
24-
export class UmbHeaderAppButtonElement extends LitElement {
25+
export class UmbHeaderAppButtonElement extends UmbLitElement {
2526
public manifest?: ManifestHeaderAppButtonKind;
2627

2728
render() {
@@ -41,7 +42,11 @@ export class UmbHeaderAppButtonElement extends LitElement {
4142
css`
4243
uui-button {
4344
font-size: 18px;
44-
--uui-button-background-color: transparent;
45+
--uui-button-background-color: var(--umb-header-app-button-background-color, transparent);
46+
--uui-button-background-color-hover: var(
47+
--umb-header-app-button-background-color-hover,
48+
var(--uui-color-emphasis)
49+
);
4550
}
4651
`,
4752
];

src/packages/search/umb-search-header-app.element.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
import { UMB_SEARCH_MODAL } from './search-modal/search-modal.token.js';
2-
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
3-
import type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit';
4-
import { css, html, customElement } from '@umbraco-cms/backoffice/external/lit';
5-
import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal';
2+
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
63
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
7-
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
4+
import { UmbHeaderAppButtonElement } from '@umbraco-cms/backoffice/components';
85

96
@customElement('umb-search-header-app')
10-
export class UmbSearchHeaderAppElement extends UmbLitElement {
11-
private _modalContext?: UmbModalManagerContext;
12-
13-
constructor() {
14-
super();
15-
16-
this.consumeContext(UMB_MODAL_MANAGER_CONTEXT, (_instance) => {
17-
this._modalContext = _instance;
18-
});
19-
}
20-
21-
#onSearchClick() {
22-
this._modalContext?.open(this, UMB_SEARCH_MODAL);
7+
export class UmbSearchHeaderAppElement extends UmbHeaderAppButtonElement {
8+
async #onSearchClick() {
9+
const context = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
10+
context.open(this, UMB_SEARCH_MODAL);
2311
}
2412

2513
render() {
@@ -30,15 +18,7 @@ export class UmbSearchHeaderAppElement extends UmbLitElement {
3018
`;
3119
}
3220

33-
static styles: CSSResultGroup = [
34-
UmbTextStyles,
35-
css`
36-
uui-button {
37-
font-size: 18px;
38-
--uui-button-background-color: transparent;
39-
}
40-
`,
41-
];
21+
static styles = UmbHeaderAppButtonElement.styles;
4222
}
4323

4424
export default UmbSearchHeaderAppElement;

src/packages/user/current-user/current-user-header-app.element.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { UMB_CURRENT_USER_MODAL } from './modals/current-user/current-user-modal.token.js';
2-
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
32
import type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit';
43
import { css, html, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
54
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
6-
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
75
import { UMB_CURRENT_USER_CONTEXT, type UmbCurrentUserModel } from '@umbraco-cms/backoffice/current-user';
6+
import { UmbHeaderAppButtonElement } from '@umbraco-cms/backoffice/components';
87

98
@customElement('umb-current-user-header-app')
10-
export class UmbCurrentUserHeaderAppElement extends UmbLitElement {
9+
export class UmbCurrentUserHeaderAppElement extends UmbHeaderAppButtonElement {
1110
@state()
1211
private _currentUser?: UmbCurrentUserModel;
1312

@@ -96,11 +95,10 @@ export class UmbCurrentUserHeaderAppElement extends UmbLitElement {
9695
}
9796

9897
static styles: CSSResultGroup = [
99-
UmbTextStyles,
98+
UmbHeaderAppButtonElement.styles,
10099
css`
101100
uui-button {
102101
font-size: 14px;
103-
--uui-button-background-color: transparent;
104102
}
105103
`,
106104
];

0 commit comments

Comments
 (0)