Skip to content

Commit f7a4e36

Browse files
authored
Merge pull request #2351 from tf/counter-size-typography
Support size-based typography for counters
2 parents 3bbc906 + d13e0f0 commit f7a4e36

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function Counter({configuration, contentElementId, contentElementWidth, s
132132
className={styles.description}
133133
onChange={description => updateConfiguration({description})}
134134
onlyParagraphs={true}
135-
scaleCategory="counterDescription"
135+
scaleCategory={descriptionScaleCategories[configuration.textSize || 'medium']}
136136
placeholder={t('pageflow_scrolled.inline_editing.type_description')} />
137137
</div>
138138
</div>
@@ -146,6 +146,13 @@ const numberScaleCategories = {
146146
large: 'counterNumber-lg'
147147
};
148148

149+
const descriptionScaleCategories = {
150+
verySmall: 'counterDescription-xs',
151+
small: 'counterDescription-sm',
152+
medium: 'counterDescription-md',
153+
large: 'counterDescription-lg'
154+
};
155+
149156
const countingDurations = {
150157
none: 0,
151158
fast: 500,

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ storiesOfContentElement(module, {
8484
configuration: {
8585
numberColor: 'accent'
8686
}
87+
},
88+
{
89+
name: 'Custom typography',
90+
configuration: {
91+
textSize: 'small'
92+
},
93+
themeOptions: {
94+
typography: {
95+
counterNumberSm: {
96+
fontSize: '40px'
97+
},
98+
counterDescriptionSm: {
99+
fontSize: '18px'
100+
}
101+
}
102+
}
87103
}
88104
]
89105
});

entry_types/scrolled/package/src/frontend/Text.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import styles from './Text.module.css';
1414
* `'headingSubtitle-lg'`, `'headingSubtitle-md'`, `'headingSubtitle-sm'`,
1515
* `'body'`, `'caption'`, `'question'`, `'questionAnswer'`,
1616
* `'quoteText-lg'`, `'quoteText-md'`, `'quoteText-sm'`, `'quoteText-xs'`, `'quoteAttribution'`,
17-
* `'counterNumber-lg'`, `'counterNumber-md'`, `'counterNumber-sm'`,
18-
* `'counterNumber-xs'`, `'counterDescription`'.
17+
* `'counterNumber-lg'`, `'counterNumber-md'`, `'counterNumber-sm'`, `'counterNumber-xs'`,
18+
* `'counterDescription-lg'`, `'counterDescription-md'`, `'counterDescription-sm'`, `'counterDescription-xs'`.
1919
* `'infoTableLabel'`, `'infoTableValue`'.
2020
* `'hotspotsTooltipTitle'`, `'hotspotsTooltipDescription`', `'hotspotsTooltipLink`',
2121
* `'teaserTitle-lg'`, `'teaserTitle-md'`, `'teaserTitle-sm'`,
@@ -60,7 +60,7 @@ Text.propTypes = {
6060
'teaserDescription-lg', 'teaserDescription-md', 'teaserDescription-sm',
6161
'teaserLink',
6262
'counterNumber-lg', 'counterNumber-md', 'counterNumber-sm', 'counterNumber-xs',
63-
'counterDescription',
63+
'counterDescription-lg', 'counterDescription-md', 'counterDescription-sm', 'counterDescription-xs',
6464
'infoTableLabel', 'infoTableValue',
6565
'body', 'caption', 'question', 'questionAnswer'
6666
]),

entry_types/scrolled/package/src/frontend/Text.module.css

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,29 +164,37 @@
164164
composes: typography-quoteAttributionXs from global;
165165
}
166166

167-
.counterNumber-lg {
167+
.counterNumber {
168168
composes: typography-counterNumber from global;
169+
}
170+
171+
.counterNumber-lg {
172+
composes: counterNumber;
173+
composes: typography-counterNumberLg from global;
169174
font-size: text-5xl;
170175
line-height: 1;
171176
font-weight: 700;
172177
}
173178

174179
.counterNumber-md {
175-
composes: typography-counterNumber from global;
180+
composes: counterNumber;
181+
composes: typography-counterNumberMd from global;
176182
font-size: text-4xl;
177183
line-height: 1;
178184
font-weight: 700;
179185
}
180186

181187
.counterNumber-sm {
182-
composes: typography-counterNumber from global;
188+
composes: counterNumber;
189+
composes: typography-counterNumberSm from global;
183190
font-size: text-3xl;
184191
line-height: 1;
185192
font-weight: 700;
186193
}
187194

188195
.counterNumber-xs {
189-
composes: typography-counterNumber from global;
196+
composes: counterNumber;
197+
composes: typography-counterNumberXs from global;
190198
font-size: text-xl;
191199
line-height: 1;
192200
font-weight: 700;
@@ -198,6 +206,26 @@
198206
line-height: 1.4;
199207
}
200208

209+
.counterDescription-lg {
210+
composes: counterDescription;
211+
composes: typography-counterDescriptionLg from global;
212+
}
213+
214+
.counterDescription-md {
215+
composes: counterDescription;
216+
composes: typography-counterDescriptionMd from global;
217+
}
218+
219+
.counterDescription-sm {
220+
composes: counterDescription;
221+
composes: typography-counterDescriptionSm from global;
222+
}
223+
224+
.counterDescription-xs {
225+
composes: counterDescription;
226+
composes: typography-counterDescriptionXs from global;
227+
}
228+
201229
.hotspotsTooltipTitle {
202230
composes: typography-hotspotTooltipTitle from global;
203231
font-size: text-xs;

0 commit comments

Comments
 (0)