From f2b98ae01df4bf1c95972fe8fb718e02efd07c03 Mon Sep 17 00:00:00 2001 From: Vlad Faust Date: Sat, 22 Sep 2018 16:43:40 +0300 Subject: [PATCH] feat: extract color to settings.json --- package.json | 1 + src/index.pug | 31 ++++++++++++++++++------------- src/settings.json | 3 +++ src/style.sass | 5 +++-- webpack.config.js | 8 +++++++- yarn.lock | 20 +++++++++++++++++++- 6 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 src/settings.json diff --git a/package.json b/package.json index c66a87f..8d13c09 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "css-loader": "^0.28.11", "html-webpack-plugin": "^3.2.0", "node-sass": "^4.9.0", + "node-sass-json-importer": "^4.0.1", "pug": "^2.0.3", "pug-loader": "^2.4.0", "sass-loader": "^7.0.1", diff --git a/src/index.pug b/src/index.pug index 999438e..9f6265e 100644 --- a/src/index.pug +++ b/src/index.pug @@ -1,3 +1,8 @@ +- var color = require("./settings.json").color; +- var stars = function (username, repo) { +- return `https://img.shields.io/badge/dynamic/json.svg?label=star&url=https%3A%2F%2Fapi.github.com%2Frepos%2F${username}%2F${repo}&query=%24.stargazers_count&style=flat-square&colorA=black&colorB=${color}&maxAge=86400` +- }; + doctype html html head @@ -34,17 +39,17 @@ html li a(href="https://github.com/vladfaust/prism") span.title Prism - img(src="https://img.shields.io/github/stars/vladfaust/prism.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "prism")) | an expressive web framework with typed params li - a(href="https://github.com/vladfaust/core.cr") + a(href="https://github.com/vladfaust/core") span.title Core - img(src="https://img.shields.io/github/stars/vladfaust/core.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "core")) | an expressive modular ORM li a(href="https://github.com/vladfaust/crystalworld") span.title Crystal World - img(src="https://img.shields.io/github/stars/vladfaust/crystalworld.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "crystalworld")) span | the  a(href="https://realworld.io") realworld.io @@ -58,27 +63,27 @@ html li a(href="https://github.com/vladfaust/migrate.cr") span.title Migrate - img(src="https://img.shields.io/github/stars/vladfaust/migrate.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "migrate.cr")) | a database migration solution li a(href="https://github.com/vladfaust/validations.cr") span.title Validations - img(src="https://img.shields.io/github/stars/vladfaust/validations.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "validations.cr")) | a validations mixin li a(href="https://github.com/vladfaust/callbacks.cr") span.title Callbacks - img(src="https://img.shields.io/github/stars/vladfaust/callbacks.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "callbacks.cr")) | the expressive callbacks module li a(href="https://github.com/vladfaust/cake-bake.cr") span.title Cake-Bake - img(src="https://img.shields.io/github/stars/vladfaust/cake-bake.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "cake-bake.cr")) | an utility shard to bake Cakefile (just like Rake tasks) into binaries li a(href="https://github.com/vladfaust/tarantool-crystal") span.title Tarantool - img(src="https://img.shields.io/github/stars/vladfaust/tarantool-crystal.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "tarantool-crystal")) span | the  a(href="https://tarantool.io") tarantool @@ -86,24 +91,24 @@ html li a(href="https://github.com/vladfaust/http-multiserver.cr") span.title HTTP::Multiserver - img(src="https://img.shields.io/github/stars/vladfaust/http-multiserver.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "http-multiserver.cr")) | an utility shard to map web applications li a(href="https://github.com/vladfaust/i18n.cr") span.title I18n - img(src="https://img.shields.io/github/stars/vladfaust/i18n.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "i18n.cr")) | an internationalization shard li a(href="https://github.com/vladfaust/time_format.cr") span.title TimeFormat - img(src="https://img.shields.io/github/stars/vladfaust/time_format.cr.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "time_format.cr")) | a shard to humanize time spans h2 Non-crystal projects: ul.projects li a(href="https://github.com/vladfaust/unity-wakatime") span.title Unity Wakatime - img(src="https://img.shields.io/github/stars/vladfaust/unity-wakatime.svg?style=flat-square&label=star&colorA=black&colorB=0a83d8&maxAge=86400") + img(src=stars("vladfaust", "unity-wakatime")) | a Unity Wakatime integration (C#) li a(href="http://xgm.guru/p/ufs") UFS Arena diff --git a/src/settings.json b/src/settings.json new file mode 100644 index 0000000..5497e91 --- /dev/null +++ b/src/settings.json @@ -0,0 +1,3 @@ +{ + "color": "purple" +} diff --git a/src/style.sass b/src/style.sass index 015ac32..63f0076 100644 --- a/src/style.sass +++ b/src/style.sass @@ -1,4 +1,5 @@ @import url('https://fonts.googleapis.com/css?family=Roboto') +@import './settings.json' body align-items: center @@ -28,7 +29,7 @@ body, html left: 0 max-width: 100% height: 5px - background-color: #0a83d8 + background-color: $color h1, h2 margin: 0 0 1rem @@ -38,7 +39,7 @@ h1, h2 a text-decoration: none - color: #0a83d8 + color: $color ul.projects padding: 0 diff --git a/webpack.config.js b/webpack.config.js index 21193d5..c20e4c3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,7 @@ var path = require('path'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); +var jsonImporter = require('node-sass-json-importer'); module.exports = { mode: 'production', @@ -15,7 +16,12 @@ module.exports = { use: [ "style-loader", "css-loader", - "sass-loader" + { + loader: "sass-loader", + options: { + importer: jsonImporter() + } + } ] }, { test: /\.pug$/, diff --git a/yarn.lock b/yarn.lock index 9374deb..6f4a7c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2485,6 +2485,10 @@ is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" +is-there@^4.0.0: + version "4.4.3" + resolved "https://registry.yarnpkg.com/is-there/-/is-there-4.4.3.tgz#a2c49366c6a487f719dbcad80cbde21248d2c18d" + is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -2586,6 +2590,12 @@ json5@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" +json5@^1.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + dependencies: + minimist "^1.2.0" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -2719,7 +2729,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.5, lodash@~4.17.10: +lodash@^4.0.0, lodash@^4.17, lodash@^4.17.10, lodash@^4.17.5, lodash@~4.17.10: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" @@ -3101,6 +3111,14 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" +node-sass-json-importer@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/node-sass-json-importer/-/node-sass-json-importer-4.0.1.tgz#0d7d8641670bc9fed96951eef677c438e20dd1d5" + dependencies: + is-there "^4.0.0" + json5 "^1.0" + lodash "^4.17" + node-sass@^4.9.0: version "4.9.3" resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.9.3.tgz#f407cf3d66f78308bb1e346b24fa428703196224"