Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

looking for config.js if config.json is not found; updating docs #247

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d2e4fb1
Merge pull request #131 from amzn/master
chazzmoney Sep 7, 2018
564e892
improved error messages for registerTemplate
didoo Sep 19, 2018
7d15280
updated error message
didoo Sep 20, 2018
ff8d452
Introduce option to control the generation of the "Do not edit" heade…
didoo Sep 28, 2018
cd45a2b
removing the confusing static-style-guide stuff (#157)
chazzmoney Oct 5, 2018
4aedd89
handle no command and invalid commands with friendly console output (…
chazzmoney Oct 5, 2018
acfee69
Add json5 support (#165)
vvscode Oct 17, 2018
aa19668
Removing unnecessary backticks (#172)
dbanksdesign Oct 18, 2018
15c876d
Merge Jest Branch (#169)
chazzmoney Oct 19, 2018
83fc888
feat(json-nested): Add JSON nested transform (#167)
davixyz Oct 23, 2018
f5c0486
Fix errors and improve error messaging (#158)
chazzmoney Oct 24, 2018
071c6a5
Deprecating templates (#152)
chazzmoney Nov 1, 2018
666a3d5
Porting over a stragler test (#190)
dbanksdesign Nov 2, 2018
54a53c7
Merging master into develop
dbanksdesign Nov 2, 2018
96c1273
2.5.0
dbanksdesign Nov 2, 2018
5ad6475
Added 'json/flat' format (#192)
didoo Nov 6, 2018
3a865f6
Fix: #195 (#196)
dbanksdesign Nov 9, 2018
b88b4b4
updating contributing to reflect the package manager and testing suit…
chazzmoney Nov 9, 2018
d80cbb3
Add Sass maps formats (#193)
didoo Nov 16, 2018
5095ac4
Better examples (#164)
didoo Nov 30, 2018
13479c4
New cut at documentation PR using current develop branch (#198)
chazzmoney Nov 30, 2018
e9f1a57
Configuration doc update
Nov 30, 2018
aa7b1f6
resolving merge conflicts
Nov 30, 2018
1896f48
fixing snapshot whitespace issues, discovered actual failing test on …
Nov 30, 2018
ca4cf5f
Fixing merge conflict issues
dbanksdesign Nov 30, 2018
5ca2acb
v2.6.0 release (#210)
dbanksdesign Dec 1, 2018
14e4b0f
moved the snapshot tests for the “all” formats to its own declaration…
didoo Jan 2, 2019
ab28dab
Add registerFilter method (#233)
didoo Jan 29, 2019
5a5a260
Remove registerTemplate from examples (#232)
didoo Jan 29, 2019
25b77cf
feat: Add node example (#228)
dbanksdesign Jan 29, 2019
41c9f27
feat: Making include accept an array of globs, like source does (#227)
dbanksdesign Jan 29, 2019
37006d9
fixed the naming for Sass/Scss in documentation, tests, formats (#222)
didoo Jan 30, 2019
7931791
fix: handle showFileHeader option in adroids formats templates (#243)
gael-boyenval Feb 4, 2019
6c9a78b
Merging master into develop
dbanksdesign Feb 5, 2019
c070300
looking for config.js if config.json is not found; updating documenta…
Feb 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ While not exactly necessary, we feel this classification structure of style prop

Structuring style properties in this manner gives us consistent naming and accessing of these properties. You don't need to remember if it is button_color_error or error_button_color, it is color_background_button_error!

Technically, you can organize and name your style properties however you want, there are no restrictions. But we have a good amount of helpers if you do use this structure, like the 'attribute/cti' transform which adds attributes to the property of its CTI based on the path in the object. There are a lot of name transforms as well for when you want a flat structure like for sass variables.
Technically, you can organize and name your style properties however you want, there are no restrictions. But we have a good amount of helpers if you do use this structure, like the 'attribute/cti' transform which adds attributes to the property of its CTI based on the path in the object. There are a lot of name transforms as well for when you want a flat structure like for Sass variables.

Also, the CTI structure provides a good mechanism to target transforms for specific kinds of properties. All of the transforms provided by the framework use the CTI of a property to know if it should be applied. For instance, the 'color/hex' transform only applies to properties of the category 'color'.

Expand Down
40 changes: 32 additions & 8 deletions __tests__/extend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,33 @@ describe('extend', () => {
).toThrow('include must be an array');
});

it('should throw if a path in the includes array doesnt resolve', () => {
expect(
StyleDictionary.extend.bind(null, {include: ['foo']})
).toThrow("Cannot find module 'foo'");
it('should not update properties if include glob paths dont resolve to anything', () => {
var StyleDictionaryExtended = StyleDictionary.extend({
include: ['foo']
});
expect(typeof StyleDictionaryExtended.properties.size).toBe('undefined');
});

it('should properly glob paths', () => {
var StyleDictionaryExtended = StyleDictionary.extend({
include: [__dirname + '/__properties/*.json']
});
expect(typeof StyleDictionaryExtended.properties.size.padding.tiny).toBe('object');
});

it('should build the properties object if an include is given', () => {
var StyleDictionaryExtended = StyleDictionary.extend({
"include": [__dirname + "/__properties/paddings.json"]
});
expect(StyleDictionaryExtended.properties).toEqual(helpers.fileToJSON(__dirname + "/__properties/paddings.json"));
});

it('should override existing properties if include is given', () => {
var StyleDictionaryExtended = StyleDictionary.extend({
properties: test_props,
include: [__dirname + "/__properties/paddings.json"]
});
expect(StyleDictionaryExtended.properties).toEqual(helpers.fileToJSON(__dirname + "/__properties/paddings.json"));
});

it('should update properties if there are includes', () => {
Expand All @@ -91,10 +114,11 @@ describe('extend', () => {
).toThrow('source must be an array');
});

it('should throw if a path in the source array doesnt resolve', () => {
expect(
StyleDictionary.extend.bind(null, {include: ['foo']})
).toThrow("Cannot find module 'foo'");
it('should not update properties if source glob paths don\'t resolve to anything', () => {
var StyleDictionaryExtended = StyleDictionary.extend({
source: ['foo']
});
expect(typeof StyleDictionaryExtended.properties.size).toBe('undefined');
});

it('should build the properties object if a source is given', () => {
Expand Down
25 changes: 15 additions & 10 deletions __tests__/filterProperties.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,21 @@ describe('filterProperties', () => {
expect(filteredDictionary.properties).not.toHaveProperty('color');
});

it('should work with a filter object', () => {
var filter = { "attributes": { "category": "size" } };
var filteredDictionary = filterProperties(dictionary, filter);
_.each(filteredDictionary.allProperties, function(property) {
expect(property).not.toBe(colorRed);
expect(property).not.toBe(colorBlue);
describe('should throw if', () => {
it('filter is a string', () => {
expect(
function(){
filterProperties(dictionary, 'my_filter')
}
).toThrow(/filter is not a function/);
});
it('filter is an object', () => {
expect(
function(){
filterProperties(dictionary, { "attributes": { "category": "size" } })
}
).toThrow(/filter is not a function/);
});
expect(filteredDictionary.allProperties).toEqual([sizeSmall, sizeLarge]);
expect(filteredDictionary.properties).toHaveProperty('size');
expect(filteredDictionary.properties).not.toHaveProperty('color');

});

});
Loading