Skip to content

Commit a86b92e

Browse files
authored
Merge pull request #2211 from tf/counter-grouping
Allow disabling thousands separators in counter
2 parents 249789a + c857a90 commit a86b92e

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
de:
2+
pageflow_scrolled:
3+
editor:
4+
content_elements:
5+
counter:
6+
attributes:
7+
thousandsSeparators:
8+
label: "Tausendertrennzeichen anzeigen"
9+
inline_help: "Zum Beispiel 1.000, wenn Deutsch als Sprache für den Beitrag eingestellt ist."
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
en:
2+
pageflow_scrolled:
3+
editor:
4+
content_elements:
5+
counter:
6+
attributes:
7+
thousandsSeparators:
8+
label: "Display thousands separators"
9+
inline_help: "For example, 1,000 in stories with English language setting."

entry_types/scrolled/package/src/contentElements/counter/Counter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export function Counter({configuration, contentElementId, contentElementWidth, s
8888

8989
function format(value) {
9090
const localeString = value.toLocaleString(locale, {
91+
useGrouping: !configuration.hideThousandsSeparators,
9192
minimumFractionDigits: decimalPlaces,
9293
maximumFractionDigits: decimalPlaces
9394
});

entry_types/scrolled/package/src/contentElements/counter/editor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {editor} from 'pageflow-scrolled/editor';
2-
import {SelectInputView, TextInputView, NumberInputView, SeparatorView} from 'pageflow/ui';
2+
import {
3+
CheckBoxInputView, SelectInputView, TextInputView, NumberInputView, SeparatorView
4+
} from 'pageflow/ui';
35

46
import pictogram from './pictogram.svg';
57

@@ -25,6 +27,9 @@ editor.contentElementTypes.register('counter', {
2527
(0).toLocaleString(locale, {minimumFractionDigits: i})
2628
)
2729
});
30+
this.input('thousandsSeparators', CheckBoxInputView, {
31+
storeInverted: 'hideThousandsSeparators'
32+
});
2833
this.input('unit', TextInputView);
2934
this.input('unitPlacement', SelectInputView, {
3035
values: ['trailing', 'leading'],

entry_types/scrolled/package/src/contentElements/counter/stories.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ storiesOfContentElement(module, {
5252
unitPlacement: 'leading'
5353
}
5454
},
55+
{
56+
name: 'With Default Grouping',
57+
configuration: {
58+
targetValue: 2000,
59+
startValue: 1000,
60+
unit: 'kg',
61+
description: [],
62+
textSize: 'small'
63+
}
64+
},
65+
{
66+
name: 'Without Grouping',
67+
configuration: {
68+
targetValue: 2025,
69+
startValue: 2020,
70+
hideThousandsSeparators: true,
71+
unit: '',
72+
description: []
73+
}
74+
},
5575
{
5676
name: 'Pallete number color',
5777
themeOptions: {

0 commit comments

Comments
 (0)