forked from expressjs/generator
-
Notifications
You must be signed in to change notification settings - Fork 0
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 expressjs#78 from vtex/feature/nested
Add option to set nested-link color
- Loading branch information
Showing
11 changed files
with
242 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const defaultConfig = require('../config') | ||
|
||
function getColor(customConfig, name, fallback) { | ||
if (name && customConfig.colors[name]) { | ||
return customConfig.colors[name] | ||
} | ||
|
||
if (name) { | ||
console.warn(`Color "${name}" not found. Using Tachyons default color.`) | ||
} | ||
|
||
return defaultConfig.colors[fallback] | ||
} | ||
|
||
module.exports = { | ||
getColor | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import test from 'ava' | ||
import { getColor } from '../lib/config-utils' | ||
|
||
test('should get the custom color if it exists', t => { | ||
const customConfig = { | ||
colors: { | ||
customBlue: '#f1f8ff' | ||
} | ||
} | ||
|
||
const color = getColor(customConfig, 'customBlue', 'blue') | ||
|
||
t.is(color, '#f1f8ff') | ||
}) | ||
|
||
test('should use the fallback color if the color is not defined', t => { | ||
const color = getColor({ colors: {} }, 'customRed', 'red') | ||
|
||
t.is(color, '#ff3223') | ||
}) |
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,24 @@ | ||
import test from 'ava' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import config from '../config' | ||
import tachyonsGenerator from '../' | ||
|
||
test('nested links colors fall back to default values when not defined', async t => { | ||
const tachy = tachyonsGenerator() | ||
const { modules: { nested } } = await tachy.generate() | ||
|
||
t.snapshot(nested) | ||
}) | ||
|
||
test('nested links colors are generated when defined', async t => { | ||
const tachy = tachyonsGenerator({ | ||
nested: { | ||
links: ['blue', 'lightest-blue'], | ||
}, | ||
}) | ||
const { modules: { nested } } = await tachy.generate() | ||
|
||
t.snapshot(nested) | ||
}) |
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
Binary file not shown.
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,133 @@ | ||
# Snapshot report for `test/nested-test.js` | ||
|
||
The actual snapshot is saved in `nested-test.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## nested links colors are generated when defined | ||
|
||
> Snapshot 1 | ||
`␊ | ||
/*␊ | ||
␊ | ||
NESTED␊ | ||
Tachyons module for styling nested elements␊ | ||
that are generated by a cms.␊ | ||
␊ | ||
*/␊ | ||
␊ | ||
␊ | ||
.nested-copy-line-height p,␊ | ||
.nested-copy-line-height ul,␊ | ||
.nested-copy-line-height ol {␊ | ||
line-height: 1.5;␊ | ||
}␊ | ||
␊ | ||
.nested-headline-line-height h1,␊ | ||
.nested-headline-line-height h2,␊ | ||
.nested-headline-line-height h3,␊ | ||
.nested-headline-line-height h4,␊ | ||
.nested-headline-line-height h5,␊ | ||
.nested-headline-line-height h6 {␊ | ||
line-height: 1.25;␊ | ||
}␊ | ||
␊ | ||
.nested-list-reset ul,␊ | ||
.nested-list-reset ol {␊ | ||
padding-left: 0;␊ | ||
margin-left: 0;␊ | ||
list-style-type: none;␊ | ||
}␊ | ||
␊ | ||
.nested-copy-indent p+p {␊ | ||
text-indent: 1em;␊ | ||
margin-top: 0;␊ | ||
margin-bottom: 0;␊ | ||
}␊ | ||
␊ | ||
.nested-copy-separator p+p {␊ | ||
margin-top: 1.5em;␊ | ||
}␊ | ||
␊ | ||
.nested-img img {␊ | ||
width: 100%;␊ | ||
max-width: 100%;␊ | ||
display: block;␊ | ||
}␊ | ||
␊ | ||
.nested-links a {␊ | ||
color: #357edd;␊ | ||
transition: color .15s ease-in;␊ | ||
}␊ | ||
␊ | ||
.nested-links a:hover,␊ | ||
.nested-links a:focus {␊ | ||
color: #cdecff;␊ | ||
transition: color .15s ease-in;␊ | ||
}␊ | ||
` | ||
|
||
## nested links colors fall back to default values when not defined | ||
|
||
> Snapshot 1 | ||
`␊ | ||
/*␊ | ||
␊ | ||
NESTED␊ | ||
Tachyons module for styling nested elements␊ | ||
that are generated by a cms.␊ | ||
␊ | ||
*/␊ | ||
␊ | ||
␊ | ||
.nested-copy-line-height p,␊ | ||
.nested-copy-line-height ul,␊ | ||
.nested-copy-line-height ol {␊ | ||
line-height: 1.5;␊ | ||
}␊ | ||
␊ | ||
.nested-headline-line-height h1,␊ | ||
.nested-headline-line-height h2,␊ | ||
.nested-headline-line-height h3,␊ | ||
.nested-headline-line-height h4,␊ | ||
.nested-headline-line-height h5,␊ | ||
.nested-headline-line-height h6 {␊ | ||
line-height: 1.25;␊ | ||
}␊ | ||
␊ | ||
.nested-list-reset ul,␊ | ||
.nested-list-reset ol {␊ | ||
padding-left: 0;␊ | ||
margin-left: 0;␊ | ||
list-style-type: none;␊ | ||
}␊ | ||
␊ | ||
.nested-copy-indent p+p {␊ | ||
text-indent: 1em;␊ | ||
margin-top: 0;␊ | ||
margin-bottom: 0;␊ | ||
}␊ | ||
␊ | ||
.nested-copy-separator p+p {␊ | ||
margin-top: 1.5em;␊ | ||
}␊ | ||
␊ | ||
.nested-img img {␊ | ||
width: 100%;␊ | ||
max-width: 100%;␊ | ||
display: block;␊ | ||
}␊ | ||
␊ | ||
.nested-links a {␊ | ||
color: #357edd;␊ | ||
transition: color .15s ease-in;␊ | ||
}␊ | ||
␊ | ||
.nested-links a:hover,␊ | ||
.nested-links a:focus {␊ | ||
color: #96ccff;␊ | ||
transition: color .15s ease-in;␊ | ||
}␊ | ||
` |
Binary file not shown.