From 29d05d707b3d420702004ffee3f7d0fd4a3f1c65 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Tue, 30 Mar 2021 13:04:46 -0700 Subject: [PATCH 1/6] wip: interpolated references --- lib/common/formatHelpers.js | 42 +++++++++++++--------------- lib/utils/references/getReference.js | 11 +++++--- test.js | 24 ++++++++++++++++ variables.css | 11 ++++++++ 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 test.js create mode 100644 variables.css diff --git a/lib/common/formatHelpers.js b/lib/common/formatHelpers.js index 3f5547d40..7d0b527d2 100644 --- a/lib/common/formatHelpers.js +++ b/lib/common/formatHelpers.js @@ -11,6 +11,7 @@ * and limitations under the License. */ +const createReferenceRegex = require('../utils/references/createReferenceRegex'); /** * @@ -100,14 +101,14 @@ function fileHeader(file, commentStyle) { function sorter(a, b) { const aComesFirst = -1; const bComesFirst = 1; - + console.log({a, b}) // If token a uses a reference and token b doesn't, b might come before a // read on.. if (dictionary.usesReference(a.original.value)) { // Both a and b have references, we need to see if the reference each other if (dictionary.usesReference(b.original.value)) { - const aRef = dictionary.getReference(a.original.value); - const bRef = dictionary.getReference(b.original.value); + const aRef = dictionary.getReference(a.original.value)[0]; + const bRef = dictionary.getReference(b.original.value)[0]; // a references b, we want b to come first if (aRef.name === b.name) { return bComesFirst; @@ -191,32 +192,27 @@ function formattedVariables(format, dictionary, outputReferences = false) { allProperties = allProperties.sort(sortAllProperties(dictionary)); } + const regex = createReferenceRegex({}); + return allProperties - // Some languages are imperative, meaning a variable has to be defined - // before it is used. If `outputReferences` is true, check if the token - // has a reference, and if it does send it to the end of the array. - .sort((a) => { - if (outputReferences) { - if (dictionary.usesReference(a.original.value)) { - return 1; - } else { - return -1; - } - } else { - return 0; - } - }) .map(function(prop) { var to_ret_prop = `${indentation}${prefix}${prop.name}${separator} `; let value = prop.value; if (outputReferences && dictionary.usesReference(prop.original.value)) { - var ref = dictionary.getReference(prop.original.value).name; - if (format === 'css') { - value = `var(${prefix}${ref})` - } else { - value = `${prefix}${ref}`; - } + var refs = dictionary.getReference(prop.original.value); + + value = prop.original.value.replace(regex, function(match, variable, offset, string) { + const ref = refs + .find(token => token.path.join('.') === variable.replace('.value','')) + .name; + if (format === 'css') { + return `var(${prefix}${ref})` + } else { + return `${prefix}${ref}`; + } + // return `var(${prefix}${ref})`; + }); } to_ret_prop += (prop.attributes.category==='asset' ? '"'+value+'"' : value); diff --git a/lib/utils/references/getReference.js b/lib/utils/references/getReference.js index f069c4977..1e836c1ca 100644 --- a/lib/utils/references/getReference.js +++ b/lib/utils/references/getReference.js @@ -34,7 +34,10 @@ function getReference(value) { // `this` is the dictionary object passed to formats and actions const self = this; const regex = createReferenceRegex({}); - let ref; + // because a token's value can contain multiple references due to string interpolation + // "{size.padding.base.value} {color.border.primary.value}" + // references is an array of 0 or more references + const references = []; value.replace(regex, function(match, variable) { // remove 'value' to access the whole token object @@ -43,17 +46,17 @@ function getReference(value) { // Find what the value is referencing const pathName = getPath(variable); - ref = resolveReference(pathName, self.properties); + let ref = resolveReference(pathName, self.properties); if (!ref) { // fall back on _properties as it is unfiltered ref = resolveReference(pathName, self._properties); // and warn the user about this GroupMessages.add(GroupMessages.GROUP.FilteredOutputReferences, variable); } - + references.push(ref); }); - return ref; + return references; } module.exports = getReference; diff --git a/test.js b/test.js new file mode 100644 index 000000000..4ba79b2ac --- /dev/null +++ b/test.js @@ -0,0 +1,24 @@ +const StyleDictionary = require('./index'); + +StyleDictionary.extend({ + properties: { + color: { + red: { value: "#f00" }, + blue: { value: "#00f" }, + danger: { value: "calc({color.red.value}, {color.blue.value})" }, + test: { value: "{color.red.value}" } + } + }, + platforms: { + css: { + transformGroup: `css`, + files: [{ + destination: `variables.css`, + format: `css/variables`, + options: { + outputReferences: true + } + }] + } + } +}).buildAllPlatforms(); \ No newline at end of file diff --git a/variables.css b/variables.css new file mode 100644 index 000000000..aea6f08b1 --- /dev/null +++ b/variables.css @@ -0,0 +1,11 @@ +/** + * Do not edit directly + * Generated on Tue, 30 Mar 2021 19:49:14 GMT + */ + +:root { + --color-blue: #0000ff; + --color-red: #ff0000; + --color-test: var(--color-red); + --color-danger: calc(var(--color-red), var(--color-blue)); +} From 4f006a839b987cc7e25a62b93f98e91fdaf8b277 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Tue, 30 Mar 2021 13:05:06 -0700 Subject: [PATCH 2/6] wip still --- lib/common/formatHelpers.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/common/formatHelpers.js b/lib/common/formatHelpers.js index 7d0b527d2..46342aba5 100644 --- a/lib/common/formatHelpers.js +++ b/lib/common/formatHelpers.js @@ -107,16 +107,31 @@ function fileHeader(file, commentStyle) { if (dictionary.usesReference(a.original.value)) { // Both a and b have references, we need to see if the reference each other if (dictionary.usesReference(b.original.value)) { - const aRef = dictionary.getReference(a.original.value)[0]; - const bRef = dictionary.getReference(b.original.value)[0]; + const aRefs = dictionary.getReference(a.original.value)[0]; + const bRefs = dictionary.getReference(b.original.value)[0]; + + aRefs.forEach(aRef => { + // a references b, we want b to come first + if (aRef.name === b.name) { + return bComesFirst; + } + }); + + bRefs.forEach(bRef => { + // ditto but opposite + if (bRef.name === a.name) { + return aComesFirst; + } + }); + // a references b, we want b to come first - if (aRef.name === b.name) { - return bComesFirst; - } - // ditto but opposite - if (bRef.name === a.name) { - return aComesFirst; - } + // if (aRef.name === b.name) { + // return bComesFirst; + // } + // // ditto but opposite + // if (bRef.name === a.name) { + // return aComesFirst; + // } // both a and b have references and don't reference each other // we go further down the rabbit hole (reference chain) return sorter(aRef, bRef); @@ -202,7 +217,8 @@ function formattedVariables(format, dictionary, outputReferences = false) { if (outputReferences && dictionary.usesReference(prop.original.value)) { var refs = dictionary.getReference(prop.original.value); - value = prop.original.value.replace(regex, function(match, variable, offset, string) { + value = prop.original.value.replace(regex, function(match, variable) { + // get the specific reference in the list of references const ref = refs .find(token => token.path.join('.') === variable.replace('.value','')) .name; @@ -211,7 +227,6 @@ function formattedVariables(format, dictionary, outputReferences = false) { } else { return `${prefix}${ref}`; } - // return `var(${prefix}${ref})`; }); } From 546671bc285b1a66922e4cabe9ee1ad2dd02f186 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Wed, 31 Mar 2021 12:06:59 -0700 Subject: [PATCH 3/6] feat(formats): output references handles interpoloated references --- .../__snapshots__/android.test.js.snap | 3 + .../__snapshots__/css.test.js.snap | 331 +- .../__snapshots__/flutter.test.js.snap | 8554 +---------------- .../__snapshots__/scss.test.js.snap | 378 +- .../__snapshots__/swift.test.js.snap | 398 +- __integration__/css.test.js | 10 + __integration__/flutter.test.js | 2 +- .../formats/__snapshots__/all.test.js.snap | 17 +- .../androidResources.test.js.snap | 3 + docs/formats.md | 127 +- .../advanced/variables-in-outputs/README.md | 6 +- .../variables-in-outputs/sd.config.js | 6 +- lib/common/formatHelpers.js | 329 - .../formatHelpers/createPropertyFormatter.js | 123 + lib/common/formatHelpers/fileHeader.js | 80 + .../formatHelpers/formattedVariables.js | 56 + lib/common/formatHelpers/iconsWithPrefix.js | 48 + lib/common/formatHelpers/index.js | 26 + lib/common/formatHelpers/minifyDictionary.js | 48 + lib/common/formatHelpers/sortByName.js | 41 + lib/common/formatHelpers/sortByReference.js | 71 + lib/common/formats.js | 98 +- lib/common/templates/android/colors.template | 15 +- lib/common/templates/android/dimens.template | 15 +- .../templates/android/fontDimens.template | 15 +- .../templates/android/integers.template | 15 +- .../templates/android/resources.template | 15 +- lib/common/templates/android/strings.template | 15 +- .../templates/flutter/class.dart.template | 28 +- .../templates/ios-swift/class.swift.template | 23 +- .../templates/ios-swift/enum.swift.template | 22 +- lib/register/format.js | 2 +- lib/utils/createDictionary.js | 6 +- lib/utils/createFormatArgs.js | 4 +- .../{getReference.js => getReferences.js} | 5 +- scripts/generateDocs.js | 2 +- scripts/handlebars/templates/formats.hbs | 8 +- 37 files changed, 1651 insertions(+), 9294 deletions(-) delete mode 100644 lib/common/formatHelpers.js create mode 100644 lib/common/formatHelpers/createPropertyFormatter.js create mode 100644 lib/common/formatHelpers/fileHeader.js create mode 100644 lib/common/formatHelpers/formattedVariables.js create mode 100644 lib/common/formatHelpers/iconsWithPrefix.js create mode 100644 lib/common/formatHelpers/index.js create mode 100644 lib/common/formatHelpers/minifyDictionary.js create mode 100644 lib/common/formatHelpers/sortByName.js create mode 100644 lib/common/formatHelpers/sortByReference.js rename lib/utils/references/{getReference.js => getReferences.js} (94%) diff --git a/__integration__/__snapshots__/android.test.js.snap b/__integration__/__snapshots__/android.test.js.snap index d2eed60a1..8d8a33582 100644 --- a/__integration__/__snapshots__/android.test.js.snap +++ b/__integration__/__snapshots__/android.test.js.snap @@ -2,6 +2,7 @@ exports[`integration android android/resources should match snapshot 1`] = ` " + style comments respectively. Anything else will use \/\* style comments. - * @returns {String} - * @example - * ```js - * StyleDictionary.registerFormat({ - * name: 'myCustomFormat', - * formatter: function({ dictionary, file }) { - * return fileHeader(file, 'short') + - * dictionary.allProperties.map(token => `${token.name} = ${token.value}`); - * } - * }); - * ``` - */ -function fileHeader(file, commentStyle) { - // showFileHeader is true by default - let showFileHeader = true; - if (file.options && typeof file.options.showFileHeader !== 'undefined') { - showFileHeader = file.options.showFileHeader; - } - - // Return empty string if the showFileHeader is false - if (!showFileHeader) return ''; - - let fn = defaultFileHeader; - if (file.options && typeof file.options.fileHeader === 'function') { - fn = file.options.fileHeader; - } - - // default header - const defaultHeader = [ - `Do not edit directly`, - `Generated on ${new Date().toUTCString()}` - ]; - let commentPrefix, commentHeader, commentFooter; - if (showFileHeader) { - if (commentStyle === 'short') { - commentPrefix = '// '; - commentHeader = '\n'; - commentFooter = '\n\n'; - } else if (commentStyle === 'xml') { - commentPrefix = ' '; - commentHeader = '\n'; - } else { - commentPrefix = ' * '; - commentHeader = '/**\n'; - commentFooter = '\n */\n\n'; - } - } - - return `${commentHeader}${fn(defaultHeader) - .map(line => `${commentPrefix}${line}`) - .join('\n')}${commentFooter}`; -} - -/** - * A function that returns a sorting function to be used with Array.sort that - * will sort the allProperties array based on references. This is to make sure - * if you use output references that you never use a reference before it is - * defined. - * - * @example - * ```javascript - * dictionary.allProperties.sort(sortAllProperties(dictionary)) - * ``` - * @param {Dictionary} dictionary - * @returns function - */ - function sortAllProperties(dictionary) { - // The sorter function is recursive to account for multiple levels of nesting - function sorter(a, b) { - const aComesFirst = -1; - const bComesFirst = 1; - console.log({a, b}) - // If token a uses a reference and token b doesn't, b might come before a - // read on.. - if (dictionary.usesReference(a.original.value)) { - // Both a and b have references, we need to see if the reference each other - if (dictionary.usesReference(b.original.value)) { - const aRefs = dictionary.getReference(a.original.value)[0]; - const bRefs = dictionary.getReference(b.original.value)[0]; - - aRefs.forEach(aRef => { - // a references b, we want b to come first - if (aRef.name === b.name) { - return bComesFirst; - } - }); - - bRefs.forEach(bRef => { - // ditto but opposite - if (bRef.name === a.name) { - return aComesFirst; - } - }); - - // a references b, we want b to come first - // if (aRef.name === b.name) { - // return bComesFirst; - // } - // // ditto but opposite - // if (bRef.name === a.name) { - // return aComesFirst; - // } - // both a and b have references and don't reference each other - // we go further down the rabbit hole (reference chain) - return sorter(aRef, bRef); - // a has a reference and b does not: - } else { - return bComesFirst; - } - // a does not have a reference it should come first regardless if b has one - } else { - return aComesFirst; - } - } - - return sorter; -} - -/** - * - * This is used to create lists of variables like Sass variables or CSS custom properties - * @memberof module:formatHelpers - * @param {String} format - What type of variables to output. Options are: css, sass, less, and stylus - * @param {Object} dictionary - The dictionary object that gets passed to the formatter method. - * @param {Boolean} outputReferences - Whether or not to output references - * @returns {String} - * @example - * ```js - * StyleDictionary.registerFormat({ - * name: 'myCustomFormat', - * formatter: function({ dictionary, options }) { - * return formattedVariables('less', dictionary, options.outputReferences); - * } - * }); - * ``` - */ -function formattedVariables(format, dictionary, outputReferences = false) { - var prefix, commentStyle, indentation, separator; - - switch(format) { - case 'css': - prefix = '--'; - indentation = ' '; - separator = ':'; - break; - case 'sass': - prefix = '$'; - commentStyle = 'short'; - indentation = ''; - separator = ':'; - break; - case 'less': - prefix = '@'; - commentStyle = 'short'; - indentation = ''; - separator = ':'; - break; - case 'stylus': - prefix = '$'; - commentStyle = 'short'; - indentation = ''; - separator = '='; - break; - } - - let {allProperties} = dictionary; - - // Some languages are imperative, meaning a variable has to be defined - // before it is used. If `outputReferences` is true, check if the token - // has a reference, and if it does send it to the end of the array. - // We also need to account for nested references, a -> b -> c. They - // need to be defined in reverse order: c, b, a so that the reference always - // comes after the definition - if (outputReferences) { - allProperties = allProperties.sort(sortAllProperties(dictionary)); - } - - const regex = createReferenceRegex({}); - - return allProperties - .map(function(prop) { - var to_ret_prop = `${indentation}${prefix}${prop.name}${separator} `; - let value = prop.value; - - if (outputReferences && dictionary.usesReference(prop.original.value)) { - var refs = dictionary.getReference(prop.original.value); - - value = prop.original.value.replace(regex, function(match, variable) { - // get the specific reference in the list of references - const ref = refs - .find(token => token.path.join('.') === variable.replace('.value','')) - .name; - if (format === 'css') { - return `var(${prefix}${ref})` - } else { - return `${prefix}${ref}`; - } - }); - } - - to_ret_prop += (prop.attributes.category==='asset' ? '"'+value+'"' : value); - - if (format == 'sass' && prop.themeable === true) { - to_ret_prop += ' !default'; - } - - to_ret_prop += ';'; - - if (prop.comment) { - if (commentStyle === 'short') { - to_ret_prop = to_ret_prop.concat(' // ' + prop.comment); - } else { - to_ret_prop = to_ret_prop.concat(' /* ' + prop.comment + ' */'); - } - } - - return to_ret_prop; - }) - .filter(function(strVal) { return !!strVal }) - .join('\n'); -} - -/** - * - * This is used to create CSS (and CSS pre-processor) lists of icons. It assumes you are - * using an icon font and creates helper classes with the :before psuedo-selector to add - * a unicode character. - * __You probably don't need this.__ - * @memberof module:formatHelpers - * @param {String} prefix - Character to prefix variable names, like '$' for Sass - * @param {Property[]} properties - allProperties array on the dictionary object passed to the formatter function. - * @param {Object} options - options object passed to the formatter function. - * @returns {String} - * @example - * ```js - * StyleDictionary.registerFormat({ - * name: 'myCustomFormat', - * formatter: function({ dictionary, options }) { - * return iconsWithPrefix('$', dictionary.allProperties, options); - * } - * }); - * ``` - */ -function iconsWithPrefix(prefix, properties, options) { - return properties.filter(function(prop) { - return prop.attributes.category === 'content' && prop.attributes.type === 'icon'; - }) - .map(function(prop) { - var varName = prefix + prop.name + ': ' + prop.value + ';'; - var className = '.' + options.prefix + '-icon.' + prop.attributes.item + ':before '; - var declaration = '{ content: ' + prefix + prop.name + '; }'; - return varName + '\n' + className + declaration; - }) - .join('\n'); -} - -/** - * Outputs an object stripping out everything except values - * @memberof module:formatHelpers - * @param {Object} obj - The object to minify. You will most likely pass `dictionary.properties` to it. - * @returns {Object} - * @example - * ```js - * StyleDictionary.registerFormat({ - * name: 'myCustomFormat', - * formatter: function({ dictionary }) { - * return JSON.stringify(minifyDictionary(dictionary.properties)); - * } - * }); - * ``` - */ -function minifyDictionary(obj) { - if (typeof obj !== 'object' || Array.isArray(obj)) { - return obj; - } - - var toRet = {}; - - if (obj.hasOwnProperty('value')) { - return obj.value; - } else { - for(var name in obj) { - if(obj.hasOwnProperty(name)) { - toRet[name] = minifyDictionary(obj[name]); - } - } - } - return toRet; -} - -module.exports = { - minifyDictionary, - fileHeader, - formattedVariables, - iconsWithPrefix, - sortAllProperties -} \ No newline at end of file diff --git a/lib/common/formatHelpers/createPropertyFormatter.js b/lib/common/formatHelpers/createPropertyFormatter.js new file mode 100644 index 000000000..a5facb7bf --- /dev/null +++ b/lib/common/formatHelpers/createPropertyFormatter.js @@ -0,0 +1,123 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +const createReferenceRegex = require('../../utils/references/createReferenceRegex'); + +const defaultFormatting = { + prefix: '', + commentStyle: 'long', + indentation: '', + separator: ' =', + suffix: ';' +} + +/** + * Creates a function that can be used to format a property. This can be useful + * to use as the function on `dictionary.allProperties.map`. The formatting + * is configurable either by supplying a `format` option or a `formatting` object + * which uses: prefix, indentation, separator, suffix, and commentStyle. + * @memberof module:formatHelpers + * @example + * ```javascript + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary, options }) { + * const { outputReferences } = options; + * const formatProperty = createPropertyFormatter({ + * outputReferences, + * dictionary, + * format: 'css' + * }); + * return dictionary.allProperties.map(formatProperty).join('\n'); + * } + * }); + * ``` + * @param {Object} options + * @param {Boolean} options.outputReferences - Whether or not to output references. You will want to pass this from the `options` object sent to the formatter function. + * @param {Dictionary} options.dictionary - The dictionary object sent to the formatter function + * @param {String} options.format - Available formats are: 'css', 'sass', 'less', and 'stylus'. If you want to customize the format and can't use one of those predefined formats, use the `formatting` option + * @param {Object} options.formatting - Custom formatting properties that define parts of a declaration line in code. The configurable strings are: prefix, indentation, separator, suffix, and commentStyle. Those are used to generate a line like this: `${indentation}${prefix}${prop.name}${separator} ${prop.value}${suffix}` + * @returns {Function} + */ +function createPropertyFormatter({outputReferences, dictionary, format, formatting={}}) { + let {prefix, commentStyle, indentation, separator, suffix} = Object.assign({}, defaultFormatting, formatting); + + switch(format) { + case 'css': + prefix = '--'; + indentation = ' '; + separator = ':'; + break; + case 'sass': + prefix = '$'; + commentStyle = 'short'; + indentation = ''; + separator = ':'; + break; + case 'less': + prefix = '@'; + commentStyle = 'short'; + indentation = ''; + separator = ':'; + break; + case 'stylus': + prefix = '$'; + commentStyle = 'short'; + indentation = ''; + separator = '='; + break; + } + + const regex = createReferenceRegex({}); + + return function(prop) { + let to_ret_prop = `${indentation}${prefix}${prop.name}${separator} `; + let value = prop.value; + + if (outputReferences && dictionary.usesReference(prop.original.value)) { + const refs = dictionary.getReferences(prop.original.value); + + value = prop.original.value.replace(regex, function(match, variable) { + // get the specific reference in the list of references + const ref = refs + .find(token => token.path.join('.') === variable.replace('.value','')) + .name; + if (format === 'css') { + return `var(${prefix}${ref})` + } else { + return `${prefix}${ref}`; + } + }); + } + + to_ret_prop += prop.attributes.category === 'asset' ? `"${value}"` : value; + + if (format == 'sass' && prop.themeable === true) { + to_ret_prop += ' !default'; + } + + to_ret_prop += suffix; + + if (prop.comment) { + if (commentStyle === 'short') { + to_ret_prop = to_ret_prop.concat(` // ${prop.comment}`); + } else { + to_ret_prop = to_ret_prop.concat(` /* ${prop.comment} */`); + } + } + + return to_ret_prop; + } +} + +module.exports = createPropertyFormatter; \ No newline at end of file diff --git a/lib/common/formatHelpers/fileHeader.js b/lib/common/formatHelpers/fileHeader.js new file mode 100644 index 000000000..79fffc343 --- /dev/null +++ b/lib/common/formatHelpers/fileHeader.js @@ -0,0 +1,80 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +// no-op default +const defaultFileHeader = (arr) => arr + +/** + * + * This is for creating the comment at the top of generated files with the generated at date. + * It will use the custom file header if defined on the configuration, or use the + * default file header. + * @memberof module:formatHelpers + * @param {File} file - The file object that is passed to the formatter. + * @param {String} commentStyle - The only options are 'short' and 'xml', which will use the // or \ style comments respectively. Anything else will use \/\* style comments. + * @returns {String} + * @example + * ```js + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary, file }) { + * return fileHeader(file, 'short') + + * dictionary.allProperties.map(token => `${token.name} = ${token.value}`) + * .join('\n'); + * } + * }); + * ``` + */ +function fileHeader(file, commentStyle) { + // showFileHeader is true by default + let showFileHeader = true; + if (file.options && typeof file.options.showFileHeader !== 'undefined') { + showFileHeader = file.options.showFileHeader; + } + + // Return empty string if the showFileHeader is false + if (!showFileHeader) return ''; + + let fn = defaultFileHeader; + if (file.options && typeof file.options.fileHeader === 'function') { + fn = file.options.fileHeader; + } + + // default header + const defaultHeader = [ + `Do not edit directly`, + `Generated on ${new Date().toUTCString()}` + ]; + let commentPrefix, commentHeader, commentFooter; + if (showFileHeader) { + if (commentStyle === 'short') { + commentPrefix = '// '; + commentHeader = '\n'; + commentFooter = '\n\n'; + } else if (commentStyle === 'xml') { + commentPrefix = ' '; + commentHeader = ''; + } else { + commentPrefix = ' * '; + commentHeader = '/**\n'; + commentFooter = '\n */\n\n'; + } + } + + return `${commentHeader}${fn(defaultHeader) + .map(line => `${commentPrefix}${line}`) + .join('\n')}${commentFooter}`; +} + +module.exports = fileHeader; \ No newline at end of file diff --git a/lib/common/formatHelpers/formattedVariables.js b/lib/common/formatHelpers/formattedVariables.js new file mode 100644 index 000000000..5a1ec67e6 --- /dev/null +++ b/lib/common/formatHelpers/formattedVariables.js @@ -0,0 +1,56 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +const createPropertyFormatter = require('./createPropertyFormatter'); +const sortByReference = require('./sortByReference'); + +/** + * + * This is used to create lists of variables like Sass variables or CSS custom properties + * @memberof module:formatHelpers + * @param {String} format - What type of variables to output. Options are: css, sass, less, and stylus + * @param {Object} dictionary - The dictionary object that gets passed to the formatter method. + * @param {Boolean} outputReferences - Whether or not to output references + * @returns {String} + * @example + * ```js + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary, options }) { + * return formattedVariables('less', dictionary, options.outputReferences); + * } + * }); + * ``` + */ +function formattedVariables(format, dictionary, outputReferences = false) { + let {allProperties} = dictionary; + + // Some languages are imperative, meaning a variable has to be defined + // before it is used. If `outputReferences` is true, check if the token + // has a reference, and if it does send it to the end of the array. + // We also need to account for nested references, a -> b -> c. They + // need to be defined in reverse order: c, b, a so that the reference always + // comes after the definition + if (outputReferences) { + // note: using the spread operator here so we get a new array rather than + // mutating the original + allProperties = [...allProperties].sort(sortByReference(dictionary)); + } + + return allProperties + .map(createPropertyFormatter({ outputReferences, dictionary, format })) + .filter(function(strVal) { return !!strVal }) + .join('\n'); +} + +module.exports = formattedVariables; \ No newline at end of file diff --git a/lib/common/formatHelpers/iconsWithPrefix.js b/lib/common/formatHelpers/iconsWithPrefix.js new file mode 100644 index 000000000..bb806f4f4 --- /dev/null +++ b/lib/common/formatHelpers/iconsWithPrefix.js @@ -0,0 +1,48 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * + * This is used to create CSS (and CSS pre-processor) lists of icons. It assumes you are + * using an icon font and creates helper classes with the :before psuedo-selector to add + * a unicode character. + * __You probably don't need this.__ + * @memberof module:formatHelpers + * @param {String} prefix - Character to prefix variable names, like '$' for Sass + * @param {Property[]} properties - allProperties array on the dictionary object passed to the formatter function. + * @param {Object} options - options object passed to the formatter function. + * @returns {String} + * @example + * ```js + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary, options }) { + * return iconsWithPrefix('$', dictionary.allProperties, options); + * } + * }); + * ``` + */ + function iconsWithPrefix(prefix, properties, options) { + return properties.filter(function(prop) { + return prop.attributes.category === 'content' && prop.attributes.type === 'icon'; + }) + .map(function(prop) { + var varName = prefix + prop.name + ': ' + prop.value + ';'; + var className = '.' + options.prefix + '-icon.' + prop.attributes.item + ':before '; + var declaration = '{ content: ' + prefix + prop.name + '; }'; + return varName + '\n' + className + declaration; + }) + .join('\n'); +} + +module.exports = iconsWithPrefix; \ No newline at end of file diff --git a/lib/common/formatHelpers/index.js b/lib/common/formatHelpers/index.js new file mode 100644 index 000000000..33e48270c --- /dev/null +++ b/lib/common/formatHelpers/index.js @@ -0,0 +1,26 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * + * @module formatHelpers + */ +module.exports = { + createPropertyFormatter: require('./createPropertyFormatter'), + fileHeader: require('./fileHeader'), + formattedVariables: require('./formattedVariables'), + iconsWithPrefix: require('./iconsWithPrefix'), + sortByReference: require('./sortByReference'), + sortByName: require('./sortByName'), + minifyDictionary: require('./minifyDictionary') +} \ No newline at end of file diff --git a/lib/common/formatHelpers/minifyDictionary.js b/lib/common/formatHelpers/minifyDictionary.js new file mode 100644 index 000000000..638ec7570 --- /dev/null +++ b/lib/common/formatHelpers/minifyDictionary.js @@ -0,0 +1,48 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * Outputs an object stripping out everything except values + * @memberof module:formatHelpers + * @param {Object} obj - The object to minify. You will most likely pass `dictionary.properties` to it. + * @returns {Object} + * @example + * ```js + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary }) { + * return JSON.stringify(minifyDictionary(dictionary.properties)); + * } + * }); + * ``` + */ + function minifyDictionary(obj) { + if (typeof obj !== 'object' || Array.isArray(obj)) { + return obj; + } + + var toRet = {}; + + if (obj.hasOwnProperty('value')) { + return obj.value; + } else { + for(var name in obj) { + if(obj.hasOwnProperty(name)) { + toRet[name] = minifyDictionary(obj[name]); + } + } + } + return toRet; +} + +module.exports = minifyDictionary; \ No newline at end of file diff --git a/lib/common/formatHelpers/sortByName.js b/lib/common/formatHelpers/sortByName.js new file mode 100644 index 000000000..b8df89916 --- /dev/null +++ b/lib/common/formatHelpers/sortByName.js @@ -0,0 +1,41 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * A sorting function to be used when iterating over `dictionary.allProperties` in + * a format. + * @memberof module:formatHelpers + * @example + * ```javascript + * StyleDictionary.registerFormat({ + * name: 'myCustomFormat', + * formatter: function({ dictionary, options }) { + * return dictionary.allProperties.sort(sortByName) + * .map(token => `${token.name} = ${token.value}`) + * .join('\n'); + * } + * }); + * ``` + * @param {*} a - first element for comparison + * @param {*} b - second element for comparison + * @returns {Integer} -1 or 1 depending on which element should come first based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort + */ +function sortByName(a,b) { + if (b.name > a.name) { + return -1 + } else { + return 1 + } +} + +module.exports = sortByName; \ No newline at end of file diff --git a/lib/common/formatHelpers/sortByReference.js b/lib/common/formatHelpers/sortByReference.js new file mode 100644 index 000000000..653232b70 --- /dev/null +++ b/lib/common/formatHelpers/sortByReference.js @@ -0,0 +1,71 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * A function that returns a sorting function to be used with Array.sort that + * will sort the allProperties array based on references. This is to make sure + * if you use output references that you never use a reference before it is + * defined. + * @memberof module:formatHelpers + * @example + * ```javascript + * dictionary.allProperties.sort(sortByReference(dictionary)) + * ``` + * @param {Dictionary} dictionary + * @returns {Function} + */ + function sortByReference(dictionary) { + // The sorter function is recursive to account for multiple levels of nesting + function sorter(a, b) { + const aComesFirst = -1; + const bComesFirst = 1; + + // If token a uses a reference and token b doesn't, b might come before a + // read on.. + if (dictionary.usesReference(a.original.value)) { + // Both a and b have references, we need to see if the reference each other + if (dictionary.usesReference(b.original.value)) { + const aRefs = dictionary.getReferences(a.original.value); + const bRefs = dictionary.getReferences(b.original.value); + + aRefs.forEach(aRef => { + // a references b, we want b to come first + if (aRef.name === b.name) { + return bComesFirst; + } + }); + + bRefs.forEach(bRef => { + // ditto but opposite + if (bRef.name === a.name) { + return aComesFirst; + } + }); + + // both a and b have references and don't reference each other + // we go further down the rabbit hole (reference chain) + return sorter(aRefs[0], bRefs[0]); + // a has a reference and b does not: + } else { + return bComesFirst; + } + // a does not have a reference it should come first regardless if b has one + } else { + return aComesFirst; + } + } + + return sorter; +} + +module.exports = sortByReference; \ No newline at end of file diff --git a/lib/common/formats.js b/lib/common/formats.js index fbd825e4f..8421cdda5 100644 --- a/lib/common/formats.js +++ b/lib/common/formats.js @@ -14,7 +14,7 @@ var fs = require('fs'), _ = require('lodash'), GroupMessages = require('../utils/groupMessages'), - { fileHeader, formattedVariables, iconsWithPrefix, minifyDictionary, sortAllProperties } = require('./formatHelpers'); + { fileHeader, formattedVariables, iconsWithPrefix, minifyDictionary, sortByReference, createPropertyFormatter, sortByName } = require('./formatHelpers'); var SASS_MAP_FORMAT_DEPRECATION_WARNINGS = GroupMessages.GROUP.SassMapFormatDeprecationWarnings; @@ -390,7 +390,7 @@ module.exports = { const template = _.template( fs.readFileSync(__dirname + '/templates/android/resources.template') ); - return template({dictionary, file, options}); + return template({dictionary, file, options, fileHeader}); }, /** @@ -417,9 +417,12 @@ module.exports = { * #ffe19d9c * ``` */ - 'android/colors': _.template( - fs.readFileSync(__dirname + '/templates/android/colors.template') - ), + 'android/colors': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/android/colors.template') + ); + return template({dictionary, file, options, fileHeader}); + }, /** * Creates a dimen resource xml file with all the sizes in your style dictionary. @@ -445,9 +448,12 @@ module.exports = { * 15.00dp * ``` */ - 'android/dimens': _.template( - fs.readFileSync(__dirname + '/templates/android/dimens.template') - ), + 'android/dimens': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/android/dimens.template') + ); + return template({dictionary, file, options, fileHeader}); + }, /** * Creates a dimen resource xml file with all the font sizes in your style dictionary. @@ -473,9 +479,12 @@ module.exports = { * 15.00sp * ``` */ - 'android/fontDimens': _.template( - fs.readFileSync(__dirname + '/templates/android/fontDimens.template') - ), + 'android/fontDimens': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/android/fontDimens.template') + ); + return template({dictionary, file, options, fileHeader}); + }, /** * Creates a resource xml file with all the integers in your style dictionary. It filters your @@ -503,9 +512,12 @@ module.exports = { * 4000 * ``` */ - 'android/integers': _.template( - fs.readFileSync(__dirname + '/templates/android/integers.template') - ), + 'android/integers': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/android/integers.template') + ); + return template({dictionary, file, options, fileHeader}); + }, /** * Creates a resource xml file with all the strings in your style dictionary. Filters your @@ -532,9 +544,12 @@ module.exports = { * * ``` */ - 'android/strings': _.template( - fs.readFileSync(__dirname + '/templates/android/strings.template') - ), + 'android/strings': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/android/strings.template') + ); + return template({dictionary, file, options, fileHeader}); + }, // iOS templates /** @@ -673,7 +688,23 @@ module.exports = { const template = _.template( fs.readFileSync(__dirname + '/templates/ios-swift/class.swift.template') ); - return template({dictionary, file, options, sortAllProperties}); + let allProperties; + const { outputReferences } = options; + const formatProperty = createPropertyFormatter({ + outputReferences, + dictionary, + formatting: { + suffix: '' + } + }); + + if (outputReferences) { + allProperties = [...dictionary.allProperties].sort(sortByReference(dictionary)); + } else { + allProperties = [...dictionary.allProperties].sort(sortByName); + } + + return template({allProperties, file, options, formatProperty, fileHeader}); }, /** @@ -687,7 +718,22 @@ module.exports = { const template = _.template( fs.readFileSync(__dirname + '/templates/ios-swift/enum.swift.template') ); - return template({dictionary, file, options, sortAllProperties}); + let allProperties; + const { outputReferences } = options; + const formatProperty = createPropertyFormatter({ + outputReferences, + dictionary, + formatting: { + suffix: '' + } + }); + + if (outputReferences) { + allProperties = [...dictionary.allProperties].sort(sortByReference(dictionary)); + } else { + allProperties = [...dictionary.allProperties].sort(sortByName) + } + return template({allProperties, file, options, formatProperty, fileHeader}); }, // Css templates @@ -880,7 +926,19 @@ module.exports = { const template = _.template( fs.readFileSync(__dirname + '/templates/flutter/class.dart.template') ); - return template({dictionary, file, options}); + let allProperties; + const { outputReferences } = options; + const formatProperty = createPropertyFormatter({ + outputReferences, + dictionary + }); + + if (outputReferences) { + allProperties = [...dictionary.allProperties].sort(sortByReference(dictionary)); + } else { + allProperties = [...dictionary.allProperties].sort(sortByName) + } + return template({allProperties, file, options, formatProperty, fileHeader}); }, }; diff --git a/lib/common/templates/android/colors.template b/lib/common/templates/android/colors.template index 9b4d5cd1a..f5d81ebf8 100644 --- a/lib/common/templates/android/colors.template +++ b/lib/common/templates/android/colors.template @@ -14,22 +14,13 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'color'; }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader(file, 'xml') %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> <% }); %> diff --git a/lib/common/templates/android/dimens.template b/lib/common/templates/android/dimens.template index 792454fa2..dc3065d72 100644 --- a/lib/common/templates/android/dimens.template +++ b/lib/common/templates/android/dimens.template @@ -14,21 +14,12 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'size' && prop.attributes.type !== 'font' }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader(file, 'xml') %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> <% }); %> diff --git a/lib/common/templates/android/fontDimens.template b/lib/common/templates/android/fontDimens.template index 31c3b93e4..aa7a03bf0 100644 --- a/lib/common/templates/android/fontDimens.template +++ b/lib/common/templates/android/fontDimens.template @@ -14,21 +14,12 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'size' && prop.attributes.type === 'font'; }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader(file, 'xml') %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> <% }); %> diff --git a/lib/common/templates/android/integers.template b/lib/common/templates/android/integers.template index 6404fa979..6f1fc907a 100644 --- a/lib/common/templates/android/integers.template +++ b/lib/common/templates/android/integers.template @@ -14,21 +14,12 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'time'; }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader(file, 'xml') %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> <% }); %> diff --git a/lib/common/templates/android/resources.template b/lib/common/templates/android/resources.template index 22ffa098c..36c25f1ca 100644 --- a/lib/common/templates/android/resources.template +++ b/lib/common/templates/android/resources.template @@ -37,21 +37,12 @@ function propToType(prop) { function propToValue(prop) { if (file.options && file.options.outputReferences && dictionary.usesReference(prop.original.value)) { - return `@${propToType(prop)}/${dictionary.getReference(prop.original.value).name}`; + return `@${propToType(prop)}/${dictionary.getReferences(prop.original.value)[0].name}`; } else { return prop.value; } -} - - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (file.options && file.options.hasOwnProperty('showFileHeader')) ? file.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +} %> +<%= fileHeader(file, 'xml') %> <% dictionary.allProperties.forEach(function(prop) { %><<%= propToType(prop) %> name="<%= prop.name %>"><%= propToValue(prop) %>><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/strings.template b/lib/common/templates/android/strings.template index 51ae200e5..aedea2eb0 100644 --- a/lib/common/templates/android/strings.template +++ b/lib/common/templates/android/strings.template @@ -14,21 +14,12 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'content'; }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader(file, 'xml') %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> <% }); %> diff --git a/lib/common/templates/flutter/class.dart.template b/lib/common/templates/flutter/class.dart.template index e7f638b3e..d1b960ae1 100644 --- a/lib/common/templates/flutter/class.dart.template +++ b/lib/common/templates/flutter/class.dart.template @@ -13,34 +13,14 @@ // // <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (file.options && file.options.hasOwnProperty('showFileHeader')) ? file.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } - - function propToValue(prop) { - if (file.options && file.options.outputReferences && dictionary.usesReference(prop.original.value)) { - return dictionary.getReference(prop.original.value).name; - } else { - return prop.value; - } - } -%> -// -<% - // Filter to only those props wanted based on the filter, then sort - // them by category so we keep like props together, then by name - // so they are easier to find alphabetically. - var props = _.sortBy(dictionary.allProperties, item => item.attributes.category + item.name); -%> +<%= fileHeader(file, 'short') %> import 'dart:ui'; class <%= file.className %> { <%= file.className %>._(); - <%= _.map(props, function(prop) { return 'static const ' + prop.name + ' = ' + propToValue(prop) + ";" }).join('\n ') %> + <%= allProperties.map(function(prop) { + return 'static const ' + formatProperty(prop); + }).join('\n ') %> } \ No newline at end of file diff --git a/lib/common/templates/ios-swift/class.swift.template b/lib/common/templates/ios-swift/class.swift.template index f7afe969b..84af6acd7 100644 --- a/lib/common/templates/ios-swift/class.swift.template +++ b/lib/common/templates/ios-swift/class.swift.template @@ -16,27 +16,12 @@ // // <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (file.options && file.options.hasOwnProperty('showFileHeader')) ? file.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } - - function propToValue(prop) { - if (file.options && file.options.outputReferences && dictionary.usesReference(prop.original.value)) { - return dictionary.getReference(prop.original.value).name; - } else { - return prop.value; - } - } -%> -// - +<%= fileHeader(file, 'short') %> import UIKit public class <%= file.className %> { - <%= dictionary.allProperties.sort(sortAllProperties(dictionary)).map(function(prop) { return 'public static let ' + prop.name + ' = ' + propToValue(prop); }).join('\n ') %> + <%= allProperties.map(function(prop) { + return 'public static let ' + formatProperty(prop); + }).join('\n ') %> } diff --git a/lib/common/templates/ios-swift/enum.swift.template b/lib/common/templates/ios-swift/enum.swift.template index a399dd2f8..8692537fb 100644 --- a/lib/common/templates/ios-swift/enum.swift.template +++ b/lib/common/templates/ios-swift/enum.swift.template @@ -16,26 +16,12 @@ // // <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (file.options && file.options.hasOwnProperty('showFileHeader')) ? file.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } - - function propToValue(prop) { - if (file.options && file.options.outputReferences && dictionary.usesReference(prop.original.value)) { - return dictionary.getReference(prop.original.value).name; - } else { - return prop.value; - } - } -%> -// +<%= fileHeader(file, 'short') %> import UIKit public enum <%= file.className %> { - <%= dictionary.allProperties.sort(sortAllProperties).map(function(prop) { return 'public static let ' + prop.name + ' = ' + propToValue(prop); }).join('\n ') %> + <%= allProperties.map(function(prop) { + return 'public static let ' + formatProperty(prop); + }).join('\n ') %> } diff --git a/lib/register/format.js b/lib/register/format.js index 80e88b8b7..6148e7663 100644 --- a/lib/register/format.js +++ b/lib/register/format.js @@ -25,7 +25,7 @@ * @param {Object} args.dictionary.properties - Object structure of the tokens/properties that has been transformed and references resolved. * @param {Array} args.dictionary.allProperties - Flattened array of all the tokens/properties. This makes it easy to output a list, like a list of SCSS variables. * @param {function(value): Boolean} args.dictionary.usesReference - Use this function to see if a token's value uses a reference. This is the same function style dictionary uses internally to detect a reference. - * @param {function(value): Value} args.dictionary.getReference - Use this function to get the token/property that it references. You can use this to output a reference in your custom format. For example: `dictionary.getReference(token.original.value) // returns the referenced token object` + * @param {function(value): Value} args.dictionary.getReferences - Use this function to get the token/property that it references. You can use this to output a reference in your custom format. For example: `dictionary.getReferences(token.original.value) // returns an array of the referenced token objects` * @param {Object} args.platform - The platform configuration this format is being called in. * @param {Object} args.file - The file configuration this format is being called in. * @param {Object} args.options - Merged options object that combines platform level configuration and file level configuration. File options take precedence. diff --git a/lib/utils/createDictionary.js b/lib/utils/createDictionary.js index 7c9f027ca..5dd5f249e 100644 --- a/lib/utils/createDictionary.js +++ b/lib/utils/createDictionary.js @@ -12,7 +12,7 @@ */ const flattenProperties = require('./flattenProperties'); -const getReference = require('./references/getReference'); +const getReferences = require('./references/getReferences'); const usesReference = require('./references/usesReference'); /** @@ -20,7 +20,7 @@ const usesReference = require('./references/usesReference'); * @typedef Dictionary * @property {Object} properties * @property {Array} allProperties - * @property {Dictionary.getReference} getReference + * @property {Dictionary.getReferences} getReferences * @property {Dictionary.usesReference} usesReference */ @@ -34,7 +34,7 @@ function createDictionary({ properties }) { return { properties: properties, allProperties: flattenProperties( properties ), - getReference: getReference, + getReferences: getReferences, usesReference: usesReference } } diff --git a/lib/utils/createFormatArgs.js b/lib/utils/createFormatArgs.js index b79096f3b..319cb3570 100644 --- a/lib/utils/createFormatArgs.js +++ b/lib/utils/createFormatArgs.js @@ -14,7 +14,7 @@ const deepExtend = require('./deepExtend'); function createFormatArgs({ dictionary, platform, file = {} }) { - const {allProperties, properties, usesReference, getReference} = dictionary; + const {allProperties, properties, usesReference, getReferences} = dictionary; // This will merge platform and file-level configuration // where the file configuration takes precedence const {options} = platform; @@ -23,7 +23,7 @@ function createFormatArgs({ dictionary, platform, file = {} }) { return { dictionary, usesReference, - getReference, + getReferences, allProperties, properties, platform, diff --git a/lib/utils/references/getReference.js b/lib/utils/references/getReferences.js similarity index 94% rename from lib/utils/references/getReference.js rename to lib/utils/references/getReferences.js index 1e836c1ca..d3354c097 100644 --- a/lib/utils/references/getReference.js +++ b/lib/utils/references/getReferences.js @@ -30,7 +30,7 @@ const GroupMessages = require('../groupMessages'); * @param {string} value the value that contains a reference * @returns {any} */ -function getReference(value) { +function getReferences(value) { // `this` is the dictionary object passed to formats and actions const self = this; const regex = createReferenceRegex({}); @@ -39,6 +39,7 @@ function getReference(value) { // references is an array of 0 or more references const references = []; + // function inside .replace runs multiple times if there are multiple matches value.replace(regex, function(match, variable) { // remove 'value' to access the whole token object variable = variable.trim().replace('.value',''); @@ -59,4 +60,4 @@ function getReference(value) { return references; } -module.exports = getReference; +module.exports = getReferences; diff --git a/scripts/generateDocs.js b/scripts/generateDocs.js index c4f7ee209..c62e088df 100644 --- a/scripts/generateDocs.js +++ b/scripts/generateDocs.js @@ -86,7 +86,7 @@ console.log(ACTIONS_PATH + ' generated.'); const FORMATS_PATH = './docs/formats.md' const formats = jsdoc2md.renderSync({ - files: ['lib/common/formats.js', 'lib/register/format.js', 'lib/common/formatHelpers.js'], + files: ['lib/common/formats.js', 'lib/register/format.js', 'lib/common/formatHelpers/*.js'], template: fs.readFileSync('scripts/handlebars/templates/formats.hbs').toString(), 'no-gfm': true, separators: true, diff --git a/scripts/handlebars/templates/formats.hbs b/scripts/handlebars/templates/formats.hbs index 61582dc29..f7675396d 100644 --- a/scripts/handlebars/templates/formats.hbs +++ b/scripts/handlebars/templates/formats.hbs @@ -243,7 +243,7 @@ Note: to support legacy ways of defining custom formats, this in th ## Custom format with output references -To take advantage of outputting references in your custom formats there are 2 helper methods in the `dictionary` argument passed to your formatter function: `usesReference(value)` and `getReference(value)`. Here is an example using those: +To take advantage of outputting references in your custom formats there are 2 helper methods in the `dictionary` argument passed to your formatter function: `usesReference(value)` and `getReferences(value)`. Here is an example using those: ```javascript StyleDictionary.registerFormat({ @@ -252,14 +252,14 @@ StyleDictionary.registerFormat({ return dictionary.allProperties.map(token => { let value = JSON.stringify(token.value); // the `dictionary` object now has `usesReference()` and - // `getReference()` methods. `usesReference()` will return true if - // the value has a reference in it. `getReference()` will return + // `getReferences()` methods. `usesReference()` will return true if + // the value has a reference in it. `getReferences()` will return // the reference to the whole token so that you can access its // name or any other attributes. if (dictionary.usesReference(token.original.value)) { // Note: make sure to use `token.original.value` because // `token.value` is already resolved at this point. - const reference = dictionary.getReference(token.original.value); + const reference = dictionary.getReferences(token.original.value); value = reference.name; } return `export const ${token.name} = ${value};` From d8cb2cad3d0772932237e44c44185f8f0ea06d1b Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Fri, 2 Apr 2021 16:16:25 -0700 Subject: [PATCH 4/6] chore(formats): fixing PR comments --- docs/formats.md | 37 ++++++++----- examples/advanced/custom-file-header/build.js | 2 +- .../advanced/variables-in-outputs/README.md | 2 +- .../variables-in-outputs/sd.config.js | 2 +- lib/common/formatHelpers/fileHeader.js | 54 +++++++++++-------- .../formatHelpers/formattedVariables.js | 20 ++++--- lib/common/formats.js | 34 ++++++------ lib/common/templates/android/colors.template | 2 +- lib/common/templates/android/dimens.template | 2 +- .../templates/android/fontDimens.template | 2 +- .../templates/android/integers.template | 2 +- .../templates/android/resources.template | 2 +- lib/common/templates/android/strings.template | 2 +- .../templates/flutter/class.dart.template | 2 +- .../templates/ios-swift/class.swift.template | 2 +- .../templates/ios-swift/enum.swift.template | 2 +- lib/register/format.js | 2 +- scripts/handlebars/templates/formats.hbs | 7 +-- test.js | 24 --------- variables.css | 11 ---- 20 files changed, 106 insertions(+), 107 deletions(-) delete mode 100644 test.js delete mode 100644 variables.css diff --git a/docs/formats.md b/docs/formats.md index 5140a4d4c..1c7df44fd 100644 --- a/docs/formats.md +++ b/docs/formats.md @@ -240,7 +240,7 @@ The formatter function that is called when Style Dictionary builds files. args.dictionary.usesReferencefunction

Use this function to see if a token's value uses a reference. This is the same function style dictionary uses internally to detect a reference.

- args.dictionary.getReferencesfunction

Use this function to get the token/property that it references. You can use this to output a reference in your custom format. For example: dictionary.getReferences(token.original.value) // returns an array of the referenced token objects

+ args.dictionary.getReferencesfunction

Use this function to get the tokens/properties that it references. You can use this to output a reference in your custom format. For example: dictionary.getReferences(token.original.value) // returns an array of the referenced token objects

args.platformObject

The platform configuration this format is being called in.

@@ -309,7 +309,7 @@ StyleDictionary.registerFormat({ // the `dictionary` object now has `usesReference()` and // `getReferences()` methods. `usesReference()` will return true if // the value has a reference in it. `getReferences()` will return - // the reference to the whole token so that you can access its + // an array of references to the whole tokens so that you can access its // name or any other attributes. if (dictionary.usesReference(token.original.value)) { // Note: make sure to use `token.original.value` because @@ -335,9 +335,10 @@ const { fileHeader, formattedVariables } = StyleDictionary.formatHelpers; StyleDictionary.registerFormat({ name: 'myCustomFormat', formatter: function({dictionary, file, options}) { - return fileHeader(file) + + const { outputReferences } = options; + return fileHeader({file}) + ':root {\n' + - formattedVariables('css', dictionary, options.outputReferences) + + formattedVariables({format: 'css', dictionary, outputReferences}) + '\n}\n'; } }); @@ -396,7 +397,7 @@ StyleDictionary.registerFormat({ * * * ### fileHeader -> formatHelpers.fileHeader(file, commentStyle) ⇒ String +> formatHelpers.fileHeader(options) ⇒ String This is for creating the comment at the top of generated files with the generated at date. It will use the custom file header if defined on the configuration, or use the @@ -410,10 +411,15 @@ default file header. - fileFile

The file object that is passed to the formatter.

+ optionsObject + + options.fileFile

The file object that is passed to the formatter.

- commentStyleString

The only options are 'short' and 'xml', which will use the // or <!-- --> style comments respectively. Anything else will use /* style comments.

+ options.commentStyleString

The only options are 'short' and 'xml', which will use the // or <!-- --> style comments respectively. Anything else will use /* style comments.

+ + + options.formattingObject

Custom formatting properties that define parts of a comment in code. The configurable strings are: prefix, lineSeparator, header, and footer.

@@ -423,7 +429,7 @@ default file header. StyleDictionary.registerFormat({ name: 'myCustomFormat', formatter: function({ dictionary, file }) { - return fileHeader(file, 'short') + + return fileHeader({file, 'short') + dictionary.allProperties.map(token => `${token.name} = ${token.value}`) .join('\n'); } @@ -433,25 +439,30 @@ StyleDictionary.registerFormat({ * * * ### formattedVariables -> formatHelpers.formattedVariables(format, dictionary, outputReferences) ⇒ String +> formatHelpers.formattedVariables(options) ⇒ String This is used to create lists of variables like Sass variables or CSS custom properties - + - + + + + - -
ParamTypeDefaultDescriptionParamTypeDescription
formatString

What type of variables to output. Options are: css, sass, less, and stylus

+
optionsObject
options.formatString

What type of variables to output. Options are: css, sass, less, and stylus

+
options.dictionaryObject

The dictionary object that gets passed to the formatter method.

dictionaryObject

The dictionary object that gets passed to the formatter method.

+
options.outputReferencesBoolean

Whether or not to output references

outputReferencesBooleanfalse

Whether or not to output references

+
options.formattingObject

Custom formatting properties that define parts of a declaration line in code. This will get passed to formatHelpers.createPropertyFormatter and used for the lineSeparator between lines of code.

diff --git a/examples/advanced/custom-file-header/build.js b/examples/advanced/custom-file-header/build.js index 4715843f5..8eec99556 100644 --- a/examples/advanced/custom-file-header/build.js +++ b/examples/advanced/custom-file-header/build.js @@ -8,7 +8,7 @@ const version = require('./package.json').version; const {fileHeader} = StyleDictionary.formatHelpers; const myCustomFormat = ({ dictionary, file }) => { - return `${fileHeader(file, 'short')}${dictionary.allProperties.map(token => { + return `${fileHeader({file, commentStyle: 'short'})}${dictionary.allProperties.map(token => { return `--${token.name}: ${token.value};` }).join(`\n`)}` } diff --git a/examples/advanced/variables-in-outputs/README.md b/examples/advanced/variables-in-outputs/README.md index c0fb59f0a..ac2eee9e7 100644 --- a/examples/advanced/variables-in-outputs/README.md +++ b/examples/advanced/variables-in-outputs/README.md @@ -30,7 +30,7 @@ function(dictionary) { // the `dictionary` object now has `usesReference()` and // `getReferences()` methods. `usesReference()` will return true if // the value has a reference in it. `getReferences()` will return - // the reference to the whole token so that you can access its + // an array of references to the whole tokens so that you can access its // name or any other attributes. if (dictionary.usesReference(token.original.value)) { const reference = dictionary.getReferences(token.original.value); diff --git a/examples/advanced/variables-in-outputs/sd.config.js b/examples/advanced/variables-in-outputs/sd.config.js index afdd5dd89..b98080bb0 100644 --- a/examples/advanced/variables-in-outputs/sd.config.js +++ b/examples/advanced/variables-in-outputs/sd.config.js @@ -9,7 +9,7 @@ module.exports = { // the `dictionary` object now has `usesReference()` and // `getReferences()` methods. `usesReference()` will return true if // the value has a reference in it. `getReferences()` will return - // the reference to the whole token so that you can access its + // an array of references to the whole tokens so that you can access its // name or any other attributes. if (dictionary.usesReference(token.original.value)) { const reference = dictionary.getReferences(token.original.value); diff --git a/lib/common/formatHelpers/fileHeader.js b/lib/common/formatHelpers/fileHeader.js index 79fffc343..a4105592c 100644 --- a/lib/common/formatHelpers/fileHeader.js +++ b/lib/common/formatHelpers/fileHeader.js @@ -14,28 +14,37 @@ // no-op default const defaultFileHeader = (arr) => arr +const defaultFormatting = { + lineSeparator: '\n', + prefix: '', + header: '', + footer: '' +} + /** * * This is for creating the comment at the top of generated files with the generated at date. * It will use the custom file header if defined on the configuration, or use the * default file header. * @memberof module:formatHelpers - * @param {File} file - The file object that is passed to the formatter. - * @param {String} commentStyle - The only options are 'short' and 'xml', which will use the // or \ style comments respectively. Anything else will use \/\* style comments. + * @param {Object} options + * @param {File} options.file - The file object that is passed to the formatter. + * @param {String} options.commentStyle - The only options are 'short' and 'xml', which will use the // or \ style comments respectively. Anything else will use \/\* style comments. + * @param {Object} options.formatting - Custom formatting properties that define parts of a comment in code. The configurable strings are: prefix, lineSeparator, header, and footer. * @returns {String} * @example * ```js * StyleDictionary.registerFormat({ * name: 'myCustomFormat', * formatter: function({ dictionary, file }) { - * return fileHeader(file, 'short') + + * return fileHeader({file, 'short') + * dictionary.allProperties.map(token => `${token.name} = ${token.value}`) * .join('\n'); * } * }); * ``` */ -function fileHeader(file, commentStyle) { +function fileHeader({file, commentStyle, formatting={}}) { // showFileHeader is true by default let showFileHeader = true; if (file.options && typeof file.options.showFileHeader !== 'undefined') { @@ -55,26 +64,27 @@ function fileHeader(file, commentStyle) { `Do not edit directly`, `Generated on ${new Date().toUTCString()}` ]; - let commentPrefix, commentHeader, commentFooter; - if (showFileHeader) { - if (commentStyle === 'short') { - commentPrefix = '// '; - commentHeader = '\n'; - commentFooter = '\n\n'; - } else if (commentStyle === 'xml') { - commentPrefix = ' '; - commentHeader = ''; - } else { - commentPrefix = ' * '; - commentHeader = '/**\n'; - commentFooter = '\n */\n\n'; - } + + + let {prefix, lineSeparator, header, footer} = Object.assign({}, defaultFormatting, formatting); + + if (commentStyle === 'short') { + prefix = `// `; + header = `${lineSeparator}`; + footer = `${lineSeparator}${lineSeparator}`; + } else if (commentStyle === 'xml') { + prefix = ` `; + header = ``; + } else { + prefix = ` * `; + header = `/**${lineSeparator}`; + footer = `${lineSeparator} */${lineSeparator}${lineSeparator}`; } - return `${commentHeader}${fn(defaultHeader) - .map(line => `${commentPrefix}${line}`) - .join('\n')}${commentFooter}`; + return `${header}${fn(defaultHeader) + .map(line => `${prefix}${line}`) + .join(lineSeparator)}${footer}`; } module.exports = fileHeader; \ No newline at end of file diff --git a/lib/common/formatHelpers/formattedVariables.js b/lib/common/formatHelpers/formattedVariables.js index 5a1ec67e6..9a6326553 100644 --- a/lib/common/formatHelpers/formattedVariables.js +++ b/lib/common/formatHelpers/formattedVariables.js @@ -14,13 +14,19 @@ const createPropertyFormatter = require('./createPropertyFormatter'); const sortByReference = require('./sortByReference'); +const defaultFormatting = { + lineSeparator: '\n', +} + /** * * This is used to create lists of variables like Sass variables or CSS custom properties * @memberof module:formatHelpers - * @param {String} format - What type of variables to output. Options are: css, sass, less, and stylus - * @param {Object} dictionary - The dictionary object that gets passed to the formatter method. - * @param {Boolean} outputReferences - Whether or not to output references + * @param {Object} options + * @param {String} options.format - What type of variables to output. Options are: css, sass, less, and stylus + * @param {Object} options.dictionary - The dictionary object that gets passed to the formatter method. + * @param {Boolean} options.outputReferences - Whether or not to output references + * @param {Object} options.formatting - Custom formatting properties that define parts of a declaration line in code. This will get passed to `formatHelpers.createPropertyFormatter` and used for the `lineSeparator` between lines of code. * @returns {String} * @example * ```js @@ -32,9 +38,11 @@ const sortByReference = require('./sortByReference'); * }); * ``` */ -function formattedVariables(format, dictionary, outputReferences = false) { +function formattedVariables({format, dictionary, outputReferences=false, formatting={}}) { let {allProperties} = dictionary; + let {lineSeparator} = Object.assign({}, defaultFormatting, formatting); + // Some languages are imperative, meaning a variable has to be defined // before it is used. If `outputReferences` is true, check if the token // has a reference, and if it does send it to the end of the array. @@ -48,9 +56,9 @@ function formattedVariables(format, dictionary, outputReferences = false) { } return allProperties - .map(createPropertyFormatter({ outputReferences, dictionary, format })) + .map(createPropertyFormatter({ outputReferences, dictionary, format, formatting })) .filter(function(strVal) { return !!strVal }) - .join('\n'); + .join(lineSeparator); } module.exports = formattedVariables; \ No newline at end of file diff --git a/lib/common/formats.js b/lib/common/formats.js index 8421cdda5..bedd9063d 100644 --- a/lib/common/formats.js +++ b/lib/common/formats.js @@ -41,9 +41,10 @@ module.exports = { */ 'css/variables': function({dictionary, options={}, file}) { const selector = options.selector ? options.selector : `:root`; - return fileHeader(file) + + const { outputReferences } = options; + return fileHeader({file}) + `${selector} {\n` + - formattedVariables('css', dictionary, options.outputReferences) + + formattedVariables({format: 'css', dictionary, outputReferences}) + `\n}\n`; }, @@ -130,8 +131,9 @@ module.exports = { * ``` */ 'scss/variables': function({dictionary, options, file}) { - return fileHeader(file, 'short') + - formattedVariables('sass', dictionary, options.outputReferences); + const { outputReferences } = options; + return fileHeader({file, commentStyle: 'short'}) + + formattedVariables({format: 'sass', dictionary, outputReferences}); }, /** @@ -146,7 +148,7 @@ module.exports = { * ``` */ 'scss/icons': function({dictionary, options, file}) { - return fileHeader(file, 'short') + iconsWithPrefix('$', dictionary.allProperties, options); + return fileHeader({file, commentStyle: 'short'}) + iconsWithPrefix('$', dictionary.allProperties, options); }, /** @@ -164,8 +166,9 @@ module.exports = { * ``` */ 'less/variables': function({dictionary, options, file}) { - return fileHeader(file, 'short') + - formattedVariables('less', dictionary, options.outputReferences); + const { outputReferences } = options; + return fileHeader({file, commentStyle: 'short'}) + + formattedVariables({format: 'less', dictionary, outputReferences}); }, /** @@ -180,7 +183,7 @@ module.exports = { * ``` */ 'less/icons': function({dictionary, options, file}) { - return fileHeader(file, 'short') + iconsWithPrefix('@', dictionary.allProperties, options); + return fileHeader({file, commentStyle: 'short'}) + iconsWithPrefix('@', dictionary.allProperties, options); }, /** @@ -195,8 +198,9 @@ module.exports = { * ``` */ 'stylus/variables': function({dictionary, options, file}) { - return fileHeader(file, 'short') + - formattedVariables('stylus', dictionary, options.outputReferences); + const { outputReferences } = options; + return fileHeader({file, commentStyle: 'short'}) + + formattedVariables({format: 'stylus', dictionary, outputReferences}); }, /** @@ -218,7 +222,7 @@ module.exports = { * ``` */ 'javascript/module': function({dictionary, file}) { - return fileHeader(file) + + return fileHeader({file}) + 'module.exports = ' + JSON.stringify(dictionary.properties, null, 2) + ';'; }, @@ -236,7 +240,7 @@ module.exports = { *``` */ 'javascript/module-flat': function({dictionary, file}) { - return fileHeader(file) + + return fileHeader({file}) + 'module.exports = ' + module.exports['json/flat']({dictionary}) + ';'; }, @@ -261,7 +265,7 @@ module.exports = { * ``` */ 'javascript/object': function({dictionary, file}) { - return fileHeader(file) + + return fileHeader({file}) + 'var ' + (file.name || '_styleDictionary') + ' = ' + @@ -301,7 +305,7 @@ module.exports = { */ 'javascript/umd': function({dictionary, file}) { var name = file.name || '_styleDictionary' - return fileHeader(file) + + return fileHeader({file}) + '(function(root, factory) {\n' + ' if (typeof module === "object" && module.exports) {\n' + ' module.exports = factory();\n' + @@ -350,7 +354,7 @@ module.exports = { * ``` */ 'javascript/es6': function({dictionary, file}) { - return fileHeader(file) + + return fileHeader({file}) + dictionary.allProperties.map(function(prop) { var to_ret_prop = 'export const ' + prop.name + ' = ' + JSON.stringify(prop.value) + ';'; if (prop.comment) diff --git a/lib/common/templates/android/colors.template b/lib/common/templates/android/colors.template index f5d81ebf8..5fa2fed1e 100644 --- a/lib/common/templates/android/colors.template +++ b/lib/common/templates/android/colors.template @@ -18,7 +18,7 @@ var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'color'; }); %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/dimens.template b/lib/common/templates/android/dimens.template index dc3065d72..2e3e2b6a2 100644 --- a/lib/common/templates/android/dimens.template +++ b/lib/common/templates/android/dimens.template @@ -17,7 +17,7 @@ var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'size' && prop.attributes.type !== 'font' }); %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/fontDimens.template b/lib/common/templates/android/fontDimens.template index aa7a03bf0..f2e9ff936 100644 --- a/lib/common/templates/android/fontDimens.template +++ b/lib/common/templates/android/fontDimens.template @@ -17,7 +17,7 @@ var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'size' && prop.attributes.type === 'font'; }); %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/integers.template b/lib/common/templates/android/integers.template index 6f1fc907a..b424fbb5b 100644 --- a/lib/common/templates/android/integers.template +++ b/lib/common/templates/android/integers.template @@ -17,7 +17,7 @@ var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'time'; }); %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/resources.template b/lib/common/templates/android/resources.template index 36c25f1ca..6ea6cb9af 100644 --- a/lib/common/templates/android/resources.template +++ b/lib/common/templates/android/resources.template @@ -42,7 +42,7 @@ function propToValue(prop) { return prop.value; } } %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% dictionary.allProperties.forEach(function(prop) { %><<%= propToType(prop) %> name="<%= prop.name %>"><%= propToValue(prop) %>><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/android/strings.template b/lib/common/templates/android/strings.template index aedea2eb0..142ea7aba 100644 --- a/lib/common/templates/android/strings.template +++ b/lib/common/templates/android/strings.template @@ -17,7 +17,7 @@ var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category === 'content'; }); %> -<%= fileHeader(file, 'xml') %> +<%= fileHeader({file, commentStyle: 'xml'}) %> <% props.forEach(function(prop) { %><%= prop.value %><% if (prop.comment) { %><% } %> diff --git a/lib/common/templates/flutter/class.dart.template b/lib/common/templates/flutter/class.dart.template index d1b960ae1..d33711b0f 100644 --- a/lib/common/templates/flutter/class.dart.template +++ b/lib/common/templates/flutter/class.dart.template @@ -13,7 +13,7 @@ // // <%= file.destination %> // -<%= fileHeader(file, 'short') %> +<%= fileHeader({file, commentStyle: 'short'}) %> import 'dart:ui'; diff --git a/lib/common/templates/ios-swift/class.swift.template b/lib/common/templates/ios-swift/class.swift.template index 84af6acd7..fbf9680dc 100644 --- a/lib/common/templates/ios-swift/class.swift.template +++ b/lib/common/templates/ios-swift/class.swift.template @@ -16,7 +16,7 @@ // // <%= file.destination %> // -<%= fileHeader(file, 'short') %> +<%= fileHeader({file, commentStyle: 'short'}) %> import UIKit diff --git a/lib/common/templates/ios-swift/enum.swift.template b/lib/common/templates/ios-swift/enum.swift.template index 8692537fb..f5b67a4a4 100644 --- a/lib/common/templates/ios-swift/enum.swift.template +++ b/lib/common/templates/ios-swift/enum.swift.template @@ -16,7 +16,7 @@ // // <%= file.destination %> // -<%= fileHeader(file, 'short') %> +<%= fileHeader({file, commentStyle: 'short'}) %> import UIKit diff --git a/lib/register/format.js b/lib/register/format.js index 6148e7663..8fdd2b539 100644 --- a/lib/register/format.js +++ b/lib/register/format.js @@ -25,7 +25,7 @@ * @param {Object} args.dictionary.properties - Object structure of the tokens/properties that has been transformed and references resolved. * @param {Array} args.dictionary.allProperties - Flattened array of all the tokens/properties. This makes it easy to output a list, like a list of SCSS variables. * @param {function(value): Boolean} args.dictionary.usesReference - Use this function to see if a token's value uses a reference. This is the same function style dictionary uses internally to detect a reference. - * @param {function(value): Value} args.dictionary.getReferences - Use this function to get the token/property that it references. You can use this to output a reference in your custom format. For example: `dictionary.getReferences(token.original.value) // returns an array of the referenced token objects` + * @param {function(value): Value} args.dictionary.getReferences - Use this function to get the tokens/properties that it references. You can use this to output a reference in your custom format. For example: `dictionary.getReferences(token.original.value) // returns an array of the referenced token objects` * @param {Object} args.platform - The platform configuration this format is being called in. * @param {Object} args.file - The file configuration this format is being called in. * @param {Object} args.options - Merged options object that combines platform level configuration and file level configuration. File options take precedence. diff --git a/scripts/handlebars/templates/formats.hbs b/scripts/handlebars/templates/formats.hbs index f7675396d..4a4ec6ce2 100644 --- a/scripts/handlebars/templates/formats.hbs +++ b/scripts/handlebars/templates/formats.hbs @@ -254,7 +254,7 @@ StyleDictionary.registerFormat({ // the `dictionary` object now has `usesReference()` and // `getReferences()` methods. `usesReference()` will return true if // the value has a reference in it. `getReferences()` will return - // the reference to the whole token so that you can access its + // an array of references to the whole tokens so that you can access its // name or any other attributes. if (dictionary.usesReference(token.original.value)) { // Note: make sure to use `token.original.value` because @@ -280,9 +280,10 @@ const { fileHeader, formattedVariables } = StyleDictionary.formatHelpers; StyleDictionary.registerFormat({ name: 'myCustomFormat', formatter: function({dictionary, file, options}) { - return fileHeader(file) + + const { outputReferences } = options; + return fileHeader({file}) + ':root {\n' + - formattedVariables('css', dictionary, options.outputReferences) + + formattedVariables({format: 'css', dictionary, outputReferences}) + '\n}\n'; } }); diff --git a/test.js b/test.js deleted file mode 100644 index 4ba79b2ac..000000000 --- a/test.js +++ /dev/null @@ -1,24 +0,0 @@ -const StyleDictionary = require('./index'); - -StyleDictionary.extend({ - properties: { - color: { - red: { value: "#f00" }, - blue: { value: "#00f" }, - danger: { value: "calc({color.red.value}, {color.blue.value})" }, - test: { value: "{color.red.value}" } - } - }, - platforms: { - css: { - transformGroup: `css`, - files: [{ - destination: `variables.css`, - format: `css/variables`, - options: { - outputReferences: true - } - }] - } - } -}).buildAllPlatforms(); \ No newline at end of file diff --git a/variables.css b/variables.css deleted file mode 100644 index aea6f08b1..000000000 --- a/variables.css +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Do not edit directly - * Generated on Tue, 30 Mar 2021 19:49:14 GMT - */ - -:root { - --color-blue: #0000ff; - --color-red: #ff0000; - --color-test: var(--color-red); - --color-danger: calc(var(--color-red), var(--color-blue)); -} From c3c10deb9ddae182b60518cacb32451fce2aa4ae Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Sun, 4 Apr 2021 20:59:49 -0700 Subject: [PATCH 5/6] chore(formats): using fileHeader in iOS formats and adding integration tests --- .../__snapshots__/iOSObjectiveC.test.js.snap | 1975 +++++++++++++++++ .../__snapshots__/scss.test.js.snap | 18 +- __integration__/iOSObjectiveC.test.js | 103 + .../formats/__snapshots__/all.test.js.snap | 71 +- .../__snapshots__/scssMaps.test.js.snap | 18 +- __tests__/formats/scssMaps.test.js | 242 +- lib/common/formats.js | 132 +- lib/common/templates/ios/colors.h.template | 20 +- lib/common/templates/ios/colors.m.template | 22 +- lib/common/templates/ios/macros.template | 17 +- lib/common/templates/ios/plist.template | 14 +- lib/common/templates/ios/singleton.h.template | 15 +- lib/common/templates/ios/singleton.m.template | 19 +- lib/common/templates/ios/static.h.template | 19 +- lib/common/templates/ios/static.m.template | 21 +- lib/common/templates/ios/strings.h.template | 18 +- lib/common/templates/ios/strings.m.template | 22 +- lib/common/templates/scss/map-deep.template | 18 +- lib/common/templates/scss/map-flat.template | 13 +- 19 files changed, 2347 insertions(+), 430 deletions(-) create mode 100644 __integration__/__snapshots__/iOSObjectiveC.test.js.snap create mode 100644 __integration__/iOSObjectiveC.test.js diff --git a/__integration__/__snapshots__/iOSObjectiveC.test.js.snap b/__integration__/__snapshots__/iOSObjectiveC.test.js.snap new file mode 100644 index 000000000..d7cb7f259 --- /dev/null +++ b/__integration__/__snapshots__/iOSObjectiveC.test.js.snap @@ -0,0 +1,1975 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`integration ios objective-c ios/color.h should match snapshot 1`] = ` +" +// +// color.h +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import + +typedef NS_ENUM(NSInteger, ) { +ColorBackgroundPrimary, +ColorBackgroundSecondary, +ColorBackgroundTertiary, +ColorBackgroundDanger, +ColorBackgroundWarning, +ColorBackgroundSuccess, +ColorBackgroundInfo, +ColorBackgroundDisabled, +ColorBorderPrimary, +ColorBrandPrimary, +ColorBrandSecondary, +ColorCoreGreen0, +ColorCoreGreen100, +ColorCoreGreen200, +ColorCoreGreen300, +ColorCoreGreen400, +ColorCoreGreen500, +ColorCoreGreen600, +ColorCoreGreen700, +ColorCoreGreen800, +ColorCoreGreen900, +ColorCoreGreen1000, +ColorCoreGreen1100, +ColorCoreTeal0, +ColorCoreTeal100, +ColorCoreTeal200, +ColorCoreTeal300, +ColorCoreTeal400, +ColorCoreTeal500, +ColorCoreTeal600, +ColorCoreTeal700, +ColorCoreTeal800, +ColorCoreTeal900, +ColorCoreTeal1000, +ColorCoreTeal1100, +ColorCoreAqua0, +ColorCoreAqua100, +ColorCoreAqua200, +ColorCoreAqua300, +ColorCoreAqua400, +ColorCoreAqua500, +ColorCoreAqua600, +ColorCoreAqua700, +ColorCoreAqua800, +ColorCoreAqua900, +ColorCoreAqua1000, +ColorCoreAqua1100, +ColorCoreBlue0, +ColorCoreBlue100, +ColorCoreBlue200, +ColorCoreBlue300, +ColorCoreBlue400, +ColorCoreBlue500, +ColorCoreBlue600, +ColorCoreBlue700, +ColorCoreBlue800, +ColorCoreBlue900, +ColorCoreBlue1000, +ColorCoreBlue1100, +ColorCorePurple0, +ColorCorePurple100, +ColorCorePurple200, +ColorCorePurple300, +ColorCorePurple400, +ColorCorePurple500, +ColorCorePurple600, +ColorCorePurple700, +ColorCorePurple800, +ColorCorePurple900, +ColorCorePurple1000, +ColorCorePurple1100, +ColorCoreMagenta0, +ColorCoreMagenta100, +ColorCoreMagenta200, +ColorCoreMagenta300, +ColorCoreMagenta400, +ColorCoreMagenta500, +ColorCoreMagenta600, +ColorCoreMagenta700, +ColorCoreMagenta800, +ColorCoreMagenta900, +ColorCoreMagenta1000, +ColorCoreMagenta1100, +ColorCorePink0, +ColorCorePink100, +ColorCorePink200, +ColorCorePink300, +ColorCorePink400, +ColorCorePink500, +ColorCorePink600, +ColorCorePink700, +ColorCorePink800, +ColorCorePink900, +ColorCorePink1000, +ColorCorePink1100, +ColorCoreRed0, +ColorCoreRed100, +ColorCoreRed200, +ColorCoreRed300, +ColorCoreRed400, +ColorCoreRed500, +ColorCoreRed600, +ColorCoreRed700, +ColorCoreRed800, +ColorCoreRed900, +ColorCoreRed1000, +ColorCoreRed1100, +ColorCoreOrange0, +ColorCoreOrange100, +ColorCoreOrange200, +ColorCoreOrange300, +ColorCoreOrange400, +ColorCoreOrange500, +ColorCoreOrange600, +ColorCoreOrange700, +ColorCoreOrange800, +ColorCoreOrange900, +ColorCoreOrange1000, +ColorCoreOrange1100, +ColorCoreNeutral0, +ColorCoreNeutral100, +ColorCoreNeutral200, +ColorCoreNeutral300, +ColorCoreNeutral400, +ColorCoreNeutral500, +ColorCoreNeutral600, +ColorCoreNeutral700, +ColorCoreNeutral800, +ColorCoreNeutral900, +ColorCoreNeutral1000, +ColorCoreNeutral1100, +ColorCoreYellow0, +ColorCoreYellow100, +ColorCoreYellow200, +ColorCoreYellow300, +ColorCoreYellow400, +ColorCoreYellow500, +ColorCoreYellow600, +ColorCoreYellow700, +ColorCoreYellow800, +ColorCoreYellow900, +ColorCoreYellow1000, +ColorCoreYellow1100, +ColorFontPrimary, +ColorFontSecondary, +ColorFontTertiary, +ColorFontInteractive, +ColorFontInteractiveHover, +ColorFontInteractiveActive, +ColorFontInteractiveDisabled, +ColorFontDanger, +ColorFontWarning, +ColorFontSuccess +}; + +@interface StyleDictionaryColor : NSObject ++ (NSArray *)values; ++ (UIColor *)color:()color; +@end +" +`; + +exports[`integration ios objective-c ios/color.m should match snapshot 1`] = ` +" +// +// color.m +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import \\"StyleDictionaryColor.h\\" + +@implementation StyleDictionaryColor + ++ (UIColor *)color:()colorEnum{ + return [[self values] objectAtIndex:colorEnum]; +} + ++ (NSArray *)values { + static NSArray* colorArray; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + colorArray = @[ +[UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f], +[UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f], +[UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f], +[UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], +[UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f], +[UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], +[UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], +[UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f], +[UIColor colorWithRed:0.843f green:0.957f blue:0.843f alpha:1.000f], +[UIColor colorWithRed:0.761f green:0.949f blue:0.741f alpha:1.000f], +[UIColor colorWithRed:0.596f green:0.898f blue:0.557f alpha:1.000f], +[UIColor colorWithRed:0.459f green:0.867f blue:0.400f alpha:1.000f], +[UIColor colorWithRed:0.349f green:0.796f blue:0.349f alpha:1.000f], +[UIColor colorWithRed:0.169f green:0.714f blue:0.337f alpha:1.000f], +[UIColor colorWithRed:0.047f green:0.655f blue:0.314f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.545f blue:0.275f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.420f blue:0.251f alpha:1.000f], +[UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.169f blue:0.125f alpha:1.000f], +[UIColor colorWithRed:0.898f green:0.976f blue:0.961f alpha:1.000f], +[UIColor colorWithRed:0.804f green:0.969f blue:0.937f alpha:1.000f], +[UIColor colorWithRed:0.702f green:0.949f blue:0.902f alpha:1.000f], +[UIColor colorWithRed:0.490f green:0.918f blue:0.835f alpha:1.000f], +[UIColor colorWithRed:0.141f green:0.878f blue:0.773f alpha:1.000f], +[UIColor colorWithRed:0.031f green:0.769f blue:0.698f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.663f blue:0.612f alpha:1.000f], +[UIColor colorWithRed:0.043f green:0.588f blue:0.561f alpha:1.000f], +[UIColor colorWithRed:0.024f green:0.486f blue:0.486f alpha:1.000f], +[UIColor colorWithRed:0.008f green:0.400f blue:0.380f alpha:1.000f], +[UIColor colorWithRed:0.031f green:0.247f blue:0.247f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.145f blue:0.157f alpha:1.000f], +[UIColor colorWithRed:0.851f green:0.988f blue:0.984f alpha:1.000f], +[UIColor colorWithRed:0.773f green:0.976f blue:0.976f alpha:1.000f], +[UIColor colorWithRed:0.647f green:0.949f blue:0.949f alpha:1.000f], +[UIColor colorWithRed:0.463f green:0.898f blue:0.886f alpha:1.000f], +[UIColor colorWithRed:0.200f green:0.839f blue:0.886f alpha:1.000f], +[UIColor colorWithRed:0.090f green:0.722f blue:0.808f alpha:1.000f], +[UIColor colorWithRed:0.027f green:0.592f blue:0.682f alpha:1.000f], +[UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], +[UIColor colorWithRed:0.059f green:0.431f blue:0.518f alpha:1.000f], +[UIColor colorWithRed:0.012f green:0.369f blue:0.451f alpha:1.000f], +[UIColor colorWithRed:0.031f green:0.239f blue:0.310f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.157f blue:0.220f alpha:1.000f], +[UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.863f green:0.949f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.780f green:0.894f blue:0.976f alpha:1.000f], +[UIColor colorWithRed:0.631f green:0.824f blue:0.973f alpha:1.000f], +[UIColor colorWithRed:0.337f green:0.678f blue:0.961f alpha:1.000f], +[UIColor colorWithRed:0.220f green:0.588f blue:0.890f alpha:1.000f], +[UIColor colorWithRed:0.169f green:0.529f blue:0.827f alpha:1.000f], +[UIColor colorWithRed:0.125f green:0.475f blue:0.765f alpha:1.000f], +[UIColor colorWithRed:0.067f green:0.427f blue:0.667f alpha:1.000f], +[UIColor colorWithRed:0.047f green:0.337f blue:0.537f alpha:1.000f], +[UIColor colorWithRed:0.039f green:0.224f blue:0.376f alpha:1.000f], +[UIColor colorWithRed:0.000f green:0.129f blue:0.220f alpha:1.000f], +[UIColor colorWithRed:0.949f green:0.949f blue:0.976f alpha:1.000f], +[UIColor colorWithRed:0.918f green:0.918f blue:0.976f alpha:1.000f], +[UIColor colorWithRed:0.847f green:0.843f blue:0.976f alpha:1.000f], +[UIColor colorWithRed:0.757f green:0.757f blue:0.969f alpha:1.000f], +[UIColor colorWithRed:0.631f green:0.576f blue:0.949f alpha:1.000f], +[UIColor colorWithRed:0.569f green:0.502f blue:0.957f alpha:1.000f], +[UIColor colorWithRed:0.506f green:0.435f blue:0.918f alpha:1.000f], +[UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], +[UIColor colorWithRed:0.369f green:0.306f blue:0.729f alpha:1.000f], +[UIColor colorWithRed:0.282f green:0.227f blue:0.612f alpha:1.000f], +[UIColor colorWithRed:0.176f green:0.141f blue:0.420f alpha:1.000f], +[UIColor colorWithRed:0.114f green:0.114f blue:0.220f alpha:1.000f], +[UIColor colorWithRed:0.996f green:0.941f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.976f green:0.890f blue:0.988f alpha:1.000f], +[UIColor colorWithRed:0.957f green:0.769f blue:0.969f alpha:1.000f], +[UIColor colorWithRed:0.929f green:0.678f blue:0.949f alpha:1.000f], +[UIColor colorWithRed:0.949f green:0.510f blue:0.961f alpha:1.000f], +[UIColor colorWithRed:0.859f green:0.380f blue:0.859f alpha:1.000f], +[UIColor colorWithRed:0.769f green:0.306f blue:0.725f alpha:1.000f], +[UIColor colorWithRed:0.675f green:0.267f blue:0.659f alpha:1.000f], +[UIColor colorWithRed:0.561f green:0.220f blue:0.588f alpha:1.000f], +[UIColor colorWithRed:0.424f green:0.133f blue:0.467f alpha:1.000f], +[UIColor colorWithRed:0.271f green:0.082f blue:0.318f alpha:1.000f], +[UIColor colorWithRed:0.161f green:0.098f blue:0.176f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.914f blue:0.953f alpha:1.000f], +[UIColor colorWithRed:0.988f green:0.859f blue:0.922f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.710f blue:0.835f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.584f blue:0.757f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.463f blue:0.682f alpha:1.000f], +[UIColor colorWithRed:0.937f green:0.345f blue:0.545f alpha:1.000f], +[UIColor colorWithRed:0.878f green:0.267f blue:0.486f alpha:1.000f], +[UIColor colorWithRed:0.808f green:0.212f blue:0.396f alpha:1.000f], +[UIColor colorWithRed:0.698f green:0.184f blue:0.357f alpha:1.000f], +[UIColor colorWithRed:0.576f green:0.094f blue:0.278f alpha:1.000f], +[UIColor colorWithRed:0.337f green:0.071f blue:0.192f alpha:1.000f], +[UIColor colorWithRed:0.169f green:0.090f blue:0.129f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.835f blue:0.824f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.722f blue:0.694f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.612f blue:0.561f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.498f blue:0.431f alpha:1.000f], +[UIColor colorWithRed:0.969f green:0.376f blue:0.329f alpha:1.000f], +[UIColor colorWithRed:0.929f green:0.298f blue:0.259f alpha:1.000f], +[UIColor colorWithRed:0.859f green:0.243f blue:0.243f alpha:1.000f], +[UIColor colorWithRed:0.776f green:0.204f blue:0.204f alpha:1.000f], +[UIColor colorWithRed:0.600f green:0.133f blue:0.133f alpha:1.000f], +[UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f], +[UIColor colorWithRed:0.169f green:0.067f blue:0.067f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f], +[UIColor colorWithRed:0.988f green:0.863f blue:0.800f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.776f blue:0.643f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.694f blue:0.502f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.612f blue:0.365f alpha:1.000f], +[UIColor colorWithRed:0.988f green:0.537f blue:0.263f alpha:1.000f], +[UIColor colorWithRed:0.961f green:0.490f blue:0.200f alpha:1.000f], +[UIColor colorWithRed:0.929f green:0.439f blue:0.141f alpha:1.000f], +[UIColor colorWithRed:0.808f green:0.333f blue:0.067f alpha:1.000f], +[UIColor colorWithRed:0.588f green:0.173f blue:0.043f alpha:1.000f], +[UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f], +[UIColor colorWithRed:0.176f green:0.075f blue:0.055f alpha:1.000f], +[UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f], +[UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f], +[UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], +[UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f], +[UIColor colorWithRed:0.690f green:0.714f blue:0.718f alpha:1.000f], +[UIColor colorWithRed:0.573f green:0.604f blue:0.608f alpha:1.000f], +[UIColor colorWithRed:0.431f green:0.475f blue:0.478f alpha:1.000f], +[UIColor colorWithRed:0.318f green:0.369f blue:0.373f alpha:1.000f], +[UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], +[UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f], +[UIColor colorWithRed:0.086f green:0.125f blue:0.125f alpha:1.000f], +[UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.973f blue:0.886f alpha:1.000f], +[UIColor colorWithRed:0.992f green:0.937f blue:0.804f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.914f blue:0.604f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.882f blue:0.431f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.851f blue:0.263f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.804f blue:0.110f alpha:1.000f], +[UIColor colorWithRed:1.000f green:0.737f blue:0.000f alpha:1.000f], +[UIColor colorWithRed:0.867f green:0.600f blue:0.012f alpha:1.000f], +[UIColor colorWithRed:0.729f green:0.459f blue:0.024f alpha:1.000f], +[UIColor colorWithRed:0.580f green:0.298f blue:0.047f alpha:1.000f], +[UIColor colorWithRed:0.329f green:0.165f blue:0.000f alpha:1.000f], +[UIColor colorWithRed:0.176f green:0.102f blue:0.020f alpha:1.000f], +[UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f], +[UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f], +[UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], +[UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], +[UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], +[UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], +[UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], +[UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f], +[UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f], +[UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f] + ]; + }); + + return colorArray; +} + +@end +" +`; + +exports[`integration ios objective-c ios/macros.h should match snapshot 1`] = ` +" +// +// macros.h +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import +#import + +#define ColorBackgroundPrimary [UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f] +#define ColorBackgroundSecondary [UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f] +#define ColorBackgroundTertiary [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f] +#define ColorBackgroundDanger [UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f] +#define ColorBackgroundWarning [UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f] +#define ColorBackgroundSuccess [UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f] +#define ColorBackgroundInfo [UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f] +#define ColorBackgroundDisabled [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f] +#define ColorBorderPrimary [UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f] +#define ColorBrandPrimary [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f] +#define ColorBrandSecondary [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f] +#define ColorCoreGreen0 [UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f] +#define ColorCoreGreen100 [UIColor colorWithRed:0.843f green:0.957f blue:0.843f alpha:1.000f] +#define ColorCoreGreen200 [UIColor colorWithRed:0.761f green:0.949f blue:0.741f alpha:1.000f] +#define ColorCoreGreen300 [UIColor colorWithRed:0.596f green:0.898f blue:0.557f alpha:1.000f] +#define ColorCoreGreen400 [UIColor colorWithRed:0.459f green:0.867f blue:0.400f alpha:1.000f] +#define ColorCoreGreen500 [UIColor colorWithRed:0.349f green:0.796f blue:0.349f alpha:1.000f] +#define ColorCoreGreen600 [UIColor colorWithRed:0.169f green:0.714f blue:0.337f alpha:1.000f] +#define ColorCoreGreen700 [UIColor colorWithRed:0.047f green:0.655f blue:0.314f alpha:1.000f] +#define ColorCoreGreen800 [UIColor colorWithRed:0.000f green:0.545f blue:0.275f alpha:1.000f] +#define ColorCoreGreen900 [UIColor colorWithRed:0.000f green:0.420f blue:0.251f alpha:1.000f] +#define ColorCoreGreen1000 [UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f] +#define ColorCoreGreen1100 [UIColor colorWithRed:0.000f green:0.169f blue:0.125f alpha:1.000f] +#define ColorCoreTeal0 [UIColor colorWithRed:0.898f green:0.976f blue:0.961f alpha:1.000f] +#define ColorCoreTeal100 [UIColor colorWithRed:0.804f green:0.969f blue:0.937f alpha:1.000f] +#define ColorCoreTeal200 [UIColor colorWithRed:0.702f green:0.949f blue:0.902f alpha:1.000f] +#define ColorCoreTeal300 [UIColor colorWithRed:0.490f green:0.918f blue:0.835f alpha:1.000f] +#define ColorCoreTeal400 [UIColor colorWithRed:0.141f green:0.878f blue:0.773f alpha:1.000f] +#define ColorCoreTeal500 [UIColor colorWithRed:0.031f green:0.769f blue:0.698f alpha:1.000f] +#define ColorCoreTeal600 [UIColor colorWithRed:0.000f green:0.663f blue:0.612f alpha:1.000f] +#define ColorCoreTeal700 [UIColor colorWithRed:0.043f green:0.588f blue:0.561f alpha:1.000f] +#define ColorCoreTeal800 [UIColor colorWithRed:0.024f green:0.486f blue:0.486f alpha:1.000f] +#define ColorCoreTeal900 [UIColor colorWithRed:0.008f green:0.400f blue:0.380f alpha:1.000f] +#define ColorCoreTeal1000 [UIColor colorWithRed:0.031f green:0.247f blue:0.247f alpha:1.000f] +#define ColorCoreTeal1100 [UIColor colorWithRed:0.000f green:0.145f blue:0.157f alpha:1.000f] +#define ColorCoreAqua0 [UIColor colorWithRed:0.851f green:0.988f blue:0.984f alpha:1.000f] +#define ColorCoreAqua100 [UIColor colorWithRed:0.773f green:0.976f blue:0.976f alpha:1.000f] +#define ColorCoreAqua200 [UIColor colorWithRed:0.647f green:0.949f blue:0.949f alpha:1.000f] +#define ColorCoreAqua300 [UIColor colorWithRed:0.463f green:0.898f blue:0.886f alpha:1.000f] +#define ColorCoreAqua400 [UIColor colorWithRed:0.200f green:0.839f blue:0.886f alpha:1.000f] +#define ColorCoreAqua500 [UIColor colorWithRed:0.090f green:0.722f blue:0.808f alpha:1.000f] +#define ColorCoreAqua600 [UIColor colorWithRed:0.027f green:0.592f blue:0.682f alpha:1.000f] +#define ColorCoreAqua700 [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f] +#define ColorCoreAqua800 [UIColor colorWithRed:0.059f green:0.431f blue:0.518f alpha:1.000f] +#define ColorCoreAqua900 [UIColor colorWithRed:0.012f green:0.369f blue:0.451f alpha:1.000f] +#define ColorCoreAqua1000 [UIColor colorWithRed:0.031f green:0.239f blue:0.310f alpha:1.000f] +#define ColorCoreAqua1100 [UIColor colorWithRed:0.000f green:0.157f blue:0.220f alpha:1.000f] +#define ColorCoreBlue0 [UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f] +#define ColorCoreBlue100 [UIColor colorWithRed:0.863f green:0.949f blue:1.000f alpha:1.000f] +#define ColorCoreBlue200 [UIColor colorWithRed:0.780f green:0.894f blue:0.976f alpha:1.000f] +#define ColorCoreBlue300 [UIColor colorWithRed:0.631f green:0.824f blue:0.973f alpha:1.000f] +#define ColorCoreBlue400 [UIColor colorWithRed:0.337f green:0.678f blue:0.961f alpha:1.000f] +#define ColorCoreBlue500 [UIColor colorWithRed:0.220f green:0.588f blue:0.890f alpha:1.000f] +#define ColorCoreBlue600 [UIColor colorWithRed:0.169f green:0.529f blue:0.827f alpha:1.000f] +#define ColorCoreBlue700 [UIColor colorWithRed:0.125f green:0.475f blue:0.765f alpha:1.000f] +#define ColorCoreBlue800 [UIColor colorWithRed:0.067f green:0.427f blue:0.667f alpha:1.000f] +#define ColorCoreBlue900 [UIColor colorWithRed:0.047f green:0.337f blue:0.537f alpha:1.000f] +#define ColorCoreBlue1000 [UIColor colorWithRed:0.039f green:0.224f blue:0.376f alpha:1.000f] +#define ColorCoreBlue1100 [UIColor colorWithRed:0.000f green:0.129f blue:0.220f alpha:1.000f] +#define ColorCorePurple0 [UIColor colorWithRed:0.949f green:0.949f blue:0.976f alpha:1.000f] +#define ColorCorePurple100 [UIColor colorWithRed:0.918f green:0.918f blue:0.976f alpha:1.000f] +#define ColorCorePurple200 [UIColor colorWithRed:0.847f green:0.843f blue:0.976f alpha:1.000f] +#define ColorCorePurple300 [UIColor colorWithRed:0.757f green:0.757f blue:0.969f alpha:1.000f] +#define ColorCorePurple400 [UIColor colorWithRed:0.631f green:0.576f blue:0.949f alpha:1.000f] +#define ColorCorePurple500 [UIColor colorWithRed:0.569f green:0.502f blue:0.957f alpha:1.000f] +#define ColorCorePurple600 [UIColor colorWithRed:0.506f green:0.435f blue:0.918f alpha:1.000f] +#define ColorCorePurple700 [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f] +#define ColorCorePurple800 [UIColor colorWithRed:0.369f green:0.306f blue:0.729f alpha:1.000f] +#define ColorCorePurple900 [UIColor colorWithRed:0.282f green:0.227f blue:0.612f alpha:1.000f] +#define ColorCorePurple1000 [UIColor colorWithRed:0.176f green:0.141f blue:0.420f alpha:1.000f] +#define ColorCorePurple1100 [UIColor colorWithRed:0.114f green:0.114f blue:0.220f alpha:1.000f] +#define ColorCoreMagenta0 [UIColor colorWithRed:0.996f green:0.941f blue:1.000f alpha:1.000f] +#define ColorCoreMagenta100 [UIColor colorWithRed:0.976f green:0.890f blue:0.988f alpha:1.000f] +#define ColorCoreMagenta200 [UIColor colorWithRed:0.957f green:0.769f blue:0.969f alpha:1.000f] +#define ColorCoreMagenta300 [UIColor colorWithRed:0.929f green:0.678f blue:0.949f alpha:1.000f] +#define ColorCoreMagenta400 [UIColor colorWithRed:0.949f green:0.510f blue:0.961f alpha:1.000f] +#define ColorCoreMagenta500 [UIColor colorWithRed:0.859f green:0.380f blue:0.859f alpha:1.000f] +#define ColorCoreMagenta600 [UIColor colorWithRed:0.769f green:0.306f blue:0.725f alpha:1.000f] +#define ColorCoreMagenta700 [UIColor colorWithRed:0.675f green:0.267f blue:0.659f alpha:1.000f] +#define ColorCoreMagenta800 [UIColor colorWithRed:0.561f green:0.220f blue:0.588f alpha:1.000f] +#define ColorCoreMagenta900 [UIColor colorWithRed:0.424f green:0.133f blue:0.467f alpha:1.000f] +#define ColorCoreMagenta1000 [UIColor colorWithRed:0.271f green:0.082f blue:0.318f alpha:1.000f] +#define ColorCoreMagenta1100 [UIColor colorWithRed:0.161f green:0.098f blue:0.176f alpha:1.000f] +#define ColorCorePink0 [UIColor colorWithRed:1.000f green:0.914f blue:0.953f alpha:1.000f] +#define ColorCorePink100 [UIColor colorWithRed:0.988f green:0.859f blue:0.922f alpha:1.000f] +#define ColorCorePink200 [UIColor colorWithRed:1.000f green:0.710f blue:0.835f alpha:1.000f] +#define ColorCorePink300 [UIColor colorWithRed:1.000f green:0.584f blue:0.757f alpha:1.000f] +#define ColorCorePink400 [UIColor colorWithRed:1.000f green:0.463f blue:0.682f alpha:1.000f] +#define ColorCorePink500 [UIColor colorWithRed:0.937f green:0.345f blue:0.545f alpha:1.000f] +#define ColorCorePink600 [UIColor colorWithRed:0.878f green:0.267f blue:0.486f alpha:1.000f] +#define ColorCorePink700 [UIColor colorWithRed:0.808f green:0.212f blue:0.396f alpha:1.000f] +#define ColorCorePink800 [UIColor colorWithRed:0.698f green:0.184f blue:0.357f alpha:1.000f] +#define ColorCorePink900 [UIColor colorWithRed:0.576f green:0.094f blue:0.278f alpha:1.000f] +#define ColorCorePink1000 [UIColor colorWithRed:0.337f green:0.071f blue:0.192f alpha:1.000f] +#define ColorCorePink1100 [UIColor colorWithRed:0.169f green:0.090f blue:0.129f alpha:1.000f] +#define ColorCoreRed0 [UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f] +#define ColorCoreRed100 [UIColor colorWithRed:1.000f green:0.835f blue:0.824f alpha:1.000f] +#define ColorCoreRed200 [UIColor colorWithRed:1.000f green:0.722f blue:0.694f alpha:1.000f] +#define ColorCoreRed300 [UIColor colorWithRed:1.000f green:0.612f blue:0.561f alpha:1.000f] +#define ColorCoreRed400 [UIColor colorWithRed:1.000f green:0.498f blue:0.431f alpha:1.000f] +#define ColorCoreRed500 [UIColor colorWithRed:0.969f green:0.376f blue:0.329f alpha:1.000f] +#define ColorCoreRed600 [UIColor colorWithRed:0.929f green:0.298f blue:0.259f alpha:1.000f] +#define ColorCoreRed700 [UIColor colorWithRed:0.859f green:0.243f blue:0.243f alpha:1.000f] +#define ColorCoreRed800 [UIColor colorWithRed:0.776f green:0.204f blue:0.204f alpha:1.000f] +#define ColorCoreRed900 [UIColor colorWithRed:0.600f green:0.133f blue:0.133f alpha:1.000f] +#define ColorCoreRed1000 [UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f] +#define ColorCoreRed1100 [UIColor colorWithRed:0.169f green:0.067f blue:0.067f alpha:1.000f] +#define ColorCoreOrange0 [UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f] +#define ColorCoreOrange100 [UIColor colorWithRed:0.988f green:0.863f blue:0.800f alpha:1.000f] +#define ColorCoreOrange200 [UIColor colorWithRed:1.000f green:0.776f blue:0.643f alpha:1.000f] +#define ColorCoreOrange300 [UIColor colorWithRed:1.000f green:0.694f blue:0.502f alpha:1.000f] +#define ColorCoreOrange400 [UIColor colorWithRed:1.000f green:0.612f blue:0.365f alpha:1.000f] +#define ColorCoreOrange500 [UIColor colorWithRed:0.988f green:0.537f blue:0.263f alpha:1.000f] +#define ColorCoreOrange600 [UIColor colorWithRed:0.961f green:0.490f blue:0.200f alpha:1.000f] +#define ColorCoreOrange700 [UIColor colorWithRed:0.929f green:0.439f blue:0.141f alpha:1.000f] +#define ColorCoreOrange800 [UIColor colorWithRed:0.808f green:0.333f blue:0.067f alpha:1.000f] +#define ColorCoreOrange900 [UIColor colorWithRed:0.588f green:0.173f blue:0.043f alpha:1.000f] +#define ColorCoreOrange1000 [UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f] +#define ColorCoreOrange1100 [UIColor colorWithRed:0.176f green:0.075f blue:0.055f alpha:1.000f] +#define ColorCoreNeutral0 [UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f] +#define ColorCoreNeutral100 [UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f] +#define ColorCoreNeutral200 [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f] +#define ColorCoreNeutral300 [UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f] +#define ColorCoreNeutral400 [UIColor colorWithRed:0.690f green:0.714f blue:0.718f alpha:1.000f] +#define ColorCoreNeutral500 [UIColor colorWithRed:0.573f green:0.604f blue:0.608f alpha:1.000f] +#define ColorCoreNeutral600 [UIColor colorWithRed:0.431f green:0.475f blue:0.478f alpha:1.000f] +#define ColorCoreNeutral700 [UIColor colorWithRed:0.318f green:0.369f blue:0.373f alpha:1.000f] +#define ColorCoreNeutral800 [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f] +#define ColorCoreNeutral900 [UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f] +#define ColorCoreNeutral1000 [UIColor colorWithRed:0.086f green:0.125f blue:0.125f alpha:1.000f] +#define ColorCoreNeutral1100 [UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f] +#define ColorCoreYellow0 [UIColor colorWithRed:1.000f green:0.973f blue:0.886f alpha:1.000f] +#define ColorCoreYellow100 [UIColor colorWithRed:0.992f green:0.937f blue:0.804f alpha:1.000f] +#define ColorCoreYellow200 [UIColor colorWithRed:1.000f green:0.914f blue:0.604f alpha:1.000f] +#define ColorCoreYellow300 [UIColor colorWithRed:1.000f green:0.882f blue:0.431f alpha:1.000f] +#define ColorCoreYellow400 [UIColor colorWithRed:1.000f green:0.851f blue:0.263f alpha:1.000f] +#define ColorCoreYellow500 [UIColor colorWithRed:1.000f green:0.804f blue:0.110f alpha:1.000f] +#define ColorCoreYellow600 [UIColor colorWithRed:1.000f green:0.737f blue:0.000f alpha:1.000f] +#define ColorCoreYellow700 [UIColor colorWithRed:0.867f green:0.600f blue:0.012f alpha:1.000f] +#define ColorCoreYellow800 [UIColor colorWithRed:0.729f green:0.459f blue:0.024f alpha:1.000f] +#define ColorCoreYellow900 [UIColor colorWithRed:0.580f green:0.298f blue:0.047f alpha:1.000f] +#define ColorCoreYellow1000 [UIColor colorWithRed:0.329f green:0.165f blue:0.000f alpha:1.000f] +#define ColorCoreYellow1100 [UIColor colorWithRed:0.176f green:0.102f blue:0.020f alpha:1.000f] +#define ColorFontPrimary [UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f] +#define ColorFontSecondary [UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f] +#define ColorFontTertiary [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f] +#define ColorFontInteractive [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f] +#define ColorFontInteractiveHover [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f] +#define ColorFontInteractiveActive [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f] +#define ColorFontInteractiveDisabled [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f] +#define ColorFontDanger [UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f] +#define ColorFontWarning [UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f] +#define ColorFontSuccess [UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f] +#define SizeBorderRadiusLarge 480.00f +#define SizeFontSmall 12.00f +#define SizeFontMedium 16.00f +#define SizeFontLarge 24.00f +#define SizeFontXl 36.00f +#define SizePaddingSmall 8.00f +#define SizePaddingMedium 16.00f +#define SizePaddingLarge 16.00f +#define SizePaddingXl 16.00f + +" +`; + +exports[`integration ios objective-c ios/singleton.h should match snapshot 1`] = ` +" +// +// singleton.h +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import +#import + +@interface StyleDictionary : NSObject + ++ (NSDictionary *)properties; ++ (NSDictionary *)getProperty:(NSString *)keyPath; ++ (nonnull)getValue:(NSString *)keyPath; + +@end +" +`; + +exports[`integration ios objective-c ios/singleton.m should match snapshot 1`] = ` +" +// +// singleton.m +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import \\"StyleDictionary.h\\" + +@implementation StyleDictionary + ++ (NSDictionary *)getProperty:(NSString *)keyPath { + return [[self properties] valueForKeyPath:keyPath]; +} + ++ (nonnull)getValue:(NSString *)keyPath { + return [[self properties] valueForKeyPath:[NSString stringWithFormat:@\\"%@.value\\", keyPath]]; +} + ++ (NSDictionary *)properties { + static NSDictionary * dictionary; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + dictionary = @{ + @\\"color\\": @{ + @\\"background\\": @{ + @\\"primary\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundPrimary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"primary\\" + }, + @\\"secondary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundSecondary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"secondary\\" + }, + @\\"tertiary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundTertiary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"tertiary\\" + }, + @\\"danger\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundDanger\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"danger\\" + }, + @\\"warning\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundWarning\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"warning\\" + }, + @\\"success\\": @{ + @\\"value\\": [UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundSuccess\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"success\\" + }, + @\\"info\\": @{ + @\\"value\\": [UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundInfo\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"info\\" + }, + @\\"disabled\\": @{ + @\\"value\\": [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], + @\\"name\\": @\\"ColorBackgroundDisabled\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"background\\", + @\\"item\\": @\\"disabled\\" + } + }, + @\\"border\\": @{ + @\\"primary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f], + @\\"name\\": @\\"ColorBorderPrimary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"border\\", + @\\"item\\": @\\"primary\\" + }, + @\\"secondary\\": @ + }, + @\\"tertiary\\": @ + } + }, + @\\"brand\\": @{ + @\\"primary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], + @\\"name\\": @\\"ColorBrandPrimary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"brand\\", + @\\"item\\": @\\"primary\\" + }, + @\\"secondary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], + @\\"name\\": @\\"ColorBrandSecondary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"brand\\", + @\\"item\\": @\\"secondary\\" + } + }, + @\\"core\\": @{ + @\\"green\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.922f green:0.976f blue:0.922f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.843f green:0.957f blue:0.843f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.761f green:0.949f blue:0.741f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.596f green:0.898f blue:0.557f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.459f green:0.867f blue:0.400f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.349f green:0.796f blue:0.349f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.169f green:0.714f blue:0.337f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.047f green:0.655f blue:0.314f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.545f blue:0.275f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.420f blue:0.251f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.169f blue:0.125f alpha:1.000f], + @\\"name\\": @\\"ColorCoreGreen1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"green\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"teal\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.898f green:0.976f blue:0.961f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.804f green:0.969f blue:0.937f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.702f green:0.949f blue:0.902f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.490f green:0.918f blue:0.835f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.141f green:0.878f blue:0.773f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.031f green:0.769f blue:0.698f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.663f blue:0.612f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.043f green:0.588f blue:0.561f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.024f green:0.486f blue:0.486f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.008f green:0.400f blue:0.380f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.031f green:0.247f blue:0.247f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.145f blue:0.157f alpha:1.000f], + @\\"name\\": @\\"ColorCoreTeal1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"teal\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"aqua\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.851f green:0.988f blue:0.984f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.773f green:0.976f blue:0.976f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.647f green:0.949f blue:0.949f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.463f green:0.898f blue:0.886f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.200f green:0.839f blue:0.886f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.090f green:0.722f blue:0.808f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.027f green:0.592f blue:0.682f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.059f green:0.431f blue:0.518f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.012f green:0.369f blue:0.451f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.031f green:0.239f blue:0.310f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.157f blue:0.220f alpha:1.000f], + @\\"name\\": @\\"ColorCoreAqua1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"aqua\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"blue\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.914f green:0.973f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.863f green:0.949f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.780f green:0.894f blue:0.976f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.631f green:0.824f blue:0.973f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.337f green:0.678f blue:0.961f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.220f green:0.588f blue:0.890f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.169f green:0.529f blue:0.827f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.125f green:0.475f blue:0.765f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.067f green:0.427f blue:0.667f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.047f green:0.337f blue:0.537f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.039f green:0.224f blue:0.376f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.000f green:0.129f blue:0.220f alpha:1.000f], + @\\"name\\": @\\"ColorCoreBlue1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"blue\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"purple\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.949f green:0.949f blue:0.976f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.918f green:0.918f blue:0.976f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.847f green:0.843f blue:0.976f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.757f green:0.757f blue:0.969f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.631f green:0.576f blue:0.949f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.569f green:0.502f blue:0.957f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.506f green:0.435f blue:0.918f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.369f green:0.306f blue:0.729f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.282f green:0.227f blue:0.612f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.176f green:0.141f blue:0.420f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.114f green:0.114f blue:0.220f alpha:1.000f], + @\\"name\\": @\\"ColorCorePurple1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"purple\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"magenta\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:0.996f green:0.941f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.976f green:0.890f blue:0.988f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.957f green:0.769f blue:0.969f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.929f green:0.678f blue:0.949f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.949f green:0.510f blue:0.961f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.859f green:0.380f blue:0.859f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.769f green:0.306f blue:0.725f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.675f green:0.267f blue:0.659f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.561f green:0.220f blue:0.588f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.424f green:0.133f blue:0.467f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.271f green:0.082f blue:0.318f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.161f green:0.098f blue:0.176f alpha:1.000f], + @\\"name\\": @\\"ColorCoreMagenta1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"magenta\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"pink\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.914f blue:0.953f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.988f green:0.859f blue:0.922f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.710f blue:0.835f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.584f blue:0.757f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.463f blue:0.682f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.937f green:0.345f blue:0.545f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.878f green:0.267f blue:0.486f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.808f green:0.212f blue:0.396f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.698f green:0.184f blue:0.357f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.576f green:0.094f blue:0.278f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.337f green:0.071f blue:0.192f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.169f green:0.090f blue:0.129f alpha:1.000f], + @\\"name\\": @\\"ColorCorePink1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"pink\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"red\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.918f blue:0.914f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.835f blue:0.824f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.722f blue:0.694f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.612f blue:0.561f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.498f blue:0.431f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.969f green:0.376f blue:0.329f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.929f green:0.298f blue:0.259f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.859f green:0.243f blue:0.243f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.776f green:0.204f blue:0.204f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.600f green:0.133f blue:0.133f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.169f green:0.067f blue:0.067f alpha:1.000f], + @\\"name\\": @\\"ColorCoreRed1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"red\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"orange\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.929f blue:0.890f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.988f green:0.863f blue:0.800f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.776f blue:0.643f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.694f blue:0.502f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.612f blue:0.365f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.988f green:0.537f blue:0.263f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.961f green:0.490f blue:0.200f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.929f green:0.439f blue:0.141f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.808f green:0.333f blue:0.067f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.588f green:0.173f blue:0.043f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.176f green:0.075f blue:0.055f alpha:1.000f], + @\\"name\\": @\\"ColorCoreOrange1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"orange\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"neutral\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:1.000f blue:1.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.953f green:0.957f blue:0.957f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:0.871f green:0.882f blue:0.882f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:0.784f green:0.800f blue:0.800f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:0.690f green:0.714f blue:0.718f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:0.573f green:0.604f blue:0.608f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:0.431f green:0.475f blue:0.478f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.318f green:0.369f blue:0.373f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.086f green:0.125f blue:0.125f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f], + @\\"name\\": @\\"ColorCoreNeutral1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"neutral\\", + @\\"subitem\\": @\\"1100\\" + } + }, + @\\"yellow\\": @{ + @\\"0\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.973f blue:0.886f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow0\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"0\\" + }, + @\\"100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.992f green:0.937f blue:0.804f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"100\\" + }, + @\\"200\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.914f blue:0.604f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow200\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"200\\" + }, + @\\"300\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.882f blue:0.431f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow300\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"300\\" + }, + @\\"400\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.851f blue:0.263f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow400\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"400\\" + }, + @\\"500\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.804f blue:0.110f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow500\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"500\\" + }, + @\\"600\\": @{ + @\\"value\\": [UIColor colorWithRed:1.000f green:0.737f blue:0.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow600\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"600\\" + }, + @\\"700\\": @{ + @\\"value\\": [UIColor colorWithRed:0.867f green:0.600f blue:0.012f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow700\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"700\\" + }, + @\\"800\\": @{ + @\\"value\\": [UIColor colorWithRed:0.729f green:0.459f blue:0.024f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow800\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"800\\" + }, + @\\"900\\": @{ + @\\"value\\": [UIColor colorWithRed:0.580f green:0.298f blue:0.047f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow900\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"900\\" + }, + @\\"1000\\": @{ + @\\"value\\": [UIColor colorWithRed:0.329f green:0.165f blue:0.000f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow1000\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"1000\\" + }, + @\\"1100\\": @{ + @\\"value\\": [UIColor colorWithRed:0.176f green:0.102f blue:0.020f alpha:1.000f], + @\\"name\\": @\\"ColorCoreYellow1100\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"core\\", + @\\"item\\": @\\"yellow\\", + @\\"subitem\\": @\\"1100\\" + } + } + }, + @\\"font\\": @{ + @\\"primary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.016f green:0.016f blue:0.016f alpha:1.000f], + @\\"name\\": @\\"ColorFontPrimary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"primary\\" + }, + @\\"secondary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.153f green:0.200f blue:0.200f alpha:1.000f], + @\\"name\\": @\\"ColorFontSecondary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"secondary\\" + }, + @\\"tertiary\\": @{ + @\\"value\\": [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], + @\\"name\\": @\\"ColorFontTertiary\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"tertiary\\" + }, + @\\"interactive\\": @{ + @\\"_\\": @{ + @\\"value\\": [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], + @\\"name\\": @\\"ColorFontInteractive\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"interactive\\", + @\\"subitem\\": @\\"_\\" + }, + @\\"hover\\": @{ + @\\"value\\": [UIColor colorWithRed:0.043f green:0.522f blue:0.600f alpha:1.000f], + @\\"name\\": @\\"ColorFontInteractiveHover\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"interactive\\", + @\\"subitem\\": @\\"hover\\" + }, + @\\"active\\": @{ + @\\"value\\": [UIColor colorWithRed:0.435f green:0.369f blue:0.827f alpha:1.000f], + @\\"name\\": @\\"ColorFontInteractiveActive\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"interactive\\", + @\\"subitem\\": @\\"active\\" + }, + @\\"disabled\\": @{ + @\\"value\\": [UIColor colorWithRed:0.212f green:0.255f blue:0.255f alpha:1.000f], + @\\"name\\": @\\"ColorFontInteractiveDisabled\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"interactive\\", + @\\"subitem\\": @\\"disabled\\" + } + }, + @\\"danger\\": @{ + @\\"value\\": [UIColor colorWithRed:0.427f green:0.075f blue:0.075f alpha:1.000f], + @\\"name\\": @\\"ColorFontDanger\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"danger\\" + }, + @\\"warning\\": @{ + @\\"value\\": [UIColor colorWithRed:0.376f green:0.090f blue:0.000f alpha:1.000f], + @\\"name\\": @\\"ColorFontWarning\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"warning\\" + }, + @\\"success\\": @{ + @\\"value\\": [UIColor colorWithRed:0.031f green:0.259f blue:0.184f alpha:1.000f], + @\\"name\\": @\\"ColorFontSuccess\\", + @\\"category\\": @\\"color\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"success\\" + } + } + }, + @\\"size\\": @{ + @\\"border\\": @{ + @\\"radius\\": @{ + @\\"large\\": @{ + @\\"value\\": @480.00f, + @\\"name\\": @\\"SizeBorderRadiusLarge\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"border\\", + @\\"item\\": @\\"radius\\", + @\\"subitem\\": @\\"large\\" + } + } + }, + @\\"font\\": @{ + @\\"small\\": @{ + @\\"value\\": @12.00f, + @\\"name\\": @\\"SizeFontSmall\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"small\\" + }, + @\\"medium\\": @{ + @\\"value\\": @16.00f, + @\\"name\\": @\\"SizeFontMedium\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"medium\\" + }, + @\\"large\\": @{ + @\\"value\\": @24.00f, + @\\"name\\": @\\"SizeFontLarge\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"large\\" + }, + @\\"xl\\": @{ + @\\"value\\": @36.00f, + @\\"name\\": @\\"SizeFontXl\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"font\\", + @\\"item\\": @\\"xl\\" + } + }, + @\\"padding\\": @{ + @\\"small\\": @{ + @\\"value\\": @8.00f, + @\\"name\\": @\\"SizePaddingSmall\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"padding\\", + @\\"item\\": @\\"small\\" + }, + @\\"medium\\": @{ + @\\"value\\": @16.00f, + @\\"name\\": @\\"SizePaddingMedium\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"padding\\", + @\\"item\\": @\\"medium\\" + }, + @\\"large\\": @{ + @\\"value\\": @16.00f, + @\\"name\\": @\\"SizePaddingLarge\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"padding\\", + @\\"item\\": @\\"large\\" + }, + @\\"xl\\": @{ + @\\"value\\": @16.00f, + @\\"name\\": @\\"SizePaddingXl\\", + @\\"category\\": @\\"size\\", + @\\"type\\": @\\"padding\\", + @\\"item\\": @\\"xl\\" + } + } + } + }; + }); + + return dictionary; +} + +@end + + +" +`; + +exports[`integration ios objective-c ios/static.h should match snapshot 1`] = ` +" +// static.h +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import + + +extern CGFloat const SizeBorderRadiusLarge; +extern CGFloat const SizeFontSmall; +extern CGFloat const SizeFontMedium; +extern CGFloat const SizeFontLarge; +extern CGFloat const SizeFontXl; +extern CGFloat const SizePaddingSmall; +extern CGFloat const SizePaddingMedium; +extern CGFloat const SizePaddingLarge; +extern CGFloat const SizePaddingXl; +" +`; + +exports[`integration ios objective-c ios/static.m should match snapshot 1`] = ` +" +// +// static.m +// + +// Do not edit directly +// Generated on Sat, 01 Jan 2000 00:00:00 GMT + + +#import \\"StyleDictionaryStatic.h\\" + + +CGFloat const SizeBorderRadiusLarge = 480.00f; +CGFloat const SizeFontSmall = 12.00f; +CGFloat const SizeFontMedium = 16.00f; +CGFloat const SizeFontLarge = 24.00f; +CGFloat const SizeFontXl = 36.00f; +CGFloat const SizePaddingSmall = 8.00f; +CGFloat const SizePaddingMedium = 16.00f; +CGFloat const SizePaddingLarge = 16.00f; +CGFloat const SizePaddingXl = 16.00f; +" +`; diff --git a/__integration__/__snapshots__/scss.test.js.snap b/__integration__/__snapshots__/scss.test.js.snap index 03418d6a4..9ce614a4b 100644 --- a/__integration__/__snapshots__/scss.test.js.snap +++ b/__integration__/__snapshots__/scss.test.js.snap @@ -2,10 +2,11 @@ exports[`integration scss scss/map-deep should match snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $color-background-primary: #ffffff !default; $color-background-secondary: #f3f4f4 !default; @@ -391,10 +392,11 @@ $tokens: ( exports[`integration scss scss/map-flat should match snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $tokens: ( 'color-background-primary': #ffffff, diff --git a/__integration__/iOSObjectiveC.test.js b/__integration__/iOSObjectiveC.test.js new file mode 100644 index 000000000..f23afbc82 --- /dev/null +++ b/__integration__/iOSObjectiveC.test.js @@ -0,0 +1,103 @@ +/* + * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +const fs = require('fs-extra'); +const StyleDictionary = require('../index'); +const {buildPath} = require('./_constants'); + +describe('integration', () => { + describe('ios objective-c', () => { + StyleDictionary.extend({ + source: [`__integration__/tokens/**/*.json`], + platforms: { + flutter: { + transformGroup: `ios`, + buildPath, + files: [{ + destination: "singleton.m", + format: "ios/singleton.m", + className: "StyleDictionary" + },{ + destination: "singleton.h", + format: "ios/singleton.h", + className: "StyleDictionary" + },{ + destination: "color.h", + format: "ios/colors.h", + className: "StyleDictionaryColor", + filter: (token) => token.attributes.category === 'color' + },{ + destination: "color.m", + format: "ios/colors.m", + className: "StyleDictionaryColor", + filter: (token) => token.attributes.category === 'color' + },{ + destination: "macros.h", + format: "ios/macros", + },{ + destination: "static.h", + format: "ios/static.h", + className: "StyleDictionaryStatic", + type: "CGFloat", + filter: (token) => token.attributes.category === 'size' + },{ + destination: "static.m", + format: "ios/static.m", + className: "StyleDictionaryStatic", + type: "CGFloat", + filter: (token) => token.attributes.category === 'size' + }] + }, + } + }).buildAllPlatforms(); + + it(`ios/singleton.m should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}singleton.m`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/singleton.h should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}singleton.h`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/color.m should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}color.m`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/color.h should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}color.h`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/macros.h should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}macros.h`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/static.h should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}static.h`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + + it(`ios/static.m should match snapshot`, () => { + const output = fs.readFileSync(`${buildPath}static.m`, {encoding:`UTF-8`}); + expect(output).toMatchSnapshot(); + }); + }); +}); + +afterAll(() => { + fs.emptyDirSync(buildPath); +}); \ No newline at end of file diff --git a/__tests__/formats/__snapshots__/all.test.js.snap b/__tests__/formats/__snapshots__/all.test.js.snap index 2887c258f..84d5ee6bc 100644 --- a/__tests__/formats/__snapshots__/all.test.js.snap +++ b/__tests__/formats/__snapshots__/all.test.js.snap @@ -122,12 +122,12 @@ exports[`formats all should match ios/colors.h snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import +#import typedef NS_ENUM(NSInteger, ) { color_red @@ -145,12 +145,12 @@ exports[`formats all should match ios/colors.m snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import \\".h\\" +#import \\".h\\" @implementation @@ -180,15 +180,14 @@ exports[`formats all should match ios/macros snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// + #import #import - - #define color_red #FF0000 " @@ -226,9 +225,10 @@ exports[`formats all should match ios/singleton.h snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// + #import #import @@ -248,9 +248,10 @@ exports[`formats all should match ios/singleton.m snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// + #import \\".h\\" @@ -294,12 +295,12 @@ exports[`formats all should match ios/static.h snapshot 1`] = ` " // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import +#import extern const color_red; @@ -311,12 +312,12 @@ exports[`formats all should match ios/static.m snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import \\".h\\" +#import \\".h\\" const color_red = #FF0000; @@ -328,12 +329,12 @@ exports[`formats all should match ios/strings.h snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import +#import extern NSString * const color_red; @@ -349,12 +350,12 @@ exports[`formats all should match ios/strings.m snapshot 1`] = ` // // __output/ // + // Do not edit directly // Generated on Sat, 01 Jan 2000 00:00:00 GMT -// -#import \\".h\\" +#import \\".h\\" NSString * const color_red = #FF0000; @@ -597,10 +598,11 @@ exports[`formats all should match less/variables snapshot 1`] = ` exports[`formats all should match sass/map-deep snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $color_red: #FF0000 !default; // comment @@ -614,10 +616,11 @@ $tokens: ( exports[`formats all should match sass/map-flat snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $tokens: ( // comment @@ -636,10 +639,11 @@ exports[`formats all should match scss/icons snapshot 1`] = ` exports[`formats all should match scss/map-deep snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $color_red: #FF0000 !default; // comment @@ -653,10 +657,11 @@ $tokens: ( exports[`formats all should match scss/map-flat snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $tokens: ( // comment diff --git a/__tests__/formats/__snapshots__/scssMaps.test.js.snap b/__tests__/formats/__snapshots__/scssMaps.test.js.snap index 2c19142cf..c0a2e454e 100644 --- a/__tests__/formats/__snapshots__/scssMaps.test.js.snap +++ b/__tests__/formats/__snapshots__/scssMaps.test.js.snap @@ -2,10 +2,11 @@ exports[`formats scss/map-deep scss/map-deep snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $size-font-small: 12rem !default; $size-font-large: 18rem !default; @@ -37,10 +38,11 @@ $tokens: ( exports[`formats scss/map-flat scss/map-flat snapshot 1`] = ` " -/* - Do not edit directly - Generated on Sat, 01 Jan 2000 00:00:00 GMT -*/ +/** + * Do not edit directly + * Generated on Sat, 01 Jan 2000 00:00:00 GMT + */ + $tokens: ( 'size-font-small': 12rem, diff --git a/__tests__/formats/scssMaps.test.js b/__tests__/formats/scssMaps.test.js index 326eeb9b8..c4d9c2d1f 100644 --- a/__tests__/formats/scssMaps.test.js +++ b/__tests__/formats/scssMaps.test.js @@ -14,162 +14,71 @@ var formats = require('../../lib/common/formats'); var scss = require('node-sass'); var _ = require('../../lib/utils/es6_'); +var createDictionary = require('../../lib/utils/createDictionary'); +var createFormatArgs = require('../../lib/utils/createFormatArgs'); -var dictionary = { - "properties": { - "size": { - "font": { - "small": { - "value": "12rem", - "original": { - "value": "12px" - }, - "name": "size-font-small", - "attributes": { - "category": "size", - "type": "font", - "item": "small" - }, - "path": [ - "size", - "font", - "small" - ] +var properties = { + "size": { + "font": { + "small": { + "value": "12rem", + "original": { + "value": "12px" }, - "large": { - "value": "18rem", - "original": { - "value": "18px" - }, - "name": "size-font-large", - "attributes": { - "category": "size", - "type": "font", - "item": "large" - }, - "path": [ - "size", - "font", - "large" - ] - } - } - }, - "color": { - "base": { - "red": { - "value": "#ff0000", - "comment": "comment", - "original": { - "value": "#FF0000", - "comment": "comment" - }, - "name": "color-base-red", - "attributes": { - "category": "color", - "type": "base", - "item": "red" - }, - "path": [ - "color", - "base", - "red" - ] - } + "name": "size-font-small", + "attributes": { + "category": "size", + "type": "font", + "item": "small" + }, + "path": [ + "size", + "font", + "small" + ] }, - "white": { - "value": "#ffffff", + "large": { + "value": "18rem", "original": { - "value": "#ffffff" + "value": "18px" }, - "name": "color-white", + "name": "size-font-large", "attributes": { - "category": "color", - "type": "white" + "category": "size", + "type": "font", + "item": "large" }, "path": [ - "color", - "white" + "size", + "font", + "large" ] } - }, - "asset": { - "icon": { - "book": { - "value": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItYm9vayI+PHBhdGggZD0iTTQgMTkuNUEyLjUgMi41IDAgMCAxIDYuNSAxN0gyMCI+PC9wYXRoPjxwYXRoIGQ9Ik02LjUgMkgyMHYyMEg2LjVBMi41IDIuNSAwIDAgMSA0IDE5LjV2LTE1QTIuNSAyLjUgMCAwIDEgNi41IDJ6Ij48L3BhdGg+PC9zdmc+", - "original": { - "value": "./test/__assets/icons/book.svg" - }, - "name": "asset-icon-book", - "attributes": { - "category": "asset", - "type": "icon", - "item": "book" - }, - "path": [ - "asset", - "icon", - "book" - ] - } - } } }, - "allProperties": [ - { - "value": "12rem", - "original": { - "value": "12px" - }, - "name": "size-font-small", - "attributes": { - "category": "size", - "type": "font", - "item": "small" - }, - "path": [ - "size", - "font", - "small" - ] - }, - { - "value": "18rem", - "original": { - "value": "18px" - }, - "name": "size-font-large", - "attributes": { - "category": "size", - "type": "font", - "item": "large" - }, - "path": [ - "size", - "font", - "large" - ] - }, - { - "value": "#ff0000", - "comment": "comment", - "original": { - "value": "#FF0000", - "comment": "comment" - }, - "name": "color-base-red", - "attributes": { - "category": "color", - "type": "base", - "item": "red" - }, - "path": [ - "color", - "base", - "red" - ] + "color": { + "base": { + "red": { + "value": "#ff0000", + "comment": "comment", + "original": { + "value": "#FF0000", + "comment": "comment" + }, + "name": "color-base-red", + "attributes": { + "category": "color", + "type": "base", + "item": "red" + }, + "path": [ + "color", + "base", + "red" + ] + } }, - { + "white": { "value": "#ffffff", "original": { "value": "#ffffff" @@ -183,25 +92,29 @@ var dictionary = { "color", "white" ] - }, - { - "value": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItYm9vayI+PHBhdGggZD0iTTQgMTkuNUEyLjUgMi41IDAgMCAxIDYuNSAxN0gyMCI+PC9wYXRoPjxwYXRoIGQ9Ik02LjUgMkgyMHYyMEg2LjVBMi41IDIuNSAwIDAgMSA0IDE5LjV2LTE1QTIuNSAyLjUgMCAwIDEgNi41IDJ6Ij48L3BhdGg+PC9zdmc+", - "original": { - "value": "./test/__assets/icons/book.svg" - }, - "name": "asset-icon-book", - "attributes": { - "category": "asset", - "type": "icon", - "item": "book" - }, - "path": [ - "asset", - "icon", - "book" - ] } - ] + }, + "asset": { + "icon": { + "book": { + "value": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItYm9vayI+PHBhdGggZD0iTTQgMTkuNUEyLjUgMi41IDAgMCAxIDYuNSAxN0gyMCI+PC9wYXRoPjxwYXRoIGQ9Ik02LjUgMkgyMHYyMEg2LjVBMi41IDIuNSAwIDAgMSA0IDE5LjV2LTE1QTIuNSAyLjUgMCAwIDEgNi41IDJ6Ij48L3BhdGg+PC9zdmc+", + "original": { + "value": "./test/__assets/icons/book.svg" + }, + "name": "asset-icon-book", + "attributes": { + "category": "asset", + "type": "icon", + "item": "book" + }, + "path": [ + "asset", + "icon", + "book" + ] + } + } + } }; describe('formats', () => { @@ -215,7 +128,12 @@ describe('formats', () => { }; var formatter = formats[key].bind(file); - var output = formatter(dictionary, {}, file); + const dictionary = createDictionary({ properties }); + var output = formatter(createFormatArgs({ + dictionary, + file, + platform: {}, + }), {}, file); it('should return ' + key + ' as a string', () => { expect(typeof output).toBe('string'); diff --git a/lib/common/formats.js b/lib/common/formats.js index bedd9063d..f5af13409 100644 --- a/lib/common/formats.js +++ b/lib/common/formats.js @@ -63,18 +63,16 @@ module.exports = { * ) * ``` */ - 'scss/map-flat': _.template( - fs.readFileSync(__dirname + '/templates/scss/map-flat.template') - ), + 'scss/map-flat': function({dictionary, options, file}) { + const template = _.template(fs.readFileSync(__dirname + '/templates/scss/map-flat.template')); + const { allProperties } = dictionary; + return template({allProperties, file, options, fileHeader}); + }, // This will soon be removed, is left here only for backwards compatibility - 'sass/map-flat': function({dictionary, options}) { + 'sass/map-flat': function({dictionary, options, file}) { GroupMessages.add(SASS_MAP_FORMAT_DEPRECATION_WARNINGS, "sass/map-flat"); - const templateMapFlat = _.template(fs.readFileSync(__dirname + '/templates/scss/map-flat.template')); - return templateMapFlat({ - showFileHeader: options.showFileHeader, - allProperties: dictionary.allProperties - }); + return module.exports['scss/map-flat']({dictionary, options, file}); }, /** @@ -99,19 +97,15 @@ module.exports = { * ) * ``` */ - 'scss/map-deep': _.template( - fs.readFileSync(__dirname + '/templates/scss/map-deep.template') - ), + 'scss/map-deep': function({dictionary, options, file}) { + const template = _.template(fs.readFileSync(__dirname + '/templates/scss/map-deep.template')); + return template({dictionary, file, options, fileHeader}); + }, // This will soon be removed, is left here only for backwards compatibility - 'sass/map-deep': function({dictionary, options}) { + 'sass/map-deep': function({dictionary, options, file}) { GroupMessages.add(SASS_MAP_FORMAT_DEPRECATION_WARNINGS, "sass/map-deep"); - const templateMapDeep = _.template(fs.readFileSync(__dirname + '/templates/scss/map-deep.template')); - return templateMapDeep({ - showFileHeader: options.showFileHeader, - properties: dictionary.properties, - allProperties: dictionary.allProperties - }); + return module.exports['scss/map-deep']({dictionary, options, file}); }, /** @@ -570,9 +564,13 @@ module.exports = { * #define SizeFontTiny 176.00f * ``` */ - 'ios/macros': _.template( - fs.readFileSync(__dirname + '/templates/ios/macros.template') - ), + 'ios/macros': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/macros.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C plist file @@ -581,9 +579,13 @@ module.exports = { * @kind member * @todo Fix this template and add example and usage */ - 'ios/plist': _.template( - fs.readFileSync(__dirname + '/templates/ios/plist.template') - ), + 'ios/plist': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/plist.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C implementation file of a style dictionary singleton class @@ -592,9 +594,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/singleton.m': _.template( - fs.readFileSync(__dirname + '/templates/ios/singleton.m.template') - ), + 'ios/singleton.m': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/singleton.m.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C header file of a style dictionary singleton class @@ -603,9 +609,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/singleton.h': _.template( - fs.readFileSync(__dirname + '/templates/ios/singleton.h.template') - ), + 'ios/singleton.h': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/singleton.h.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C header file of a static style dictionary class @@ -614,9 +624,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/static.h': _.template( - fs.readFileSync(__dirname + '/templates/ios/static.h.template') - ), + 'ios/static.h': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/static.h.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C implementation file of a static style dictionary class @@ -625,9 +639,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/static.m': _.template( - fs.readFileSync(__dirname + '/templates/ios/static.m.template') - ), + 'ios/static.m': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/static.m.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C header file of a color class @@ -636,9 +654,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/colors.h': _.template( - fs.readFileSync(__dirname + '/templates/ios/colors.h.template') - ), + 'ios/colors.h': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/colors.h.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C implementation file of a color class @@ -647,9 +669,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/colors.m': _.template( - fs.readFileSync(__dirname + '/templates/ios/colors.m.template') - ), + 'ios/colors.m': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/colors.m.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C header file of strings @@ -658,9 +684,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/strings.h': _.template( - fs.readFileSync(__dirname + '/templates/ios/strings.h.template') - ), + 'ios/strings.h': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/strings.h.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates an Objective-C implementation file of strings @@ -669,9 +699,13 @@ module.exports = { * @kind member * @todo Add example and usage */ - 'ios/strings.m': _.template( - fs.readFileSync(__dirname + '/templates/ios/strings.m.template') - ), + 'ios/strings.m': function({dictionary, options, file}) { + const template = _.template( + fs.readFileSync(__dirname + '/templates/ios/strings.m.template') + ); + + return template({ dictionary, options, file, fileHeader }); + }, /** * Creates a Swift implementation file of a class with values diff --git a/lib/common/templates/ios/colors.h.template b/lib/common/templates/ios/colors.h.template index 7fb0c89b3..31bd6ab2a 100644 --- a/lib/common/templates/ios/colors.h.template +++ b/lib/common/templates/ios/colors.h.template @@ -14,26 +14,16 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - +<%= fileHeader({file, commentStyle: 'short'}) %> #import -<% var props = _.filter(allProperties, this.filter); %> typedef NS_ENUM(NSInteger, <%= this.type %>) { -<%= props.map(function(prop) { return prop.name; }).join(',\n') %> +<%= dictionary.allProperties.map(function(prop) { return prop.name; }).join(',\n') %> }; -@interface <%= this.className %> : NSObject +@interface <%= file.className %> : NSObject + (NSArray *)values; -+ (UIColor *)color:(<%= this.type %>)color; ++ (UIColor *)color:(<%= file.type %>)color; @end diff --git a/lib/common/templates/ios/colors.m.template b/lib/common/templates/ios/colors.m.template index aac9f3c03..07dc35393 100644 --- a/lib/common/templates/ios/colors.m.template +++ b/lib/common/templates/ios/colors.m.template @@ -14,24 +14,14 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - -#import "<%= this.className %>.h" -<% var props = _.filter(allProperties, this.filter); %> +<%= fileHeader({file, commentStyle: 'short'}) %> +#import "<%= file.className %>.h" -@implementation <%= this.className %> +@implementation <%= file.className %> -+ (UIColor *)color:(<%= this.type %>)colorEnum{ ++ (UIColor *)color:(<%= file.type %>)colorEnum{ return [[self values] objectAtIndex:colorEnum]; } @@ -41,7 +31,7 @@ dispatch_once(&onceToken, ^{ colorArray = @[ -<%= props.map(function(prop){ return prop.value; }).join(',\n') %> +<%= dictionary.allProperties.map(function(prop){ return prop.value; }).join(',\n') %> ]; }); diff --git a/lib/common/templates/ios/macros.template b/lib/common/templates/ios/macros.template index 277a8bfcc..7c73a766b 100644 --- a/lib/common/templates/ios/macros.template +++ b/lib/common/templates/ios/macros.template @@ -14,23 +14,12 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - +<%= fileHeader({file, commentStyle: 'short'}) %> #import #import -<% var props = _.filter(allProperties, this.filter); %> - -<% _.each(props, function(prop) { +<% dictionary.allProperties.forEach(function(prop) { %>#define <%= prop.name %> <%= prop.value %> <% }); %> diff --git a/lib/common/templates/ios/plist.template b/lib/common/templates/ios/plist.template index 9836d2e8a..afb2c66fc 100644 --- a/lib/common/templates/ios/plist.template +++ b/lib/common/templates/ios/plist.template @@ -13,7 +13,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -var props = _.filter(allProperties, function(prop) { +var props = dictionary.allProperties.filter(function(prop) { return prop.attributes.category !== 'asset' && prop.attributes.category !== 'border' && prop.attributes.category !== 'shadow' && @@ -21,18 +21,10 @@ var props = _.filter(allProperties, function(prop) { }); %> -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print(""); - } -%> +<%= fileHeader({ file, commentStyle: 'xml' }) %> - <% _.each(props, function(prop) { + <% props.forEach(function(prop) { %><%= prop.name %> <% if (prop.attributes.category === 'color') { %> r diff --git a/lib/common/templates/ios/singleton.h.template b/lib/common/templates/ios/singleton.h.template index f31abae0f..96aa45deb 100644 --- a/lib/common/templates/ios/singleton.h.template +++ b/lib/common/templates/ios/singleton.h.template @@ -14,22 +14,13 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - +<%= fileHeader({ file, commentStyle: 'short' })%> #import #import -@interface <%= this.className %> : NSObject +@interface <%= file.className %> : NSObject + (NSDictionary *)properties; + (NSDictionary *)getProperty:(NSString *)keyPath; diff --git a/lib/common/templates/ios/singleton.m.template b/lib/common/templates/ios/singleton.m.template index de939fa5f..d68ceb1c6 100644 --- a/lib/common/templates/ios/singleton.m.template +++ b/lib/common/templates/ios/singleton.m.template @@ -14,21 +14,12 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - -#import "<%= this.className %>.h" +<%= fileHeader({ file, commentStyle: 'short' })%> +#import "<%= file.className %>.h" -@implementation <%= this.className %> +@implementation <%= file.className %> + (NSDictionary *)getProperty:(NSString *)keyPath { return [[self properties] valueForKeyPath:keyPath]; @@ -43,7 +34,7 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - dictionary = <%= buildDictionary(properties) %>; + dictionary = <%= buildDictionary(dictionary.properties) %>; }); return dictionary; diff --git a/lib/common/templates/ios/static.h.template b/lib/common/templates/ios/static.h.template index 1862bea5a..d5240ac65 100644 --- a/lib/common/templates/ios/static.h.template +++ b/lib/common/templates/ios/static.h.template @@ -14,21 +14,10 @@ // permissions and limitations under the License. // %> -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - +<%= fileHeader({ file, commentStyle: 'short' })%> #import -<% var props = _.filter(allProperties, this.filter); - var type = this.type; %> -<% _.each(props, function(prop) { %> -extern <%= type %> const <%= prop.name %>;<% }); %> +<% dictionary.allProperties.forEach(function(prop) { %> +extern <%= file.type %> const <%= prop.name %>;<% }); %> diff --git a/lib/common/templates/ios/static.m.template b/lib/common/templates/ios/static.m.template index e3113bf32..94cf20a17 100644 --- a/lib/common/templates/ios/static.m.template +++ b/lib/common/templates/ios/static.m.template @@ -14,21 +14,10 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - -#import "<%= this.className %>.h" -<% var props = _.filter(allProperties, this.filter); - var type = this.type; %> +<%= fileHeader({ file, commentStyle: 'short' }) %> +#import "<%= file.className %>.h" -<% _.each(props, function(prop) { %> -<%= type %> const <%= prop.name %> = <%= prop.value %>;<% }); %> +<% dictionary.allProperties.forEach(function(prop) { %> +<%= file.type %> const <%= prop.name %> = <%= prop.value %>;<% }); %> diff --git a/lib/common/templates/ios/strings.h.template b/lib/common/templates/ios/strings.h.template index 8c0bc0a27..73179d125 100644 --- a/lib/common/templates/ios/strings.h.template +++ b/lib/common/templates/ios/strings.h.template @@ -14,24 +14,14 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - +<%= fileHeader({ file, commentStyle: 'short' })%> #import -<% var props = _.filter(allProperties, this.filter); %> -<% _.each(props, function(prop) { %> +<% dictionary.allProperties.forEach(function(prop) { %> extern NSString * const <%= prop.name %>;<% }); %> -@interface <%= this.className %> : NSObject +@interface <%= file.className %> : NSObject + (NSArray *)values; @end diff --git a/lib/common/templates/ios/strings.m.template b/lib/common/templates/ios/strings.m.template index 59bd5112d..3da68d46b 100644 --- a/lib/common/templates/ios/strings.m.template +++ b/lib/common/templates/ios/strings.m.template @@ -14,25 +14,15 @@ // permissions and limitations under the License. %> // -// <%= this.destination %> +// <%= file.destination %> // -<% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - print("// Do not edit directly\n"); - print("// Generated on " + new Date().toUTCString()); - } -%> -// - -#import "<%= this.className %>.h" -<% var props = _.filter(allProperties, this.filter); %> +<%= fileHeader({ file, commentStyle: 'short' }) %> +#import "<%= file.className %>.h" -<% _.each(props, function(prop) { %> +<% dictionary.allProperties.forEach(function(prop) { %> NSString * const <%= prop.name %> = <%= prop.value %>;<% }); %> -@implementation <%= this.className %> +@implementation <%= file.className %> + (NSArray *)values { static NSArray* array; @@ -40,7 +30,7 @@ NSString * const <%= prop.name %> = <%= prop.value %>;<% }); %> dispatch_once(&onceToken, ^{ array = @[ - <%= props.map(buildProperty).join(',\n') %> + <%= dictionary.allProperties.map(buildProperty).join(',\n') %> ]; }); diff --git a/lib/common/templates/scss/map-deep.template b/lib/common/templates/scss/map-deep.template index 1b6728ff7..7466a9898 100644 --- a/lib/common/templates/scss/map-deep.template +++ b/lib/common/templates/scss/map-deep.template @@ -12,24 +12,12 @@ // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. - %> +<%= fileHeader({file, commentStyle: 'long'}) %> <% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - var header = ''; - header += "/*\n Do not edit directly"; - header += "\n Generated on " + new Date().toUTCString(); - header += "\n*/\n"; - print(header); - } - - print("\n"); - // output the list of tokens as Sass variables // - _.each(allProperties, function(prop) { + _.each(dictionary.allProperties, function(prop) { var output = ''; output += '$' + prop.name + ': ' + (prop.attributes.category==='asset' ? '"'+prop.value+'"' : prop.value) + ' !default;' if(prop.comment) { @@ -44,7 +32,7 @@ // output the list of tokens as a Sass nested map // (the values are pointing to the variables) // - print(`$${this.mapName||'tokens'}: ${processJsonNode(properties, 0)};\n`); + print(`$${this.mapName||'tokens'}: ${processJsonNode(dictionary.properties, 0)};\n`); // recursive function to process a properties JSON node // diff --git a/lib/common/templates/scss/map-flat.template b/lib/common/templates/scss/map-flat.template index 5b58c11e5..3131c8b7c 100644 --- a/lib/common/templates/scss/map-flat.template +++ b/lib/common/templates/scss/map-flat.template @@ -14,19 +14,8 @@ // permissions and limitations under the License. %> +<%= fileHeader({file, commentStyle: 'long'}) %> <% - // for backward compatibility we need to have the user explicitly hide it - var showFileHeader = (this.options && this.options.hasOwnProperty('showFileHeader')) ? this.options.showFileHeader : true; - if(showFileHeader) { - var header = ''; - header += "/*\n Do not edit directly"; - header += "\n Generated on " + new Date().toUTCString(); - header += "\n*/\n"; - print(header); - } - - print('\n'); - var output = ''; output += `$${this.mapName||'tokens'}: (\n`; output += allProperties.map(function(prop){ From 06602d193af2d23c479494645929afbdaf17bf8e Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Mon, 5 Apr 2021 16:24:25 -0700 Subject: [PATCH 6/6] chore(formats): cleaning up empty lines --- __integration__/__snapshots__/scss.test.js.snap | 2 -- __integration__/__snapshots__/swift.test.js.snap | 2 -- __tests__/formats/__snapshots__/all.test.js.snap | 6 ------ __tests__/formats/__snapshots__/scssMaps.test.js.snap | 2 -- lib/common/templates/ios-swift/class.swift.template | 1 - lib/common/templates/ios-swift/enum.swift.template | 1 - lib/common/templates/scss/map-deep.template | 3 +-- lib/common/templates/scss/map-flat.template | 3 +-- 8 files changed, 2 insertions(+), 18 deletions(-) diff --git a/__integration__/__snapshots__/scss.test.js.snap b/__integration__/__snapshots__/scss.test.js.snap index 9ce614a4b..c3aa44265 100644 --- a/__integration__/__snapshots__/scss.test.js.snap +++ b/__integration__/__snapshots__/scss.test.js.snap @@ -7,7 +7,6 @@ exports[`integration scss scss/map-deep should match snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $color-background-primary: #ffffff !default; $color-background-secondary: #f3f4f4 !default; $color-background-tertiary: #dee1e1 !default; @@ -397,7 +396,6 @@ exports[`integration scss scss/map-flat should match snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $tokens: ( 'color-background-primary': #ffffff, 'color-background-secondary': #f3f4f4, diff --git a/__integration__/__snapshots__/swift.test.js.snap b/__integration__/__snapshots__/swift.test.js.snap index b8ea9695d..6751f8fb6 100644 --- a/__integration__/__snapshots__/swift.test.js.snap +++ b/__integration__/__snapshots__/swift.test.js.snap @@ -10,7 +10,6 @@ exports[`integration swift ios-swift/class.swift should match snapshot 1`] = ` // Generated on Sat, 01 Jan 2000 00:00:00 GMT - import UIKit public class StyleDictionary { @@ -190,7 +189,6 @@ exports[`integration swift ios-swift/class.swift with references should match sn // Generated on Sat, 01 Jan 2000 00:00:00 GMT - import UIKit public class StyleDictionary { diff --git a/__tests__/formats/__snapshots__/all.test.js.snap b/__tests__/formats/__snapshots__/all.test.js.snap index 84d5ee6bc..c96ac0fa0 100644 --- a/__tests__/formats/__snapshots__/all.test.js.snap +++ b/__tests__/formats/__snapshots__/all.test.js.snap @@ -396,7 +396,6 @@ exports[`formats all should match ios-swift/class.swift snapshot 1`] = ` // Generated on Sat, 01 Jan 2000 00:00:00 GMT - import UIKit public class { @@ -415,7 +414,6 @@ exports[`formats all should match ios-swift/enum.swift snapshot 1`] = ` // Generated on Sat, 01 Jan 2000 00:00:00 GMT - import UIKit public enum { @@ -603,7 +601,6 @@ exports[`formats all should match sass/map-deep snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $color_red: #FF0000 !default; // comment $tokens: ( @@ -621,7 +618,6 @@ exports[`formats all should match sass/map-flat snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $tokens: ( // comment 'color_red': #FF0000 @@ -644,7 +640,6 @@ exports[`formats all should match scss/map-deep snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $color_red: #FF0000 !default; // comment $tokens: ( @@ -662,7 +657,6 @@ exports[`formats all should match scss/map-flat snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $tokens: ( // comment 'color_red': #FF0000 diff --git a/__tests__/formats/__snapshots__/scssMaps.test.js.snap b/__tests__/formats/__snapshots__/scssMaps.test.js.snap index c0a2e454e..8a24215f5 100644 --- a/__tests__/formats/__snapshots__/scssMaps.test.js.snap +++ b/__tests__/formats/__snapshots__/scssMaps.test.js.snap @@ -7,7 +7,6 @@ exports[`formats scss/map-deep scss/map-deep snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $size-font-small: 12rem !default; $size-font-large: 18rem !default; $color-base-red: #ff0000 !default; // comment @@ -43,7 +42,6 @@ exports[`formats scss/map-flat scss/map-flat snapshot 1`] = ` * Generated on Sat, 01 Jan 2000 00:00:00 GMT */ - $tokens: ( 'size-font-small': 12rem, 'size-font-large': 18rem, diff --git a/lib/common/templates/ios-swift/class.swift.template b/lib/common/templates/ios-swift/class.swift.template index fbf9680dc..8bdc5f2e8 100644 --- a/lib/common/templates/ios-swift/class.swift.template +++ b/lib/common/templates/ios-swift/class.swift.template @@ -17,7 +17,6 @@ // <%= file.destination %> // <%= fileHeader({file, commentStyle: 'short'}) %> - import UIKit public class <%= file.className %> { diff --git a/lib/common/templates/ios-swift/enum.swift.template b/lib/common/templates/ios-swift/enum.swift.template index f5b67a4a4..d6ab961a6 100644 --- a/lib/common/templates/ios-swift/enum.swift.template +++ b/lib/common/templates/ios-swift/enum.swift.template @@ -17,7 +17,6 @@ // <%= file.destination %> // <%= fileHeader({file, commentStyle: 'short'}) %> - import UIKit public enum <%= file.className %> { diff --git a/lib/common/templates/scss/map-deep.template b/lib/common/templates/scss/map-deep.template index 7466a9898..6da9ed691 100644 --- a/lib/common/templates/scss/map-deep.template +++ b/lib/common/templates/scss/map-deep.template @@ -13,8 +13,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. %> -<%= fileHeader({file, commentStyle: 'long'}) %> -<% +<%= fileHeader({file, commentStyle: 'long'}) %><% // output the list of tokens as Sass variables // _.each(dictionary.allProperties, function(prop) { diff --git a/lib/common/templates/scss/map-flat.template b/lib/common/templates/scss/map-flat.template index 3131c8b7c..a2ec07810 100644 --- a/lib/common/templates/scss/map-flat.template +++ b/lib/common/templates/scss/map-flat.template @@ -14,8 +14,7 @@ // permissions and limitations under the License. %> -<%= fileHeader({file, commentStyle: 'long'}) %> -<% +<%= fileHeader({file, commentStyle: 'long'}) %><% var output = ''; output += `$${this.mapName||'tokens'}: (\n`; output += allProperties.map(function(prop){