[READ-ONLY] Mirror of https://github.com/hacknug/tailwindcss-plugin-utils. A bunch of utilities to help you create and maintain plugins for Tailwind. www.npmjs.com/package/@hacknug/tailwindcss-plugin-utils
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix not merging config objects correctly

Nestor Vera (Jul 24, 2019, 12:30 PM +0200) 368a8348 32527a7f

+48 -8
+1 -5
src/index.js
··· 98 98 variants: [], 99 99 } 100 100 const postcssPlugins = [ 101 - tailwindcss({ 102 - ...tailwindConfig, 103 - ...sandboxConfig, 104 - ...testConfig, 105 - }), 101 + tailwindcss(_.merge({}, tailwindConfig, sandboxConfig, testConfig)), 106 102 ] 107 103 108 104 return postcss(postcssPlugins)
+46 -2
src/index.test.js
··· 97 97 }) 98 98 99 99 test('responsive variants', () => { 100 - const testConfig = { variants: {} } 100 + const testConfig = { variants: ['responsive'] } 101 101 const pluginOptions = {} 102 102 103 103 const expectedCss = ` ··· 125 125 return generatePluginCss(tailwindConfig, testConfig, pluginOptions) 126 126 .then(css => expect(css).toMatchCss(expectedCss)) 127 127 }) 128 + 129 + test('merges configs correctly', () => { 130 + const testConfig = { 131 + theme: { screens: { md: '768px' } }, 132 + variants: ['responsive'], 133 + } 134 + const pluginOptions = {} 135 + 136 + const expectedCss = ` 137 + .col-count-2 { column-count: 2 } 138 + .col-count-4 { column-count: 4 } 139 + 140 + .col-gap-4 { column-gap: 1rem } 141 + .col-gap-8 { column-gap: 2rem } 142 + 143 + .col-span-none { column-span: none } 144 + .col-span-all { column-span: all } 145 + 146 + @media (min-width: 640px) { 147 + .sm\\:col-count-2 { column-count: 2 } 148 + .sm\\:col-count-4 { column-count: 4 } 149 + 150 + .sm\\:col-gap-4 { column-gap: 1rem } 151 + .sm\\:col-gap-8 { column-gap: 2rem } 152 + 153 + .sm\\:col-span-none { column-span: none } 154 + .sm\\:col-span-all { column-span: all } 155 + } 156 + 157 + @media (min-width: 768px) { 158 + .md\\:col-count-2 { column-count: 2 } 159 + .md\\:col-count-4 { column-count: 4 } 160 + 161 + .md\\:col-gap-4 { column-gap: 1rem } 162 + .md\\:col-gap-8 { column-gap: 2rem } 163 + 164 + .md\\:col-span-none { column-span: none } 165 + .md\\:col-span-all { column-span: all } 166 + } 167 + ` 168 + 169 + return generatePluginCss(tailwindConfig, testConfig, pluginOptions) 170 + .then(css => expect(css).toMatchCss(expectedCss)) 171 + }) 128 172 }) 129 173 130 174 // TODO: Use tailwind.config.js to hold the plugin's default values 131 - describe('given a pluginUtilities object', () => { 175 + describe('buildPlugin()', () => { 132 176 test.todo('generates default utilities and responsive variants') 133 177 test.todo('variants can be customized') 134 178 test.todo('utilities can be customized')
+1 -1
tailwind.config.js
··· 11 11 12 12 columnSpan: ['none', 'all'], 13 13 columnCount: [2, 4], // Forces building object from array 14 - columnGap: {}, // Forces using `gap` as fallback 14 + // columnGap: {}, // Forces using `gap` as fallback 15 15 16 16 gap: { 17 17 4: '1rem',