Skip to content

Commit

Permalink
Merge pull request #508 from shoutem/feature/SEEXT-8053-Investigate-l…
Browse files Browse the repository at this point in the history
…ineHeight-ratio-implementation-change

Feature/seext 8053 investigate line height ratio implementation change
  • Loading branch information
majaklajic authored Jul 31, 2020
2 parents 97f495c + 20d24d0 commit 80919ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { setDefaultThemeStyle } from './init';
import getTheme, { defaultThemeVariables, dimensionRelativeToIphone } from './theme';
import getTheme, {
defaultThemeVariables,
dimensionRelativeToIphone,
calculateLineHeight,
} from './theme';

setDefaultThemeStyle();

// Theme
export { getTheme, defaultThemeVariables, dimensionRelativeToIphone };
export {
getTheme,
defaultThemeVariables,
dimensionRelativeToIphone,
calculateLineHeight,
};

// Components
export { ActionSheet } from './components/ActionSheet';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shoutem/ui",
"version": "2.0.17",
"version": "2.0.18",
"description": "Styleable set of components for React Native applications",
"dependencies": {
"@shoutem/animation": "~0.12.4",
Expand Down
10 changes: 10 additions & 0 deletions theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ export function dimensionRelativeToIphone(dimension, actualRefVal = window.width
return getSizeRelativeToReference(dimension, 375, actualRefVal);
}

// This function is deprecated and replaced with calculateLineHeight.
// It remains present here because of the backward compatibility.
export function formatLineHeight(fontSize) {
// adds required padding to lineHeight to support
// different alphabets (Kanji, Greek, etc.)

console.warn(
"formatLineHeight is deprecated and will be removed. Please use calculateLineHeight instead, it can simply be renamed as it takes the same argument and returns the same expected value, but more consistently across all fontSize."
);

if (fontSize < 22) {
// minimum lineHeight for different alphabets is 25
return 25;
Expand All @@ -64,6 +70,10 @@ export function formatLineHeight(fontSize) {
return (fontSize + 3);
}

export function calculateLineHeight(fontSize) {
return (fontSize * 1.5);
}

export const defaultThemeVariables = {
featuredColor: '#659CEC',
backgroundColor: '#f2f2f2',
Expand Down

0 comments on commit 80919ff

Please sign in to comment.