|
| 1 | +const _ = require('lodash') |
| 2 | + |
| 3 | +module.exports = function (options = {}) { |
| 4 | + return function ({ addUtilities, config, e }) { |
| 5 | + let { counts, widths, rules, variants } = _.defaults(options, { |
| 6 | + counts: [1, 2, 3], |
| 7 | + rules: { |
| 8 | + colors: config('borderColors'), |
| 9 | + widths: config('borderWidths'), |
| 10 | + }, |
| 11 | + }) |
| 12 | + |
| 13 | + const getName = (name) => name === 'default' ? '' : `-${name}` |
| 14 | + |
| 15 | + counts = _.map(counts, (count) => ({ |
| 16 | + [`.${e(`col-count-${count}`)}`]: { 'column-count': count }, |
| 17 | + [`.${e(`col-count-${count}`)}`]: { 'column-count': count }, |
| 18 | + })) |
| 19 | + |
| 20 | + widths = _.map(widths, (width, name) => ({ |
| 21 | + [`.${e(`col-w-${name}`)}`]: { 'column-width': width }, |
| 22 | + })) |
| 23 | + |
| 24 | + const ruleColors = _.map(rules.colors, (color, name) => ({ |
| 25 | + [`.${e(`col-rule${getName(name)}`)}`]: { 'column-rule-color': color }, |
| 26 | + })) |
| 27 | + |
| 28 | + const ruleWidths = _.map(rules.widths, (width, name) => ({ |
| 29 | + [`.${e(`col-rule${getName(name)}`)}`]: { 'column-rule-width': width }, |
| 30 | + })) |
| 31 | + |
| 32 | + addUtilities(counts, variants) |
| 33 | + addUtilities(widths, variants) |
| 34 | + addUtilities(ruleColors, variants) |
| 35 | + addUtilities(ruleWidths, variants) |
| 36 | + addUtilities( |
| 37 | + { |
| 38 | + // Column-Rule Style |
| 39 | + '.col-rule-none': { columnRuleStyle: 'none' }, |
| 40 | + '.col-rule-hidden': { columnRuleStyle: 'hidden' }, |
| 41 | + '.col-rule-dotted': { columnRuleStyle: 'dotted' }, |
| 42 | + '.col-rule-dashed': { columnRuleStyle: 'dashed' }, |
| 43 | + '.col-rule-solid': { columnRuleStyle: 'solid' }, |
| 44 | + '.col-rule-double': { columnRuleStyle: 'double' }, |
| 45 | + '.col-rule-groove': { columnRuleStyle: 'groove' }, |
| 46 | + '.col-rule-ridge': { columnRuleStyle: 'ridge' }, |
| 47 | + '.col-rule-inset': { columnRuleStyle: 'inset' }, |
| 48 | + '.col-rule-outset': { columnRuleStyle: 'outset' }, |
| 49 | + |
| 50 | + // Column-Fill |
| 51 | + '.col-auto': { columnFill: 'auto' }, |
| 52 | + '.col-balance': { columnFill: 'balance' }, |
| 53 | + '.col-balance-all': { columnFill: 'balance-all' }, |
| 54 | + |
| 55 | + // Column-Span |
| 56 | + '.col-none': { columnSpan: 'none' }, |
| 57 | + '.col-all': { columnSpan: 'all' }, |
| 58 | + }, variants |
| 59 | + ) |
| 60 | + } |
| 61 | +} |
0 commit comments