Commit 2542a43e by Dominik Prokop

Regenerating variabless sas on theme edit v1

parent 0a66d8af
......@@ -17,13 +17,12 @@
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.1.0",
"@rtsao/plugin-proposal-class-properties": "^7.0.1-patch.1",
"@types/chokidar": "^1.7.5",
"@types/classnames": "^2.2.6",
"@types/d3": "^4.10.1",
"@types/enzyme": "^3.1.13",
"@types/jest": "^23.3.2",
"@types/jquery": "^1.10.35",
"@types/node": "^10.12.24",
"@types/node": "^8.0.31",
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"@types/react-grid-layout": "^0.16.6",
......@@ -37,8 +36,8 @@
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-angularjs-annotate": "^0.9.0",
"chokidar": "^2.1.0",
"clean-webpack-plugin": "^0.1.19",
"concurrently": "^4.1.0",
"css-loader": "^0.28.7",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
......@@ -72,7 +71,6 @@
"jest-date-mock": "^1.0.6",
"lint-staged": "^8.1.3",
"load-grunt-tasks": "3.5.2",
"log-timestamp": "^0.2.1",
"mini-css-extract-plugin": "^0.4.0",
"mocha": "^4.0.1",
"monaco-editor": "^0.15.6",
......@@ -116,7 +114,7 @@
},
"scripts": {
"dev": "webpack --progress --colors --mode development --config scripts/webpack/webpack.dev.js",
"start": "webpack-dev-server --progress --colors --mode development --config scripts/webpack/webpack.hot.js",
"start": "node ./scripts/cli/start.js",
"watch": "webpack --progress --colors --watch --mode development --config scripts/webpack/webpack.dev.js",
"build": "grunt build",
"test": "grunt test",
......@@ -126,8 +124,7 @@
"api-tests": "jest --notify --watch --config=tests/api/jest.js",
"precommit": "grunt precommit",
"storybook": "cd packages/grafana-ui && yarn storybook",
"tmp": "nodemon -e ts -w ./packages/grafana-ui/src/themes -x yarn run tmp:exec",
"tmp:exec": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/watch.ts"
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts"
},
"husky": {
"hooks": {
......
......@@ -8,23 +8,24 @@ export const darkThemeVarsTemplate = (theme: GrafanaTheme) => `
// Grays
// -------------------------
$black: #000;
$dark-1: #141414;
$dark-2: #1f1f20;
$dark-3: #262628;
$dark-4: #333333;
$dark-5: #444444;
$gray-1: #555555;
$gray-2: #8e8e8e;
$gray-3: #b3b3b3;
$gray-4: #d8d9da;
$gray-5: #ececec;
$gray-7: #fbfbfb;
$black: ${theme.colors.black};
$dark-1: ${theme.colors.dark2};
$dark-2: ${theme.colors.dark2};
$dark-3: ${theme.colors.dark3};
$dark-4: ${theme.colors.dark4};
$dark-5: ${theme.colors.dark5};
$gray-1: ${theme.colors.gray1};
$gray-2: ${theme.colors.gray2};
$gray-3: ${theme.colors.gray3};
$gray-4: ${theme.colors.gray4};
$gray-5: ${theme.colors.gray5};
$gray-6: ${theme.colors.gray6};
$gray-7: ${theme.colors.gray7};
$gray-blue: #212327;
$input-black: #09090b;
$white: #fff;
$white: ${theme.colors.white};
// Accent colors
// -------------------------
......@@ -383,5 +384,5 @@ export const darkThemeVarsTemplate = (theme: GrafanaTheme) => `
$vertical-resize-handle-bg: $dark-5;
$vertical-resize-handle-dots: $gray-1;
$vertical-resize-handle-dots-hover: $gray-2;
$vertical-resize-handle-dots-hover: $gray-2;
`;
......@@ -4,7 +4,7 @@ import appEvents from 'app/core/app_events';
jest.mock('app/core/app_events', () => {
return {
emit: jest.fn<any>(),
emit: jest.fn(),
};
});
......
......@@ -2,7 +2,7 @@ import { PlaylistSrv } from '../playlist_srv';
const dashboards = [{ url: 'dash1' }, { url: 'dash2' }];
const createPlaylistSrv = (): [PlaylistSrv, { url: jest.MockInstance<any> }] => {
const createPlaylistSrv = (): [PlaylistSrv, { url: jest.MockInstance<any, any> }] => {
const mockBackendSrv = {
get: jest.fn(url => {
switch (url) {
......@@ -27,7 +27,7 @@ const createPlaylistSrv = (): [PlaylistSrv, { url: jest.MockInstance<any> }] =>
return [new PlaylistSrv(mockLocation, mockTimeout, mockBackendSrv), mockLocation];
};
const mockWindowLocation = (): [jest.MockInstance<any>, () => void] => {
const mockWindowLocation = (): [jest.MockInstance<any, any>, () => void] => {
const oldLocation = window.location;
const hrefMock = jest.fn();
......@@ -50,7 +50,7 @@ const mockWindowLocation = (): [jest.MockInstance<any>, () => void] => {
describe('PlaylistSrv', () => {
let srv: PlaylistSrv;
let hrefMock: jest.MockInstance<any>;
let hrefMock: jest.MockInstance<any, any>;
let unmockLocation: () => void;
const initialUrl = 'http://localhost/playlist';
......
......@@ -5,8 +5,8 @@ $theme-name: dark;
// Grays
// -------------------------
$black: #000;
$dark-1: #141414;
$black: #000000;
$dark-1: #1f1f20;
$dark-2: #1f1f20;
$dark-3: #262628;
$dark-4: #333333;
......@@ -16,12 +16,13 @@ $gray-2: #8e8e8e;
$gray-3: #b3b3b3;
$gray-4: #d8d9da;
$gray-5: #ececec;
$gray-6: #f4f5f8;
$gray-7: #fbfbfb;
$gray-blue: #212327;
$input-black: #09090b;
$white: #fff;
$white: #ffffff;
// Accent colors
// -------------------------
......
......@@ -3,24 +3,10 @@
$theme-name: light;
// New Colors
// -------------------------
$sapphire-faint: #f5f9ff;
$sapphire-light: #a8caff;
$sapphire-base: #3274d9;
$sapphire-shade: #1f60c4;
$lobster-base: #e02f44;
$lobster-shade: #c4162a;
$green-base: #37872d;
$green-shade: #19730e;
$green-base: #3eb15b;
$green-shade: #369b4f;
$purple-shade: #8f3bb8;
$yellow-base: #f2cc0c;
// Grays
// -------------------------
$black: #000;
$black: #000000;
$dark-1: #13161d;
$dark-2: #1e2028;
$dark-3: #303133;
$dark-4: #35373f;
......@@ -33,35 +19,35 @@ $gray-5: #dde4ed;
$gray-6: #e9edf2;
$gray-7: #f7f8fa;
$white: #fff;
$white: #ffffff;
// Accent colors
// -------------------------
$blue: #0083b3;
$blue-light: #00a8e6;
$green: #3aa655;
$red: $lobster-base;
$red: #d44939;
$yellow: #ff851b;
$orange: #ff7941;
$purple: #9954bb;
$variable: $purple-shade;
$variable: $blue;
$brand-primary: $orange;
$brand-success: $green;
$brand-warning: $orange;
$brand-danger: $lobster-base;
$brand-danger: $red;
$query-red: $lobster-base;
$query-red: $red;
$query-green: $green;
$query-purple: $purple;
$query-orange: $orange;
$query-keyword: $sapphire-base;
$query-keyword: $blue;
// Status colors
// -------------------------
$online: $green-shade;
$online: #01a64f;
$warn: #f79520;
$critical: $lobster-shade;
$critical: #ec2128;
// Scaffolding
// -------------------------
......@@ -76,6 +62,7 @@ $text-color-faint: $gray-4;
$text-color-emphasis: $dark-5;
$text-shadow-faint: none;
$textShadow: none;
// gradients
$brand-gradient: linear-gradient(to right, rgba(255, 213, 0, 1) 0%, rgba(255, 68, 0, 1) 99%, rgba(255, 68, 0, 1) 100%);
......@@ -88,7 +75,7 @@ $edit-gradient: linear-gradient(-60deg, $gray-7, #f5f6f9 70%, $gray-7 98%);
$link-color: $gray-1;
$link-color-disabled: lighten($link-color, 30%);
$link-hover-color: darken($link-color, 20%);
$external-link-color: $sapphire-shade;
$external-link-color: $blue-light;
// Typography
// -------------------------
......@@ -150,17 +137,20 @@ $table-bg-hover: $gray-5;
// Buttons
// -------------------------
$btn-primary-bg: $green-base;
$btn-primary-bg-hl: $green-shade;
$btn-primary-bg: $brand-primary;
$btn-primary-bg-hl: lighten($brand-primary, 8%);
$btn-secondary-bg: $sapphire-base;
$btn-secondary-bg-hl: $sapphire-shade;
$btn-secondary-bg: $blue;
$btn-secondary-bg-hl: lighten($blue, 4%);
$btn-success-bg: $green-base;
$btn-success-bg-hl: $green-shade;
$btn-success-bg: lighten($green, 3%);
$btn-success-bg-hl: darken($green, 3%);
$btn-danger-bg: $lobster-base;
$btn-danger-bg-hl: $lobster-shade;
$btn-warning-bg: lighten($orange, 3%);
$btn-warning-bg-hl: darken($orange, 3%);
$btn-danger-bg: lighten($red, 3%);
$btn-danger-bg-hl: darken($red, 3%);
$btn-inverse-bg: $gray-6;
$btn-inverse-bg-hl: darken($gray-6, 5%);
......@@ -184,8 +174,8 @@ $input-bg-disabled: $gray-5;
$input-color: $dark-3;
$input-border-color: $gray-5;
$input-box-shadow: none;
$input-border-focus: $sapphire-light !default;
$input-box-shadow-focus: $sapphire-light !default;
$input-border-focus: $blue !default;
$input-box-shadow-focus: $blue !default;
$input-color-placeholder: $gray-4 !default;
$input-label-bg: $gray-5;
$input-label-border-color: $gray-5;
......@@ -259,13 +249,14 @@ $toolbar-bg: white;
// Form states and alerts
// -------------------------
$warning-text-color: lighten($orange, 10%);
$error-text-color: $lobster-shade;
$error-text-color: lighten($red, 10%);
$success-text-color: lighten($green, 10%);
$info-text-color: $blue;
$alert-error-bg: linear-gradient(90deg, $lobster-base, $lobster-shade);
$alert-success-bg: linear-gradient(90deg, $green-base, $green-shade);
$alert-warning-bg: linear-gradient(90deg, $lobster-base, $lobster-shade);
$alert-info-bg: $sapphire-base;
$alert-error-bg: linear-gradient(90deg, #d44939, #e04d3d);
$alert-success-bg: linear-gradient(90deg, #3aa655, #47b274);
$alert-warning-bg: linear-gradient(90deg, #d44939, #e04d3d);
$alert-info-bg: $blue;
// popover
$popover-bg: $page-bg;
......@@ -273,7 +264,7 @@ $popover-color: $text-color;
$popover-border-color: $gray-5;
$popover-shadow: 0 0 20px $white;
$popover-help-bg: $sapphire-base;
$popover-help-bg: $blue;
$popover-help-color: $gray-6;
$popover-error-bg: $btn-danger-bg;
......@@ -294,7 +285,7 @@ $tooltipBackgroundError: $brand-danger;
$checkboxImageUrl: '../img/checkbox_white.png';
// info box
$info-box-border-color: $sapphire-base;
$info-box-border-color: lighten($blue, 20%);
// footer
$footer-link-color: $gray-3;
......@@ -303,16 +294,16 @@ $footer-link-hover: $dark-5;
// json explorer
$json-explorer-default-color: black;
$json-explorer-string-color: green;
$json-explorer-number-color: $sapphire-base;
$json-explorer-boolean-color: $lobster-base;
$json-explorer-number-color: blue;
$json-explorer-boolean-color: red;
$json-explorer-null-color: #855a00;
$json-explorer-undefined-color: rgb(202, 11, 105);
$json-explorer-function-color: #ff20ed;
$json-explorer-rotate-time: 100ms;
$json-explorer-toggler-opacity: 0.6;
$json-explorer-bracket-color: $sapphire-base;
$json-explorer-bracket-color: blue;
$json-explorer-key-color: #00008b;
$json-explorer-url-color: $sapphire-base;
$json-explorer-url-color: blue;
// Changelog and diff
// -------------------------
......@@ -323,35 +314,35 @@ $diff-arrow-color: $dark-3;
$diff-group-bg: $gray-7;
$diff-json-bg: $gray-5;
$diff-json-fg: $gray-1;
$diff-json-fg: $gray-2;
$diff-json-added: $sapphire-shade;
$diff-json-deleted: $lobster-shade;
$diff-json-added: lighten(desaturate($green, 30%), 10%);
$diff-json-deleted: desaturate($red, 35%);
$diff-json-old: #5a372a;
$diff-json-new: #664e33;
$diff-json-changed-fg: $gray-7;
$diff-json-changed-fg: $gray-6;
$diff-json-changed-num: $gray-4;
$diff-json-icon: $gray-4;
//Submenu
$variable-option-bg: $dropdownLinkBackgroundHover;
$variable-option-bg: $blue-light;
//Switch Slider
// -------------------------
$switch-bg: $white;
$switch-slider-color: $gray-7;
$switch-slider-off-bg: $gray-5;
$switch-slider-on-bg: linear-gradient(90deg, #ff9830, #e55400);
$switch-slider-on-bg: linear-gradient(90deg, $yellow, $red);
$switch-slider-shadow: 0 0 3px $dark-5;
//Checkbox
// -------------------------
$checkbox-bg: $gray-6;
$checkbox-border: 1px solid $gray-3;
$checkbox-checked-bg: linear-gradient(0deg, #ff9830, #e55400);
$checkbox-checked-bg: linear-gradient(0deg, $yellow, $red);
$checkbox-color: $gray-7;
//Panel Edit
......@@ -365,11 +356,12 @@ $panel-editor-viz-item-border-hover: 1px solid $blue-light;
$panel-editor-viz-item-bg: $white;
$panel-editor-tabs-line-color: $dark-5;
$panel-editor-viz-item-bg-hover: lighten($blue, 62%);
$panel-options-group-border: none;
$panel-options-group-header-bg: $gray-5;
$panel-grid-placeholder-bg: $sapphire-faint;
$panel-grid-placeholder-shadow: 0 0 4px $sapphire-light;
$panel-grid-placeholder-bg: lighten($blue, 62%);
$panel-grid-placeholder-shadow: 0 0 4px $blue-light;
// logs
$logs-color-unkown: $gray-5;
......
import fs from 'fs';
import darkTheme from '@grafana/ui/src/themes/dark';
import lightTheme from '@grafana/ui/src/themes/light';
import { darkThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.dark.scss.tmpl';
import { lightThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.light.scss.tmpl';
const darkThemeVariablesPath = __dirname + '/../../public/sass/_variables.dark.scss';
const lightThemeVariablesPath = __dirname + '/../../public/sass/_variables.light.scss';
const writeVariablesFile = async (path: string, data: string) => {
return new Promise((resolve, reject) => {
fs.writeFile(path, data, e => {
if (e) {
reject(e);
} else {
resolve(data);
}
});
});
};
const generateSassVariableFiles = async () => {
try {
await Promise.all([
writeVariablesFile(darkThemeVariablesPath, darkThemeVarsTemplate(darkTheme)),
writeVariablesFile(lightThemeVariablesPath, lightThemeVarsTemplate(lightTheme)),
]);
console.log('\nSASS variable files generated');
} catch (error) {
console.error('\nWriting SASS variable files failed', error);
process.exit(1);
}
};
generateSassVariableFiles();
{
"watch": ["packages/grafana-ui/src/themes"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node ./src/index.ts"
}
const concurrently = require('concurrently');
const startTask = async () => {
try {
const res = await concurrently([
{
command: 'nodemon -e ts -w ./packages/grafana-ui/src/themes -x yarn run themes:generate',
name: 'SASS variables generator',
},
{
command: 'webpack-dev-server --progress --colors --mode development --config scripts/webpack/webpack.hot.js',
name: 'Dev server',
},
], {
killOthers: ['failure', 'failure'],
});
} catch (e) {
console.error(e);
process.exit(1);
}
};
startTask();
// import chokidar from 'chokidar';
import darkTheme from '@grafana/ui/src/themes/dark';
import { darkThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.dark.scss.tmpl';
import fs from 'fs';
console.log(__dirname + '../../packages/grafana-ui/src/themes/dark.ts');
const fileToWatch = [
__dirname + '/../../packages/grafana-ui/src/themes/dark.ts',
__dirname + '/../../packages/grafana-ui/src/themes/light.ts',
];
// const watchService = chokidar.watch(fileToWatch);
console.log(`Watching for file changes on ${fileToWatch}`);
// watchService.on('change', path => {
const result = darkThemeVarsTemplate(darkTheme);
console.log(result);
fs.writeFile(__dirname + '/../../public/sass/_variables.dark.scss', result, e => {
console.log(e);
});
// });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment