( steps: number, base?: number | string = '1em', ratio?: ModularScaleRatio = 1.333, )
| 50 | * } |
| 51 | */ |
| 52 | export 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 | } |
no test coverage detected
searching dependent graphs…