Skip to content

Commit

Permalink
allow to override language, dict, logo and primary color on show method
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Oct 26, 2016
1 parent a8a2df3 commit 5139c23
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { defaultProps } from '../ui/box/container';
import { isFieldValid, showInvalidField } from '../field/index';

export function setupLock(id, clientID, domain, options, hookRunner, emitEventFn) {
let m = syncRemoteData(l.setup(id, clientID, domain, options, hookRunner, emitEventFn));
let m = l.setup(id, clientID, domain, options, hookRunner, emitEventFn);

m = syncRemoteData(m);

preload(l.ui.logo(m) || defaultProps.logo);

webApi.setupClient(id, clientID, domain, l.withAuthOptions(m, {
Expand Down
30 changes: 29 additions & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,16 @@ function extractUIOptions(id, options) {
});
}

const { get: getUIAttribute } = dataFns(["core", "ui"]);
const {
get: getUI,
tget: tgetUI,
set: setUI,
tset: tsetUI
} = dataFns(["core", "ui"]);

const getUIAttribute = (m, attribute) => {
return tgetUI(m, attribute) || getUI(m, attribute);
};

export const ui = {
containerID: lock => getUIAttribute(lock, "containerID"),
Expand Down Expand Up @@ -485,6 +494,25 @@ export function overrideOptions(m, opts) {
m = tset(m, "authParams", Immutable.fromJS(opts.auth.params));
}

if (opts.theme) {
if (opts.theme.primaryColor) {
m = tsetUI(m, ["primaryColor"], opts.theme.primaryColor);
}

if (opts.theme.logo) {
m = tsetUI(m, ["logo"], opts.theme.logo);
}
}

if (opts.language) {
opts.dict = opts.dict || {};

m = tsetUI(m, ["language"], opts.language);
m = tsetUI(m, ["dict"], opts.dict);

m = i18n.initI18n(m);
}

if (typeof opts.rememberLastLogin === "boolean") {
m = tset(m, "rememberLastLogin", opts.rememberLastLogin);
}
Expand Down

0 comments on commit 5139c23

Please sign in to comment.