From 525d03b7dc900a95f60d61fc0eaf52b490b49179 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Tue, 12 Mar 2019 21:20:31 -0400 Subject: [PATCH] Support unquoted lists as default theme function values --- __tests__/themeFunction.test.js | 21 +++++++++++++++++++++ src/lib/evaluateTailwindFunctions.js | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/__tests__/themeFunction.test.js b/__tests__/themeFunction.test.js index 70e889888..6b777da87 100644 --- a/__tests__/themeFunction.test.js +++ b/__tests__/themeFunction.test.js @@ -88,3 +88,24 @@ test('quotes are preserved around default values', () => { expect(result.warnings().length).toBe(0) }) }) + +test('an unquoted list is valid as a default value', () => { + const input = ` + .heading { font-family: theme('fonts.sans', Helvetica, Arial, sans-serif); } + ` + + const output = ` + .heading { font-family: Helvetica, Arial, sans-serif; } + ` + + return run(input, { + theme: { + fonts: { + serif: 'Constantia', + }, + }, + }).then(result => { + expect(result.css).toEqual(output) + expect(result.warnings().length).toBe(0) + }) +}) diff --git a/src/lib/evaluateTailwindFunctions.js b/src/lib/evaluateTailwindFunctions.js index 7e08033b3..a1d3a4329 100644 --- a/src/lib/evaluateTailwindFunctions.js +++ b/src/lib/evaluateTailwindFunctions.js @@ -4,8 +4,8 @@ import functions from 'postcss-functions' export default function(config) { return functions({ functions: { - theme: (path, defaultValue) => { - return _.get(config.theme, _.trim(path, `'"`), defaultValue) + theme: (path, ...defaultValue) => { + return _.get(config.theme, _.trim(path, `'"`), defaultValue.join(', ')) }, }, })