Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,7 @@ export class UmbIconPickerModalElement extends UmbModalBaseElement<UmbIconPicker
<umb-body-layout headline=${this.localize.term('defaultdialogs_selectIcon')}>
<div id="container">
${this.renderSearch()}
<hr />
<uui-color-swatches
value=${ifDefined(this.value.color)}
label=${this.localize.term('defaultdialogs_colorSwitcher')}
@change=${this.#onColorChange}>
${this._colorList.map(
(color) => html`
<uui-color-swatch
label=${this.localize.term('colors_' + toCamelCase(color.alias))}
title=${this.localize.term('colors_' + toCamelCase(color.alias))}
value=${color.alias}
style="--uui-swatch-color: var(${color.varName})">
</uui-color-swatch>
`,
)}
</uui-color-swatches>
<hr />
${this.renderColors()}
<uui-scroll-container id="icons">
${this.data?.showEmptyOption && !this._isSearching
? html`
Expand Down Expand Up @@ -142,9 +126,34 @@ export class UmbIconPickerModalElement extends UmbModalBaseElement<UmbIconPicker
${umbFocus()}>
<uui-icon name="search" slot="prepend" id="search_icon"></uui-icon>
</uui-input>
<hr />
`;
}

renderColors() {
return this.data?.hideColors === true
? nothing
: html`<uui-color-swatches
value=${ifDefined(this.value.color)}
label=${this.localize.term('defaultdialogs_colorSwitcher')}
@change=${this.#onColorChange}>
${
this._colorList.map(
(color) => html`
<uui-color-swatch
label=${this.localize.term('colors_' + toCamelCase(color.alias))}
title=${this.localize.term('colors_' + toCamelCase(color.alias))}
value=${color.alias}
style="--uui-swatch-color: var(${color.varName})">
</uui-color-swatch>
`,
)
}
</uui-color-swatches>
<hr />
`;
}

renderIcons() {
return this._iconsFiltered
? repeat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface UmbIconPickerModalData {
placeholder?: string;
showEmptyOption?: boolean;
hideColors?: boolean;
}

export interface UmbIconPickerModalValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export const manifests: Array<UmbExtensionManifest> = [
description: 'Icon name to show when no icon is selected',
propertyEditorUiAlias: 'Umb.PropertyEditorUi.IconPicker',
},
{
alias: 'hideColors',
label: 'Hide colors',
description: 'Hide color swatches from modal',
propertyEditorUiAlias: 'Umb.PropertyEditorUi.Toggle',
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ export class UmbPropertyEditorUIIconPickerElement
@state()
private _placeholderIcon = '';

@state()
private _hideColors = false;

public set config(config: UmbPropertyEditorConfigCollection | undefined) {
if (!config) return;
const placeholder = config.getValueByAlias('placeholder');
this._placeholderIcon = typeof placeholder === 'string' ? placeholder : '';
this._hideColors = config.getValueByAlias('hideColors') as boolean;
}

private async _openModal() {
Expand All @@ -70,7 +74,7 @@ export class UmbPropertyEditorUIIconPickerElement
icon: this._icon,
color: this._color,
},
data: { placeholder: this._placeholderIcon, showEmptyOption: !this.mandatory },
data: { placeholder: this._placeholderIcon, showEmptyOption: !this.mandatory, hideColors: this._hideColors },
}).catch(() => undefined);

if (!data) return;
Expand Down
Loading