Skip to content

Commit

Permalink
Allow applying palette colors to info table columns
Browse files Browse the repository at this point in the history
REDMINE-20878
  • Loading branch information
tf committed Jan 21, 2025
1 parent 35aa434 commit 1983f17
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 12 deletions.
6 changes: 5 additions & 1 deletion entry_types/scrolled/config/locales/new/info_table.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ de:
general: Info-Tabelle
attributes:
labelColumnAlign:
label: "Text-Ausrichtung (Erste Spalte) "
label: "Text-Ausrichtung (Erste Spalte)"
values:
auto: "(Automatisch)"
left: Linksbündig
Expand All @@ -22,6 +22,10 @@ de:
left: Linksbündig
center: Zentriert
right: Rechtsbündig
labelColor:
label: "Text-Farbe (Erste Spalte)"
valueColor:
label: "Text-Farbe (Zweite Spalte)"
help_texts:
shortcuts: |-
<dl class="shortcuts">
Expand Down
4 changes: 4 additions & 0 deletions entry_types/scrolled/config/locales/new/info_table.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ en:
left: Left
center: Center
right: Right
labelColor:
label: "Text color (First column)"
valueColor:
label: "Text align (Second column)"
help_texts:
shortcuts: |-
<dl class="shortcuts">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames';

import {
EditableTable,
paletteColor,
useContentElementConfigurationUpdate,
useContentElementEditorState,
useI18n
Expand All @@ -17,16 +18,19 @@ export function InfoTable({configuration, sectionProps}) {
const {t} = useI18n({locale: 'ui'});

return (
<EditableTable className={classNames(styles.table,
styles[`labelColumnAlign-${configuration.labelColumnAlign}`],
styles[`valueColumnAlign-${configuration.valueColumnAlign}`],
{[styles.selected]: isSelected,
[styles.center]: sectionProps.layout === 'centerRagged'})}
labelScaleCategory="infoTableLabel"
valueScaleCategory="infoTableValue"
labelPlaceholder={t('pageflow_scrolled.inline_editing.type_text')}
valuePlaceholder={t('pageflow_scrolled.inline_editing.type_text')}
value={configuration.value}
onChange={value => updateConfiguration({value})} />
<div style={{'--label-color': paletteColor(configuration.labelColor),
'--value-color': paletteColor(configuration.valueColor)}}>
<EditableTable className={classNames(styles.table,
styles[`labelColumnAlign-${configuration.labelColumnAlign}`],
styles[`valueColumnAlign-${configuration.valueColumnAlign}`],
{[styles.selected]: isSelected,
[styles.center]: sectionProps.layout === 'centerRagged'})}
labelScaleCategory="infoTableLabel"
valueScaleCategory="infoTableValue"
labelPlaceholder={t('pageflow_scrolled.inline_editing.type_text')}
valuePlaceholder={t('pageflow_scrolled.inline_editing.type_text')}
value={configuration.value}
onChange={value => updateConfiguration({value})} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
white-space: pre;
}

.table td:first-child div {
color: var(--label-color);
}

.table td:last-child {
width: 100%;
padding: 0.5rem 0 0.5rem 0.5rem;
}

.table td:last-child div {
color: var(--value-color);
}

.center td {
width: 50%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ editor.contentElementTypes.register('infoTable', {
this.input('valueColumnAlign', SelectInputView, {
values: ['auto', 'left', 'center', 'right']
});
this.group('PaletteColor', {
propertyName: 'labelColor',
entry
});
this.group('PaletteColor', {
propertyName: 'valueColor',
entry
});

this.view(SeparatorView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ storiesOfContentElement(module, {
]
}
},
{
name: 'Pallete colors',
themeOptions: {
properties: {
root: {
paletteColorAccent: '#04f',
paletteColorPrimary: '#0f4'
}
}
},
configuration: {
labelColor: 'accent',
valueColor: 'primary'
}
},
{
name: 'With custom column alignment',
configuration: {
Expand Down

0 comments on commit 1983f17

Please sign in to comment.