diff --git a/src/styles/theme/index.js b/src/styles/theme/index.js index 611671e4..2e3dfc82 100644 --- a/src/styles/theme/index.js +++ b/src/styles/theme/index.js @@ -20,7 +20,7 @@ import globals from "./globals"; import media from "./media"; import motion from "./motion"; import normalize from "./normalize"; -import { generateMediaQuery, themedMode, themedModeVariant } from "./utils"; +import { generateMediaQuery, ms, themedMode, themedModeVariant } from "./utils"; import typography from "./typography"; import { MODE_BRIGHT_SNOW_FLURRY, MODE_DARK_NIGHT_FROST, THEME_KEY_MODE } from "./constants"; @@ -32,6 +32,7 @@ export { globals, media, motion, + ms, nord, normalize, palettes, diff --git a/src/styles/theme/utils/index.js b/src/styles/theme/utils/index.js index d2b28143..3cf37ba4 100644 --- a/src/styles/theme/utils/index.js +++ b/src/styles/theme/utils/index.js @@ -15,7 +15,8 @@ */ import generateMediaQuery from "./generateMediaQuery"; +import ms from "./ms"; import themedMode from "./themedMode"; import themedModeVariant from "./themedModeVariant"; -export { generateMediaQuery, themedMode, themedModeVariant }; +export { generateMediaQuery, ms, themedMode, themedModeVariant }; diff --git a/src/styles/theme/utils/ms.js b/src/styles/theme/utils/ms.js new file mode 100644 index 00000000..1cf8f709 --- /dev/null +++ b/src/styles/theme/utils/ms.js @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * Project: Nord Docs + * Repository: https://github.com/arcticicestudio/nord-docs + * License: MIT + */ + +import { modularScale } from "polished"; + +import typography from "../typography"; + +/** + * Shorthand function for polished's `modularScale` helper with pre-configured base and ratio values. + * + * @method ms + * @param {number} step The step to scale up or down. + * @return {string} The calulcated scale with the `em` unit. + * @author Arctic Ice Studio + * @author Sven Greb + * @see https://polished.js.org/docs/#modularscale + * @since 0.3.0 + */ +const ms = step => modularScale(step, typography.sizes.msBase, typography.sizes.msName); + +export default ms;