-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support node_color and docs.show under the config object (#281)
* hard coded to start * add a node color config * play with this more * add placeholder snippets * working dynamic node colors * docs node_color config works * remove debugging logs and comments * remove newlines * Allow node_color and check show under config.docs * Support doc.show from the config object * Do color validation on the dbt-docs side * remove config properties * revert this * Read from docs.node_color instead of config.docs.node_color * Fetch latest CHANGELOG * Add support for `node_color` Co-authored-by: Matt Winkler <[email protected]> Co-authored-by: Sung Won Chung <[email protected]>
- Loading branch information
1 parent
12ba81f
commit 85dec85
Showing
3 changed files
with
176 additions
and
2 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
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,157 @@ | ||
const colorSet = new Set([ | ||
'aliceblue', | ||
'antiquewhite', | ||
'aqua', | ||
'aquamarine', | ||
'azure', | ||
'beige', | ||
'bisque', | ||
'black', | ||
'blanchedalmond', | ||
'blue', | ||
'blueviolet', | ||
'brown', | ||
'burlywood', | ||
'cadetblue', | ||
'chartreuse', | ||
'chocolate', | ||
'coral', | ||
'cornflowerblue', | ||
'cornsilk', | ||
'crimson', | ||
'cyan', | ||
'darkblue', | ||
'darkcyan', | ||
'darkgoldenrod', | ||
'darkgray', | ||
'darkgreen', | ||
'darkkhaki', | ||
'darkmagenta', | ||
'darkolivegreen', | ||
'darkorange', | ||
'darkorchid', | ||
'darkred', | ||
'darksalmon', | ||
'darkseagreen', | ||
'darkslateblue', | ||
'darkslategray', | ||
'darkturquoise', | ||
'darkviolet', | ||
'deeppink', | ||
'deepskyblue', | ||
'dimgray', | ||
'dodgerblue', | ||
'firebrick', | ||
'floralwhite', | ||
'forestgreen', | ||
'fuchsia', | ||
'ghostwhite', | ||
'gold', | ||
'goldenrod', | ||
'gray', | ||
'green', | ||
'greenyellow', | ||
'honeydew', | ||
'hotpink', | ||
'indianred', | ||
'indigo', | ||
'ivory', | ||
'khaki', | ||
'lavender', | ||
'lavenderblush', | ||
'lawngreen', | ||
'lemonchiffon', | ||
'lightblue', | ||
'lightcoral', | ||
'lightcyan', | ||
'lightgoldenrodyellow', | ||
'lightgray', | ||
'lightgreen', | ||
'lightpink', | ||
'lightsalmon', | ||
'lightsalmon', | ||
'lightseagreen', | ||
'lightskyblue', | ||
'lightslategray', | ||
'lightsteelblue', | ||
'lightyellow', | ||
'lime', | ||
'limegreen', | ||
'linen', | ||
'magenta', | ||
'maroon', | ||
'mediumaquamarine', | ||
'mediumblue', | ||
'mediumorchid', | ||
'mediumpurple', | ||
'mediumseagreen', | ||
'mediumslateblue', | ||
'mediumslateblue', | ||
'mediumspringgreen', | ||
'mediumturquoise', | ||
'mediumvioletred', | ||
'midnightblue', | ||
'mintcream', | ||
'mistyrose', | ||
'moccasin', | ||
'navajowhite', | ||
'navy', | ||
'oldlace', | ||
'olive', | ||
'olivedrab', | ||
'orange', | ||
'orangered', | ||
'orchid', | ||
'palegoldenrod', | ||
'palegreen', | ||
'paleturquoise', | ||
'palevioletred', | ||
'papayawhip', | ||
'peachpuff', | ||
'peru', | ||
'pink', | ||
'plum', | ||
'powderblue', | ||
'purple', | ||
'rebeccapurple', | ||
'red', | ||
'rosybrown', | ||
'royalblue', | ||
'saddlebrown', | ||
'salmon', | ||
'sandybrown', | ||
'seagreen', | ||
'seashell', | ||
'sienna', | ||
'silver', | ||
'skyblue', | ||
'slateblue', | ||
'slategray', | ||
'snow', | ||
'springgreen', | ||
'steelblue', | ||
'tan', | ||
'teal', | ||
'thistle', | ||
'tomato', | ||
'turquoise', | ||
'violet', | ||
'wheat', | ||
'white', | ||
'whitesmoke', | ||
'yellow', | ||
'yellowgreen', | ||
]); | ||
|
||
|
||
export function isValidColor(color) { | ||
if (!color) return false; // empty string, null, undefined | ||
|
||
const serialized = color.trim().toLowerCase(); | ||
if (serialized === '') return false; // only spaces | ||
|
||
const isHex = serialized.match(/^#([A-Fa-f0-9]{3}){1,2}$/); | ||
const isColor = colorSet.has(serialized); | ||
|
||
return Boolean(isHex) || isColor; | ||
} |