Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRQ-11247: Added fontScale prop for large text mode scale values #1574

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
13 changes: 11 additions & 2 deletions ThemeDecorator/ThemeDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ const defaultConfig = /** @lends sandstone/ThemeDecorator.ThemeDecorator.default
*/
float: true,

/**
* Font scale value for large text mode.
*
* @type {Number}
* @default 1
* @public
*/
fontScale: 1,

/**
* Options for I18nDecorator.
*
Expand Down Expand Up @@ -168,7 +177,7 @@ const defaultConfig = /** @lends sandstone/ThemeDecorator.ThemeDecorator.default
* @public
*/
const ThemeDecorator = hoc(defaultConfig, (config, Wrapped) => {
const {accessible, ri, i18n, spotlight, float, noAutoFocus, overlay,
const {accessible, ri, i18n, spotlight, float, noAutoFocus, overlay, fontScale,
skin, disableFullscreen, rootId} = config;

// Apply classes depending on screen type (overlay / fullscreen)
Expand All @@ -181,7 +190,7 @@ const ThemeDecorator = hoc(defaultConfig, (config, Wrapped) => {

let App = Wrapped;
if (float) App = FloatingLayerDecorator({wrappedClassName: bgClassName}, App);
if (ri) App = ResolutionDecorator(ri, App);
if (ri) App = ResolutionDecorator({...ri, fontScale}, App);
juwonjeong marked this conversation as resolved.
Show resolved Hide resolved
if (i18n) {
// Apply the @enact/i18n decorator around the font decorator so the latter will update the
// font stylesheet when the locale changes
Expand Down
13 changes: 13 additions & 0 deletions samples/sampler/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ const skins = {
'Light': 'light'
};

const fontScales = {
'1': 1,
'1.2': 1.2,
'1.4': 1.4,
'1.6': 1.6,
'1.8': 1.8,
'2': 2,
'3': 3,
'4': 4,
'5': 5
};

configureActions();

if (process.env.STORYBOOK_APPLY_GA_COOKIEBANNER) {
Expand Down Expand Up @@ -89,6 +101,7 @@ export const parameters = {
export const globalTypes = {
'locale': getObjectType('locale', 'en-US', locales),
'large text': getBooleanType('large text'),
'font scale': getObjectType('font scale', 1, fontScales),
'high contrast': getBooleanType('high contrast'),
'skin': getObjectType('skin', 'neutral', skins),
'background': getObjectType('background', 'default', backgrounds),
Expand Down
1 change: 1 addition & 0 deletions samples/sampler/src/ThemeEnvironment/ThemeEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const StorybookDecorator = (story, config = {}) => {
title={componentName === config.name ? `${config.kind}`.replace(/\//g, ' ').trim() : `${componentName} ${config.name}`}
description={hasInfoText ? config.parameters.info.text : null}
locale={globals.locale}
fontScale={JSON.parse(globals['font scale'])}
textSize={JSON.parse(globals['large text']) ? 'large' : 'normal'}
highContrast={JSON.parse(globals['high contrast'])}
style={{
Expand Down
Loading