Skip to content

Commit 2766e93

Browse files
committedAug 31, 2018
Init repository
0 parents  commit 2766e93

File tree

5 files changed

+187
-0
lines changed

5 files changed

+187
-0
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_STORE
2+
node_modules

‎index.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
}

‎package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "tailwindcss-multi-column",
3+
"version": "0.1.0",
4+
"description": "Multi-Column utilities for Tailwind CSS.",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/hacknug/tailwindcss-multi-column.git"
9+
},
10+
"keywords": [
11+
"tailwind",
12+
"tailwindcss",
13+
"tailwind css",
14+
"tailwindcss-plugin",
15+
"plugin"
16+
],
17+
"author": {
18+
"name": "Nestor Vera",
19+
"email": "nestorvera@me.com",
20+
"url": "https://nestor.rip/"
21+
},
22+
"license": "MIT",
23+
"bugs": {
24+
"url": "https://github.com/hacknug/tailwindcss-multi-column/issues"
25+
},
26+
"homepage": "https://github.com/hacknug/tailwindcss-multi-column#readme",
27+
"dependencies": {
28+
"lodash": "^4.17.10"
29+
}
30+
}

‎readme.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Tailwind CSS Multi-Column Plugin
2+
3+
This plugin adds utilities to use all multi-column properties with Tailwind CSS.
4+
5+
## Installation
6+
7+
Add this plugin to your project:
8+
9+
```bash
10+
# Install using pnpm
11+
pnpm install --save-dev tailwindcss-multi-column
12+
13+
# Install using npm
14+
npm install --save-dev tailwindcss-multi-column
15+
16+
# Install using yarn
17+
yarn add -D tailwindcss-multi-column
18+
```
19+
20+
## Usage
21+
22+
By default the plugin uses the `borderColors` and `borderWidths` properties from the config file to generate the rules classes. You can change that to whatever, just keep in mind if you have a `default` key in both objects, `.column-rule` will set both the `column-rule-color` and `column-rule-width` of the element.
23+
24+
```js
25+
require('tailwindcss-multi-column')({
26+
counts: [1, 2],
27+
widths: {
28+
'sm': '120px',
29+
'md': '240px',
30+
'lg': '360px',
31+
},
32+
rules: {
33+
colors: {
34+
'red': 'red',
35+
'lime': 'lime',
36+
'blue': 'blue',
37+
},
38+
widths: {
39+
default: '1px',
40+
'sm': '2px',
41+
'md': '3px',
42+
},
43+
},
44+
variants: [],
45+
}),
46+
```
47+
48+
```css
49+
.col-count-1 { column-count: 1; }
50+
.col-count-2 { column-count: 2; }
51+
.col-count-3 { column-count: 3; }
52+
53+
.col-w-sm { column-width: 120px; }
54+
.col-w-md { column-width: 240px; }
55+
.col-w-lg { column-width: 360px; }
56+
57+
.col-rule-red { column-rule-color: red; }
58+
.col-rule-lime { column-rule-color: lime; }
59+
.col-rule-blue { column-rule-color: blue; }
60+
61+
.col-rule { column-rule-width: 1px; }
62+
.col-rule-sm { column-rule-width: 2px; }
63+
.col-rule-md { column-rule-width: 3px; }
64+
65+
.col-rule-none { column-rule-style: none; }
66+
.col-rule-hidden { column-rule-style: hidden; }
67+
.col-rule-dotted { column-rule-style: dotted; }
68+
.col-rule-dashed { column-rule-style: dashed; }
69+
.col-rule-solid { column-rule-style: solid; }
70+
.col-rule-double { column-rule-style: double; }
71+
.col-rule-groove { column-rule-style: groove; }
72+
.col-rule-ridge { column-rule-style: ridge; }
73+
.col-rule-inset { column-rule-style: inset; }
74+
.col-rule-outset { column-rule-style: outset; }
75+
76+
.col-auto { column-fill: auto; }
77+
.col-balance { column-fill: balance; }
78+
.col-balance-all { column-fill: balance-all; }
79+
80+
.col-none { column-span: none; }
81+
.col-all { column-span: all; }
82+
```

‎shrinkwrap.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dependencies:
2+
lodash: 4.17.10
3+
packages:
4+
/lodash/4.17.10:
5+
dev: false
6+
resolution:
7+
integrity: sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==
8+
registry: 'https://registry.npmjs.org/'
9+
shrinkwrapMinorVersion: 9
10+
shrinkwrapVersion: 3
11+
specifiers:
12+
lodash: ^4.17.10

0 commit comments

Comments
 (0)
Please sign in to comment.