Fixes for High contrast mode as per lego design. Most changes are in PXT. Adding high contrast theme in the simulator (#564)

This commit is contained in:
Sam El-Husseini 2018-05-04 10:36:48 -07:00 committed by GitHub
parent 2a371b9cc6
commit f0df0222c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 29 deletions

View File

@ -81,7 +81,6 @@
"accentColor": "#0089BF", "accentColor": "#0089BF",
"logoUrl": "https://education.lego.com/", "logoUrl": "https://education.lego.com/",
"logo": "./static/lego_education_logo.png", "logo": "./static/lego_education_logo.png",
"highContrastLogo": "./static/lego_education_logo_white.png",
"docsLogo": "./static/lego-logo.svg", "docsLogo": "./static/lego-logo.svg",
"portraitLogo": "./static/lego-logo.svg", "portraitLogo": "./static/lego-logo.svg",
"footerLogo": "./static/lego-logo.svg", "footerLogo": "./static/lego-logo.svg",

View File

@ -101,10 +101,13 @@ namespace pxsim.visuals {
export const SCREEN_HEIGHT = 128; export const SCREEN_HEIGHT = 128;
export interface IBoardTheme { export interface IBoardTheme {
accent?: string; accent?: string;
highContrast?: boolean;
display?: string; display?: string;
buttonOuter?: string; buttonOuter?: string;
buttonUps: string[]; buttonUps: string[];
buttonDown?: string; buttonDown?: string;
wireColor?: string;
backgroundViewColor?: string;
} }
export var themes: IBoardTheme[] = ["#3ADCFE"].map(accent => { export var themes: IBoardTheme[] = ["#3ADCFE"].map(accent => {
@ -112,12 +115,21 @@ namespace pxsim.visuals {
accent: accent, accent: accent,
buttonOuter: "#979797", buttonOuter: "#979797",
buttonUps: ["#a8aaa8", "#393939", "#a8aaa8", "#a8aaa8", "#a8aaa8", '#a8aaa8'], buttonUps: ["#a8aaa8", "#393939", "#a8aaa8", "#a8aaa8", "#a8aaa8", '#a8aaa8'],
buttonDown: "#000" buttonDown: "#000",
wireColor: '#5A5A5A',
backgroundViewColor: '#d6edff'
} }
}); });
export function randomTheme(highContrast?: boolean, light?: boolean): IBoardTheme { export function randomTheme(highContrast?: boolean, light?: boolean): IBoardTheme {
return themes[Math.floor(Math.random() * themes.length)]; let theme = themes[Math.floor(Math.random() * themes.length)];
if (highContrast) {
theme = JSON.parse(JSON.stringify(theme)) as IBoardTheme;
theme.highContrast = true;
theme.wireColor = '#ffffff';
theme.backgroundViewColor = '#ffffff';
}
return theme;
} }
export interface IBoardProps { export interface IBoardProps {
@ -334,7 +346,7 @@ namespace pxsim.visuals {
this.style.textContent = EV3_STYLE; this.style.textContent = EV3_STYLE;
this.layoutView = new LayoutView(); this.layoutView = new LayoutView();
this.layoutView.inject(this.element); this.layoutView.inject(this.element, this.props.theme);
const brick = new BrickViewPortrait(-1); const brick = new BrickViewPortrait(-1);
this.layoutView.setBrick(brick); this.layoutView.setBrick(brick);

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
'x': 0, 'y': 0, 'x': 0, 'y': 0,
'width': '100%', 'width': '100%',
'height': '100%', 'height': '100%',
'style': `fill: #d6edff; stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2` 'style': `fill: ${this.theme.backgroundViewColor};stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2`
}) as SVGRectElement; }) as SVGRectElement;
return this.backgroundGroup; return this.backgroundGroup;
} }

View File

@ -79,8 +79,8 @@ namespace pxsim.visuals {
public setBrick(brick: BrickView) { public setBrick(brick: BrickView) {
this.brick = brick; this.brick = brick;
this.brick.inject(this.scrollGroup); this.brick.inject(this.scrollGroup, this.theme);
this.brickLandscape.inject(this.scrollGroup); this.brickLandscape.inject(this.scrollGroup, this.theme);
this.brick.setSelected(false); this.brick.setSelected(false);
this.brickLandscape.setSelected(true); this.brickLandscape.setSelected(true);
this.brickLandscape.setVisible(false); this.brickLandscape.setVisible(false);
@ -212,16 +212,16 @@ namespace pxsim.visuals {
// Inject all wires // Inject all wires
for (let port = 0; port < DAL.NUM_OUTPUTS; port++) { for (let port = 0; port < DAL.NUM_OUTPUTS; port++) {
this.outputWires[port].inject(this.scrollGroup); this.outputWires[port].inject(this.scrollGroup, this.theme);
} }
for (let port = 0; port < DAL.NUM_INPUTS; port++) { for (let port = 0; port < DAL.NUM_INPUTS; port++) {
this.inputWires[port].inject(this.scrollGroup); this.inputWires[port].inject(this.scrollGroup, this.theme);
} }
// Inject all view containers // Inject all view containers
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
this.inputContainers[i].inject(this.scrollGroup); this.inputContainers[i].inject(this.scrollGroup, this.theme);
this.outputContainers[i].inject(this.scrollGroup); this.outputContainers[i].inject(this.scrollGroup, this.theme);
} }
// Inject all ports // Inject all ports
@ -253,6 +253,12 @@ namespace pxsim.visuals {
} }
public updateTheme(theme: IBoardTheme) { public updateTheme(theme: IBoardTheme) {
this.inputWires.forEach(n => {
n.updateTheme(theme);
})
this.outputWires.forEach(n => {
n.updateTheme(theme);
})
this.inputs.forEach(n => { this.inputs.forEach(n => {
n.updateTheme(theme); n.updateTheme(theme);
}) })

View File

@ -19,8 +19,9 @@ namespace pxsim.visuals {
public abstract getInnerWidth(): number; public abstract getInnerWidth(): number;
public abstract getInnerHeight(): number; public abstract getInnerHeight(): number;
public inject(parent: SVGElement, width?: number, visible = true) { public inject(parent: SVGElement, theme: IBoardTheme, width?: number, visible = true) {
this.width = width; this.width = width;
this.theme = theme;
parent.appendChild(this.getView()); parent.appendChild(this.getView());
if (visible) { if (visible) {
@ -276,7 +277,7 @@ namespace pxsim.visuals {
} }
public addView(view: View) { public addView(view: View) {
view.inject(this.element); view.inject(this.element, this.theme);
} }
public clear() { public clear() {

View File

@ -41,6 +41,11 @@ namespace pxsim.visuals {
return this.wire; return this.wire;
} }
public updateThemeCore() {
let theme = this.theme;
this.path.setAttribute('stroke', theme.wireColor);
}
updatePath() { updatePath() {
if (!this.hasDimensions) return; if (!this.hasDimensions) return;
const height = this.endY - this.startY; const height = this.endY - this.startY;

View File

@ -155,22 +155,6 @@
} }
} }
/** high contrast **/
.hc {
.ui.menu, #downloadArea,
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item.active {
background-color: black !important;
color: white !important;
}
.ui.red.corner.label {
border-color: #d4000d!important;
}
.menubar .ui.menu.fixed .item.editor-menuitem .ui.grid {
border-color: white !important;
}
}
/******************************* /*******************************
Custom icons Custom icons
*******************************/ *******************************/