MCPcopy
hub / github.com/styled-components/polished / modularScale

Function modularScale

src/helpers/modularScale.js:52–72  ·  view source on GitHub ↗
(
  steps: number,
  base?: number | string = '1em',
  ratio?: ModularScaleRatio = 1.333,
)

Source from the content-addressed store, hash-verified

50 * }
51 */
52export default function modularScale(
53 steps: number,
54 base?: number | string = '1em',
55 ratio?: ModularScaleRatio = 1.333,
56): string {
57 if (typeof steps !== 'number') {
58 throw new PolishedError(42)
59 }
60 if (typeof ratio === 'string' && !ratioNames[ratio]) {
61 throw new PolishedError(43)
62 }
63
64 const [realBase, unit] = typeof base === 'string' ? getValueAndUnit(base) : [base, '']
65 const realRatio = typeof ratio === 'string' ? getRatio(ratio) : ratio
66
67 if (typeof realBase === 'string') {
68 throw new PolishedError(44, base)
69 }
70
71 return `${realBase * realRatio ** steps}${unit || ''}`
72}

Callers 1

Calls 2

getValueAndUnitFunction · 0.70
getRatioFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…