Skip to content
Permalink
Browse files

[DDW-697] Adds CLI for themes:update script

  • Loading branch information...
MarcusHurney committed Jul 12, 2019
1 parent a89ca73 commit 3b90ebf1002a35964936ddd48ccf29d679d0ee3e
@@ -28,6 +28,12 @@ export type ColorParams = {
},
};

export type FindUpdatesParams = {
cardano: Object,
darkBlue: Object,
lightBlue: Object,
};

export type LogDifferencesParams = {
color: string,
missingDefs: Object,
@@ -1,5 +1,9 @@
// @flow
import { createBackgroundShades, createErrorShades } from './createShades';
import {
createReactPolymorphTheme,
createDaedalusComponentsTheme,
} from './createTheme';

export const DEFAULT_FONTS = {
black: 'NotoSans-Black, NotoSansCJKjp-Black',
@@ -30,3 +34,8 @@ export const CREATE_THEME_MOCK_PARAMS = {
},
fonts: DEFAULT_FONTS,
};

export const CREATE_THEME_OBJ = {
...createReactPolymorphTheme(CREATE_THEME_MOCK_PARAMS),
...createDaedalusComponentsTheme(CREATE_THEME_MOCK_PARAMS),
};

This file was deleted.

@@ -6,7 +6,11 @@ import { findMissingDefinitions, findMissingCSSVars } from './checkCreateTheme';
import { CARDANO_THEME_CONFIG } from '../daedalus/cardano';
import { DARK_BLUE_THEME_CONFIG } from '../daedalus/dark-blue';
import { LIGHT_BLUE_THEME_CONFIG } from '../daedalus/light-blue';
import type { DaedalusThemesUpdates, LogDifferencesParams } from '../types';
import type {
DaedalusThemesUpdates,
FindUpdatesParams,
LogDifferencesParams,
} from '../types';

const logDifferences = ({
color,
@@ -23,19 +27,23 @@ const logDifferences = ({
};

// Checks for properties/CSS vars on createThemeObj that don't exist on existing themes
export const checkExistingThemes = (createThemeObj: Object): Object => {
export const findUpdates = (
createThemeOutputs: FindUpdatesParams
): null | Object => {
const { cardano, darkBlue, lightBlue } = createThemeOutputs;
const daedalusThemesUpdates = {};

const cardanoDefsToAdd = {
...findMissingDefinitions(createThemeObj, CARDANO_THEME_CONFIG),
...findMissingCSSVars(createThemeObj, CARDANO_THEME_CONFIG),
...findMissingDefinitions(cardano, CARDANO_THEME_CONFIG),
...findMissingCSSVars(cardano, CARDANO_THEME_CONFIG),
};
const darkBlueDefsToAdd = {
...findMissingDefinitions(createThemeObj, DARK_BLUE_THEME_CONFIG),
...findMissingCSSVars(createThemeObj, DARK_BLUE_THEME_CONFIG),
...findMissingDefinitions(darkBlue, DARK_BLUE_THEME_CONFIG),
...findMissingCSSVars(darkBlue, DARK_BLUE_THEME_CONFIG),
};
const lightBlueDefsToAdd = {
...findMissingDefinitions(createThemeObj, LIGHT_BLUE_THEME_CONFIG),
...findMissingCSSVars(createThemeObj, LIGHT_BLUE_THEME_CONFIG),
...findMissingDefinitions(lightBlue, LIGHT_BLUE_THEME_CONFIG),
...findMissingCSSVars(lightBlue, LIGHT_BLUE_THEME_CONFIG),
};

if (!isEmpty(cardanoDefsToAdd)) {
@@ -77,6 +85,7 @@ export const checkExistingThemes = (createThemeObj: Object): Object => {
)}`
)
);
return null;
}
return daedalusThemesUpdates;
};
@@ -115,12 +124,13 @@ export const updateThemes = (daedalusThemesUpdates: DaedalusThemesUpdates) => {
darkBlueUpdates,
lightBlueUpdates,
} = daedalusThemesUpdates;

const updatedThemes = {};
if (cardanoUpdates && !isEmpty(cardanoUpdates)) {
const updatedCardanoTheme = updateTheme(
CARDANO_THEME_CONFIG,
cardanoUpdates
);
updateThemes['cardano'] = updatedCardanoTheme;

// write updatedCardanoTheme theme object to cardano.js
// $FlowFixMe
@@ -134,6 +144,7 @@ export const updateThemes = (daedalusThemesUpdates: DaedalusThemesUpdates) => {
DARK_BLUE_THEME_CONFIG,
darkBlueUpdates
);
updateThemes['dark-blue'] = updatedDarkBlueTheme;

// write updatedDarkBlueTheme theme object to dark-blue.js
// $FlowFixMe
@@ -147,6 +158,7 @@ export const updateThemes = (daedalusThemesUpdates: DaedalusThemesUpdates) => {
LIGHT_BLUE_THEME_CONFIG,
lightBlueUpdates
);
updateThemes['light-blue'] = updatedLightBlueTheme;

// write updatedLightBlueTheme theme object to light-blue.js
// $FlowFixMe
@@ -158,4 +170,5 @@ export const updateThemes = (daedalusThemesUpdates: DaedalusThemesUpdates) => {
// )}`
// );
}
return updateThemes;
};

0 comments on commit 3b90ebf

Please sign in to comment.
You can’t perform that action at this time.