Skip to content

Commit

Permalink
Merge pull request #28 from ahaseeb04/master
Browse files Browse the repository at this point in the history
Allow a custom class name to be passed in
  • Loading branch information
adamwathan authored Jul 16, 2020
2 parents 385f854 + d6e2c17 commit 060bed3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ function configToCss(config) {
}

module.exports = plugin.withOptions(
({ modifiers = ['sm', 'lg', 'xl', '2xl'] } = {}) => {
({ modifiers = ['sm', 'lg', 'xl', '2xl'], className = 'prose' } = {}) => {
return function ({ addComponents, theme, variants }) {
const config = theme('typography', {})

addComponents(
[
{
'.prose': merge(...castArray(styles.default.css), configToCss(config.default || {})),
[`.${className}`]: merge(...castArray(styles.default.css), configToCss(config.default || {})),
},
...modifiers.map((modifier) => ({
[`.prose-${modifier}`]: merge(
[`.${className}-${modifier}`]: merge(
...castArray(styles[modifier].css),
configToCss(config[modifier] || {})
),
})),
...Object.keys(config)
.filter((key) => !['default', ...modifiers].includes(key))
.map((modifier) => ({
[`.prose-${modifier}`]: configToCss(config[modifier]),
[`.${className}-${modifier}`]: configToCss(config[modifier]),
})),
],
variants('typography')
Expand Down

0 comments on commit 060bed3

Please sign in to comment.