diff --git a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte index ff3f34097b..5ad842ba6c 100644 --- a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte +++ b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte @@ -229,7 +229,8 @@ css?.button?.class ?? '', isMenuItem ? 'flex items-center justify-start' : '', isMenuItem ? '!border-0' : '', - 'wm-button' + 'wm-button', + `wm-button-${resolvedConfig.color}` )} variant={isMenuItem ? 'border' : 'contained'} style={css?.button?.style} @@ -237,7 +238,8 @@ css?.container?.class ?? '', resolvedConfig.fillContainer ? 'w-full h-full' : '', isMenuItem ? 'w-full' : '', - 'wm-button-container' + 'wm-button-container', + `wm-button-container-${resolvedConfig.color}` )} wrapperStyle={css?.container?.style} disabled={resolvedConfig.disabled} diff --git a/frontend/src/lib/components/apps/components/display/AppAlert.svelte b/frontend/src/lib/components/apps/components/display/AppAlert.svelte index 20fc60ba03..24dfa9ea51 100644 --- a/frontend/src/lib/components/apps/components/display/AppAlert.svelte +++ b/frontend/src/lib/components/apps/components/display/AppAlert.svelte @@ -10,6 +10,7 @@ import InitializeComponent from '../helpers/InitializeComponent.svelte' import { Alert } from '$lib/components/common' import AlignWrapper from '../helpers/AlignWrapper.svelte' + import { appendClass } from '../../editor/componentsPanel/cssUtils' export let id: string export let configuration: RichConfigurations @@ -63,13 +64,13 @@ tooltip={resolvedConfig.tooltip} size={resolvedConfig.size} collapsible={resolvedConfig.collapsible} - bgClass={css?.background?.class} + bgClass={appendClass(css?.background?.class, 'wm-alert-card-background')} bgStyle={css?.background?.style} - iconClass={css?.icon?.class} + iconClass={appendClass(css?.icon?.class, 'wm-alert-card-icon')} iconStyle={css?.icon?.style} - titleClass={css?.title?.class} + titleClass={appendClass(css?.title?.class, 'wm-alert-card-title')} titleStyle={css?.title?.style} - descriptionClass={css?.description?.class} + descriptionClass={appendClass(css?.description?.class, 'wm-alert-card-description')} descriptionStyle={css?.description?.style} isCollapsed={resolvedConfig.initiallyCollapsed} > diff --git a/frontend/src/lib/components/apps/components/layout/AppModal.svelte b/frontend/src/lib/components/apps/components/layout/AppModal.svelte index 3000afdedf..15f3eca206 100644 --- a/frontend/src/lib/components/apps/components/layout/AppModal.svelte +++ b/frontend/src/lib/components/apps/components/layout/AppModal.svelte @@ -179,7 +179,7 @@ >
{ e?.stopPropagation() if (!$connectingInput.opened) { diff --git a/frontend/src/lib/components/apps/editor/component/components.ts b/frontend/src/lib/components/apps/editor/component/components.ts index 2ff364f44a..27d0bfc3bf 100644 --- a/frontend/src/lib/components/apps/editor/component/components.ts +++ b/frontend/src/lib/components/apps/editor/component/components.ts @@ -3410,7 +3410,8 @@ See date-fns format for more information. By default, it is 'dd.MM.yyyy HH:mm' customCss: { button: { class: '', style: '' }, buttonContainer: { class: '', style: '' }, - popup: { class: '', style: '' } + popup: { class: '', style: '' }, + container: { class: '', style: '' } }, initialData: { horizontalAlignment: 'center', diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/CssHelperPanel.svelte b/frontend/src/lib/components/apps/editor/componentsPanel/CssHelperPanel.svelte index fda2b9338a..05e6380238 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/CssHelperPanel.svelte +++ b/frontend/src/lib/components/apps/editor/componentsPanel/CssHelperPanel.svelte @@ -20,20 +20,38 @@ const dispatch = createEventDispatcher() interface CustomCSSEntry { - type: CustomCSSType + type?: CustomCSSType name: string icon: any - ids: { id: string; forceStyle: boolean; forceClass: boolean }[] + ids?: { id: string; forceStyle: boolean; forceClass: boolean }[] + description?: string + order?: number } const { app } = getContext('AppViewerContext') + const descriptions = { + buttoncomponent: + 'The button component also has additional color specific classes to allow customizing classes by color. wm-button-wrapper-blue, wm-button-container-blue, ...' + } const entries: CustomCSSEntry[] = [ + { + name: 'Dark Mode', + icon: LayoutDashboardIcon, + description: + 'When in dark mode, the entire document has the .dark class applied to it. You can apply selective styling by using the .dark class: e.g. .dark .my-element { color: white; }', + order: 3 + }, { type: 'app', name: 'App', icon: LayoutDashboardIcon, - ids: ['viewer', 'grid', 'component'].map((id) => ({ id, forceStyle: true, forceClass: true })) + ids: ['viewer', 'grid', 'component'].map((id) => ({ + id, + forceStyle: true, + forceClass: true + })), + order: 2 }, { type: 'quillcomponent', @@ -51,11 +69,12 @@ id, forceStyle: v?.style != undefined, forceClass: v?.['class'] != undefined - })) + })), + description: descriptions[type as keyof typeof descriptions] })) ] - entries.sort((a, b) => a.name.localeCompare(b.name)) + entries.sort((a, b) => (b.order ?? 0) - (a.order ?? 0) + a.name.localeCompare(b.name)) let search = '' @@ -66,15 +85,15 @@
{#each search != '' ? entries.filter((x) => x.name .toLowerCase() - .includes(search.toLowerCase())) : entries as { type, name, icon, ids } (name + type)} - {#if ids.length > 0} + .includes(search.toLowerCase())) : entries as { type, name, icon, ids, description } (name + type)} + {#if description || (ids && ids.length > 0)} { if ($app.css != undefined) { - if (e.detail && $app.css[type] == undefined) { - $app.css[type] = Object.fromEntries(ids.map(({ id }) => [id, {}])) + if (type && e.detail && $app.css[type] == undefined) { + $app.css[type] = Object.fromEntries((ids ?? []).map(({ id }) => [id, {}])) } } }} @@ -85,115 +104,120 @@ {name}
-
- {#each customisationByComponent.filter( (c) => c.components.includes(type) ) as customisation (customisation.components.join('-'))} - {#if customisation.link} - -
- See documentation - -
-
- {/if} - - - {#if customisation.selectors.length > 0} - - Selectors ({customisation.selectors.length}) - - {/if} - {#if customisation.variables.length > 0} - -
- Variables ({customisation.variables.length}) + {#if description} +
{description}
+ {/if} + {#if type} +
+ {#each customisationByComponent.filter( (c) => c.components.includes(type) ) as customisation (customisation.components.join('-'))} + {#if customisation.link} + +
+ See documentation +
- +
{/if} -
- - - - - Selector - Comment - - - - {#each customisation.selectors as { selector, comment }} - - - {selector} - - - {#if comment} -
{comment}
- {/if} -
- - - -
- {/each} -
-
- - - - - Variable - Default value - Comment - - - - {#each customisation.variables as { variable, value, comment }} - - - {variable} - - - {value} - - - {#if comment} -
{comment}
- {/if} -
- - - -
- {/each} -
-
-
- - {/each} -
+ + + {#if customisation.selectors.length > 0} + + Selectors ({customisation.selectors.length}) + + {/if} + {#if customisation.variables.length > 0} + +
+ Variables ({customisation.variables.length}) +
+
+ {/if} +
+ + + + + Selector + Comment + + + + {#each customisation.selectors as { selector, comment }} + + + {selector} + + + {#if comment} +
{comment}
+ {/if} +
+ + + +
+ {/each} +
+
+ + + + + Variable + Default value + Comment + + + + {#each customisation.variables as { variable, value, comment }} + + + {variable} + + + {value} + + + {#if comment} +
{comment}
+ {/if} +
+ + + +
+ {/each} +
+
+
+
+ {/each} +
+ {/if} {/if} {/each} diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/cssUtils.ts b/frontend/src/lib/components/apps/editor/componentsPanel/cssUtils.ts index 6fc8344295..4634959ac0 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/cssUtils.ts +++ b/frontend/src/lib/components/apps/editor/componentsPanel/cssUtils.ts @@ -185,7 +185,11 @@ export const customisationByComponent: Customisation[] = [ components: ['modalcomponent'], selectors: [ { selector: '.wm-modal', comment: 'main modal element', customCssKey: 'popup' }, - { selector: '.wm-modal-button', comment: 'button to open modal', customCssKey: 'button' }, + { + selector: '.wm-modal-container', + comment: 'container for modal', + customCssKey: 'container' + }, { selector: '.wm-modal-button-container', comment: 'container for button to open modal', @@ -826,6 +830,26 @@ export const customisationByComponent: Customisation[] = [ selector: 'wm-alert-card-container', comment: 'Alert container', customCssKey: 'container' + }, + { + selector: 'wm-alert-card-background', + comment: 'Alert background', + customCssKey: 'background' + }, + { + selector: 'wm-alert-card-icon', + comment: 'Alert icon', + customCssKey: 'icon' + }, + { + selector: 'wm-alert-card-title', + comment: 'Alert title', + customCssKey: 'title' + }, + { + selector: 'wm-alert-card-description', + comment: 'Alert description', + customCssKey: 'description' } ], variables: [] @@ -860,3 +884,9 @@ export function hasStyleValue(obj: ComponentCssProperty | undefined) { return obj.style !== '' } + +export function appendClass(className: string | undefined, customCssKey: string) { + if (!className) return customCssKey + + return `${className} ${customCssKey}` +}