-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from CMSgov/staging
v1.0.0-alpha.2
- Loading branch information
Showing
228 changed files
with
6,846 additions
and
4,157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ module.exports = (gulp) => { | |
return runSequence( | ||
[ | ||
'sass', | ||
'javascript', | ||
'fonts' | ||
], | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const _ = require('lodash'); | ||
const nestSections = require('../nestSections'); | ||
|
||
const sections = [ | ||
{ | ||
reference: 'components', | ||
sections: [] | ||
}, { | ||
reference: 'components.buttons', | ||
sections: [] | ||
}, { | ||
reference: 'components.buttons.primary', | ||
sections: [] | ||
}, { | ||
reference: 'utilities', | ||
sections: [] | ||
}, { | ||
reference: 'utilities.colors', | ||
sections: [] | ||
}, { | ||
reference: 'home', | ||
sections: [] | ||
} | ||
]; | ||
|
||
describe('nestSections', () => { | ||
it('nests children within parent section', () => { | ||
return nestSections(sections) | ||
.then(nestedSections => { | ||
let components = _.find(nestedSections, { | ||
reference: 'components' | ||
}); | ||
|
||
expect(components.sections[0].reference) | ||
.toEqual('components.buttons'); | ||
expect(components.sections[0].sections[0].reference) | ||
.toEqual('components.buttons.primary'); | ||
expect(nestedSections.length) | ||
.toEqual(3); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
const processSection = require('../processSection'); | ||
|
||
describe('processSection', () => { | ||
let section = reference => { | ||
return { | ||
toJSON: () => ( | ||
{ | ||
description: '<p>Hello world</p><p>@react-component</p><p>@hide-markup</p><p>@status prototype</p>', | ||
markup: '<% var foo="bar" %><%= foo %>', | ||
modifiers: [{ | ||
name: '.primary', | ||
description: 'The primary action', | ||
className: '' | ||
}], | ||
parameters: [], | ||
reference: reference | ||
} | ||
) | ||
}; | ||
}; | ||
|
||
let data; | ||
|
||
beforeAll(() => { | ||
data = processSection(section()); | ||
}); | ||
|
||
it('sets and replaces flags', () => { | ||
expect(data.hasReactComponent).toEqual(true); | ||
expect(data.hideMarkup).toEqual(true); | ||
expect(data.status).toEqual('prototype'); | ||
expect(data.description).toEqual('<p>Hello world</p>'); | ||
}); | ||
|
||
it('renders EJS', () => { | ||
expect(data.markup).toEqual('bar'); | ||
}); | ||
|
||
it('adds a sections property', () => { | ||
expect(data.sections).toEqual(expect.any(Array)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const _ = require('lodash'); | ||
|
||
/** | ||
* Each KSS section has a reference property which we can use to determine | ||
* which sections are parent sections vs. a child section. For example: | ||
* "components.buttons" would belong in "components". | ||
* @param {Array} sections - KssSection | ||
* @return {Promise<Array>} | ||
*/ | ||
module.exports = (sections) => { | ||
sections = sections | ||
.concat([]) // don't mutate original array | ||
.map(setParentReference) | ||
.map((section, index) => { | ||
if (section.parentReference) { | ||
let parent = _.find(sections, { | ||
reference: section.parentReference | ||
}); | ||
|
||
if (parent) parent.sections.push(section); | ||
} | ||
return section; | ||
}) | ||
.filter(section => !section.parentReference); | ||
|
||
return Promise.resolve(sections); | ||
}; | ||
|
||
// Goes up a reference level to find and set the parent reference | ||
// @example components.buttons.primary => components.buttons | ||
function setParentReference(section) { | ||
const references = section.reference.split('.'); | ||
if (references.length > 1) { | ||
references.pop(); | ||
section.parentReference = references.join('.'); | ||
} else { | ||
section.parentReference = null; | ||
} | ||
|
||
return section; | ||
} |
Oops, something went wrong.