[d565449] | 1 | /* eslint-disable no-invalid-this */
|
---|
| 2 | 'use strict';
|
---|
| 3 |
|
---|
| 4 | // SEE TACHYONS REFERENCE: https://tachyons.io/#style
|
---|
| 5 |
|
---|
| 6 | var addonSnake = require('./snake').addon;
|
---|
| 7 |
|
---|
| 8 | var colors = {
|
---|
| 9 | black: 'rgba(0,0,0,1)',
|
---|
| 10 | black90: 'rgba(0,0,0,.9)',
|
---|
| 11 | black80: 'rgba(0,0,0,.8)',
|
---|
| 12 | black70: 'rgba(0,0,0,.7)',
|
---|
| 13 | black60: 'rgba(0,0,0,.6)',
|
---|
| 14 | black50: 'rgba(0,0,0,.5)',
|
---|
| 15 | black40: 'rgba(0,0,0,.4)',
|
---|
| 16 | black30: 'rgba(0,0,0,.3)',
|
---|
| 17 | black20: 'rgba(0,0,0,.2)',
|
---|
| 18 | black10: 'rgba(0,0,0,.1)',
|
---|
| 19 | black05: 'rgba(0,0,0,.05)',
|
---|
| 20 | black025: 'rgba(0,0,0,.025)',
|
---|
| 21 | black0125: 'rgba(0,0,0,.0125)',
|
---|
| 22 | nearBlack: '#111',
|
---|
| 23 | darkGray: '#333',
|
---|
| 24 | midGray: '#555',
|
---|
| 25 | gray: '#777',
|
---|
| 26 | white: 'rgba(255,255,255,1)',
|
---|
| 27 | white90: 'rgba(255,255,255,.9)',
|
---|
| 28 | white80: 'rgba(255,255,255,.8)',
|
---|
| 29 | white70: 'rgba(255,255,255,.7)',
|
---|
| 30 | white60: 'rgba(255,255,255,.6)',
|
---|
| 31 | white50: 'rgba(255,255,255,.5)',
|
---|
| 32 | white40: 'rgba(255,255,255,.4)',
|
---|
| 33 | white30: 'rgba(255,255,255,.3)',
|
---|
| 34 | white20: 'rgba(255,255,255,.2)',
|
---|
| 35 | white10: 'rgba(255,255,255,.1)',
|
---|
| 36 | white05: 'rgba(255,255,255,.05)',
|
---|
| 37 | white025: 'rgba(255,255,255,.025)',
|
---|
| 38 | white0125: 'rgba(255,255,255,.0125)',
|
---|
| 39 | silver: '#999',
|
---|
| 40 | lightSilver: '#aaa',
|
---|
| 41 | lightGray: '#eee',
|
---|
| 42 | nearWhite: '#f4f4f4',
|
---|
| 43 | darkRed: '#e7040f',
|
---|
| 44 | red: '#ff4136',
|
---|
| 45 | lightRed: '#ff725c',
|
---|
| 46 | orange: '#ff6300',
|
---|
| 47 | gold: '#ffb700',
|
---|
| 48 | yellow: '#ffde37',
|
---|
| 49 | lightYellow: '#fbf1a9',
|
---|
| 50 | purple: '#5e2ca5',
|
---|
| 51 | lightPurple: '#a463f2',
|
---|
| 52 | darkPink: '#d5008f',
|
---|
| 53 | hotPink: '#ff41b4',
|
---|
| 54 | pink: '#ff80cc',
|
---|
| 55 | lightPink: '#ffa3d7',
|
---|
| 56 | darkGreen: '#137752',
|
---|
| 57 | green: '#19a974',
|
---|
| 58 | lightGreen: '#9eebcf',
|
---|
| 59 | navy: '#001b44',
|
---|
| 60 | darkBlue: '#00449e',
|
---|
| 61 | blue: '#357edd',
|
---|
| 62 | lightBlue: '#96ccff',
|
---|
| 63 | lightestBlue: '#cdecff',
|
---|
| 64 | washedBlue: '#f6fffe',
|
---|
| 65 | washedGreen: '#e8fdf5',
|
---|
| 66 | washedYellow: '#fffceb',
|
---|
| 67 | washedRed: '#ffdfdf',
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | var tachyons = [
|
---|
| 71 | // Font sizes
|
---|
| 72 | ['f1', 'fontSize', '3rem'],
|
---|
| 73 | ['f2', 'fontSize', '2.25rem'],
|
---|
| 74 | ['f3', 'fontSize', '1.5rem'],
|
---|
| 75 | ['f4', 'fontSize', '1.25rem'],
|
---|
| 76 | ['f5', 'fontSize', '1rem'],
|
---|
| 77 | ['f6', 'fontSize', '.875rem'],
|
---|
| 78 |
|
---|
| 79 | // Text decorations
|
---|
| 80 | ['strike', 'textDecoration', 'line-through'],
|
---|
| 81 | ['ttc', 'textTransform', 'capitalize'],
|
---|
| 82 | ['ttu', 'textTransform', 'uppercase'],
|
---|
| 83 |
|
---|
| 84 | // Fonts
|
---|
| 85 | ['sans-serif', 'fontFamily', "-apple-system,BlinkMacSystemFont,'avenir next', avenir,helvetica,'helvetica neue',ubuntu,roboto,noto,'segoe ui',arial,sans-serif"],
|
---|
| 86 | ['sansSerif', 'fontFamily', "-apple-system,BlinkMacSystemFont,'avenir next', avenir,helvetica,'helvetica neue',ubuntu,roboto,noto,'segoe ui',arial,sans-serif"],
|
---|
| 87 | ['serif', 'fontFamily', 'georgia,times,serif'],
|
---|
| 88 | ['code', 'fontFamily', 'Consolas,monaco,monospace'],
|
---|
| 89 | ['courier', 'fontFamily', "'Courier Next', courier, monospace"],
|
---|
| 90 | ['helvetica', 'fontFamily', "'helvetica neue', helvetica, sans-serif"],
|
---|
| 91 | ['avenir', 'fontFamily', "'avenir next', avenir, sans-serif"],
|
---|
| 92 | ['athelas', 'fontFamily', 'athelas, georgia, serif'],
|
---|
| 93 | ['georgia', 'fontFamily', 'georgia, serif'],
|
---|
| 94 | ['times', 'fontFamily', 'times, seriff'],
|
---|
| 95 | ['bodoni', 'fontFamily', '"Calisto MT", serif'],
|
---|
| 96 | ['calisto', 'fontFamily', '"Bodoni MT", serif'],
|
---|
| 97 | ['garamond', 'fontFamily', 'garamond, serif'],
|
---|
| 98 | ['baskerville', 'fontFamily', 'baskerville, serif'],
|
---|
| 99 |
|
---|
| 100 | // Measures
|
---|
| 101 | ['measure-wide', 'maxWidth', '34em'],
|
---|
| 102 | ['measureWide', 'maxWidth', '34em'],
|
---|
| 103 | ['measure', 'maxWidth', '30em'],
|
---|
| 104 | ['measure-narrow', 'maxWidth', '20em'],
|
---|
| 105 | ['measureNarrow', 'maxWidth', '20em'],
|
---|
| 106 |
|
---|
| 107 | // Grid
|
---|
| 108 | ['fl', 'float', 'left'],
|
---|
| 109 | ['w100', 'width', '100%'],
|
---|
| 110 | ['w90', 'width', '90%'],
|
---|
| 111 | ['w80', 'width', '80%'],
|
---|
| 112 | ['w75', 'width', '75%'],
|
---|
| 113 | ['w70', 'width', '70%'],
|
---|
| 114 | ['w60', 'width', '60%'],
|
---|
| 115 | ['w50', 'width', '50%'],
|
---|
| 116 | ['w40', 'width', '40%'],
|
---|
| 117 | ['w30', 'width', '30%'],
|
---|
| 118 | ['w25', 'width', '25%'],
|
---|
| 119 | ['w20', 'width', '20%'],
|
---|
| 120 | ['w10', 'width', '10%'],
|
---|
| 121 | ['wThird', 'width', '33.33333%'],
|
---|
| 122 | ['wTwoThirds', 'width', '36.66667%'],
|
---|
| 123 |
|
---|
| 124 | // Borders
|
---|
| 125 | ['ba', 'border-style', 'solid', 'border-width', '1px'],
|
---|
| 126 | ['bt', 'border-top-style', 'solid', 'border-top-width', '1px'],
|
---|
| 127 | ['br', 'border-right-style', 'solid', 'border-right-width', '1px'],
|
---|
| 128 | ['bb', 'border-bottom-style', 'solid', 'border-bottom-width', '1px'],
|
---|
| 129 | ['bl', 'border-left-style', 'solid', 'border-left-width', '1px'],
|
---|
| 130 | ['bn', 'border-style', 'none', 'border-width', 0],
|
---|
| 131 |
|
---|
| 132 | // Border styles
|
---|
| 133 | ['bDotted', 'border-style', 'dotted'],
|
---|
| 134 | ['bDashed', 'border-style', 'dashed'],
|
---|
| 135 | ['bSolid', 'border-style', 'solid'],
|
---|
| 136 | ['bNone', 'border-style', 'none'],
|
---|
| 137 |
|
---|
| 138 | // Border width
|
---|
| 139 | ['bw0', 'borderWidth', 0],
|
---|
| 140 | ['bw1', 'borderWidth', '.125rem'],
|
---|
| 141 | ['bw2', 'borderWidth', '.25rem'],
|
---|
| 142 | ['bw3', 'borderWidth', '.5rem'],
|
---|
| 143 | ['bw4', 'borderWidth', '1rem'],
|
---|
| 144 | ['bw5', 'borderWidth', '2rem'],
|
---|
| 145 |
|
---|
| 146 | // Border radii
|
---|
| 147 | ['br0', 'borderRadius', 0],
|
---|
| 148 | ['br1', 'borderRadius', '.125rem'],
|
---|
| 149 | ['br2', 'borderRadius', '.25rem'],
|
---|
| 150 | ['br3', 'borderRadius', '.5rem'],
|
---|
| 151 | ['br4', 'borderRadius', '1rem'],
|
---|
| 152 | ['br100', 'borderRadius', '100%'],
|
---|
| 153 | ['brPill', 'borderRadius', '9999px'],
|
---|
| 154 | ['brBottom', 'borderTopLeftRadius', 0, 'borderTopRightRadius', 0],
|
---|
| 155 | ['brTop', 'borderBottomLeftRadius', 0, 'borderBottomRightRadius', 0],
|
---|
| 156 | ['brRight', 'borderTopLeftRadius', 0, 'borderBottomLeftRadius', 0],
|
---|
| 157 | ['brLeft', 'borderTopRightRadius', 0, 'borderBottomRightRadius', 0],
|
---|
| 158 | ];
|
---|
| 159 |
|
---|
| 160 | // Colors
|
---|
| 161 | for (var name in colors) {
|
---|
| 162 | var capitalized = name[0].toUpperCase() + name.substr(1);
|
---|
| 163 | var color = colors[name];
|
---|
| 164 |
|
---|
| 165 | // Colors
|
---|
| 166 | tachyons.push([name, 'color', color]);
|
---|
| 167 |
|
---|
| 168 | // Background colors
|
---|
| 169 | tachyons.push(['bg' + capitalized, 'backgroundColor', color]);
|
---|
| 170 |
|
---|
| 171 | // Border colors
|
---|
| 172 | tachyons.push(['b' + capitalized, 'borderColor', color]);
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | exports.addon = function (renderer, ruleOverrides) {
|
---|
| 176 | var rules = {};
|
---|
| 177 |
|
---|
| 178 | function onTachyon (tachyon) {
|
---|
| 179 | rules[tachyon[0]] = function () {
|
---|
| 180 | for (var i = 1; i < tachyon.length; i += 2) {
|
---|
| 181 | this[tachyon[i]] = tachyon[i + 1];
|
---|
| 182 | }
|
---|
| 183 | };
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | for (var i = 0; i < tachyons.length; i++)
|
---|
| 187 | onTachyon(tachyons[i]);
|
---|
| 188 |
|
---|
| 189 | // Add hover rules
|
---|
| 190 | rules.grow = function () {
|
---|
| 191 | this['-moz-osx-font-smoothing'] = 'grayscale';
|
---|
| 192 | this.backfaceVisibility = 'hidden';
|
---|
| 193 | this.transform = 'translateZ(0)';
|
---|
| 194 | this.transition = 'transform 0.25s ease-out';
|
---|
| 195 | this[':hover'] = {
|
---|
| 196 | transform: 'scale(1.05)',
|
---|
| 197 | };
|
---|
| 198 | this[':focus'] = {
|
---|
| 199 | transform: 'scale(1.05)',
|
---|
| 200 | };
|
---|
| 201 | };
|
---|
| 202 |
|
---|
| 203 | rules.dim = function () {
|
---|
| 204 | this.opacity = 1;
|
---|
| 205 | this.transition = 'opacity .15s ease-in';
|
---|
| 206 | this[':hover'] = {
|
---|
| 207 | opacity: '.5',
|
---|
| 208 | };
|
---|
| 209 | this[':focus'] = {
|
---|
| 210 | opacity: '.5',
|
---|
| 211 | };
|
---|
| 212 | };
|
---|
| 213 |
|
---|
| 214 | addonSnake(renderer, renderer.assign(rules, ruleOverrides || {}));
|
---|
| 215 | };
|
---|