Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions skillmap/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface AppProps {
skillMaps: { [key: string]: SkillMap };
activityOpen: boolean;
backgroundImageUrl: string;
pixelatedBackground?: boolean;
theme: SkillGraphTheme;
signedIn: boolean;
activityId: string;
Expand All @@ -71,7 +72,7 @@ interface AppProps {
dispatchSetPageTitle: (title: string) => void;
dispatchSetPageDescription: (description: string) => void;
dispatchSetPageInfoUrl: (infoUrl: string) => void;
dispatchSetPageBackgroundImageUrl: (backgroundImageUrl: string) => void;
dispatchSetPageBackgroundImageUrl: (backgroundImageUrl: string, pixelatedBackground?: boolean) => void;
dispatchSetPageBannerImageUrl: (bannerImageUrl: string) => void;
dispatchSetUser: (user: UserState) => void;
dispatchSetPageSourceUrl: (url: string, status: PageSourceStatus) => void;
Expand Down Expand Up @@ -228,13 +229,13 @@ class AppImpl extends React.Component<AppProps, AppState> {
}

if (metadata) {
const { title, description, infoUrl, backgroundImageUrl,
const { title, description, infoUrl, backgroundImageUrl, pixelatedBackground,
bannerImageUrl, theme, alternateSources } = metadata;
setPageTitle(title);
this.props.dispatchSetPageTitle(title);
if (description) this.props.dispatchSetPageDescription(description);
if (infoUrl) this.props.dispatchSetPageInfoUrl(infoUrl);
if (backgroundImageUrl) this.props.dispatchSetPageBackgroundImageUrl(backgroundImageUrl);
if (backgroundImageUrl) this.props.dispatchSetPageBackgroundImageUrl(backgroundImageUrl, pixelatedBackground);
if (bannerImageUrl) this.props.dispatchSetPageBannerImageUrl(bannerImageUrl);
if (alternateSources) this.props.dispatchSetPageAlternateUrls(alternateSources);
if (theme) this.props.dispatchSetPageTheme(theme);
Expand Down Expand Up @@ -432,7 +433,7 @@ class AppImpl extends React.Component<AppProps, AppState> {
}

render() {
const { skillMaps, activityOpen, backgroundImageUrl, theme } = this.props;
const { skillMaps, activityOpen, backgroundImageUrl, theme, pixelatedBackground } = this.props;
const { error, showingSyncLoader, forcelang } = this.state;
const maps = Object.keys(skillMaps).map((id: string) => skillMaps[id]);
const feedbackEnabled = pxt.U.ocvEnabled();
Expand All @@ -446,7 +447,7 @@ class AppImpl extends React.Component<AppProps, AppState> {
<div className={`skill-map-container ${activityOpen ? "hidden" : ""}`} style={{ backgroundColor: theme.backgroundColor }}>
{ error
? <div className="skill-map-error">{error}</div>
: <SkillGraphContainer maps={maps} backgroundImageUrl={backgroundImageUrl} backgroundColor={theme.backgroundColor} strokeColor={theme.strokeColor} />
: <SkillGraphContainer maps={maps} backgroundImageUrl={backgroundImageUrl} backgroundColor={theme.backgroundColor} pixelatedBackground={pixelatedBackground} strokeColor={theme.strokeColor} />
}
{ !error && <InfoPanel onFocusEscape={this.focusCurrentActivity} />}
</div>
Expand Down Expand Up @@ -568,6 +569,7 @@ function mapStateToProps(state: SkillMapState, ownProps: any) {
skillMaps: state.maps,
activityOpen: !!state.editorView,
backgroundImageUrl: state.backgroundImageUrl,
pixelatedBackground: state.pixelatedBackground,
theme: state.theme,
signedIn: state.auth.signedIn,
activityId: state.selectedItem?.activityId,
Expand Down
2 changes: 1 addition & 1 deletion skillmap/src/actions/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const dispatchResetUser = () => ({ type: actions.RESET_USER });
export const dispatchSetPageTitle = (title: string) => ({ type: actions.SET_PAGE_TITLE, title });
export const dispatchSetPageDescription = (description: string) => ({ type: actions.SET_PAGE_DESCRIPTION, description });
export const dispatchSetPageInfoUrl = (infoUrl: string) => ({ type: actions.SET_PAGE_INFO_URL, infoUrl });
export const dispatchSetPageBackgroundImageUrl = (backgroundImageUrl: string) => ({ type: actions.SET_PAGE_BACKGROUND_IMAGE_URL, backgroundImageUrl });
export const dispatchSetPageBackgroundImageUrl = (backgroundImageUrl: string, pixelatedBackground?: boolean) => ({ type: actions.SET_PAGE_BACKGROUND_IMAGE_URL, backgroundImageUrl, pixelatedBackground });
export const dispatchSetPageBannerImageUrl = (bannerImageUrl: string) => ({ type: actions.SET_PAGE_BANNER_IMAGE_URL, bannerImageUrl });
export const dispatchSetPageTheme = (theme: SkillGraphTheme) => ({ type: actions.SET_PAGE_THEME, theme });
export const dispatchSetPageSourceUrl = (url: string, status: PageSourceStatus) => ({ type: actions.SET_PAGE_SOURCE_URL, url, status });
Expand Down
11 changes: 9 additions & 2 deletions skillmap/src/components/SkillGraphContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface SkillGraphContainerProps {
graphs: SvgGraph[];
backgroundImageUrl: string;
backgroundColor: string;
pixelatedBackground?: boolean;
strokeColor: string;
graphSize: {
width: number;
Expand Down Expand Up @@ -50,7 +51,7 @@ export class SkillGraphContainerImpl extends React.Component<SkillGraphContainer
}

render() {
const { maps, graphs, graphSize, backgroundImageUrl, backgroundColor, strokeColor } = this.props;
const { maps, graphs, graphSize, backgroundImageUrl, pixelatedBackground, backgroundColor, strokeColor } = this.props;
const { backgroundSize } = this.state;
let altTextColor: string = 'black';
let backgroundAltText: string = lf("Background image for {0}", maps[0]?.displayName || lf("skillmap"));
Expand Down Expand Up @@ -97,7 +98,13 @@ export class SkillGraphContainerImpl extends React.Component<SkillGraphContainer
</svg>
</MenuBar>
{backgroundImageUrl && <div className="skill-graph-background">
<img src={backgroundImageUrl} alt={backgroundAltText} onLoad={this.onImageLoad} style={{ color: altTextColor }} />
<img
src={backgroundImageUrl}
className={pixelatedBackground ? "pixelated" : undefined}
alt={backgroundAltText}
onLoad={this.onImageLoad}
style={{ color: altTextColor }}
/>
</div>}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions skillmap/src/lib/skillMap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ interface PageMetadata {
description?: string;
infoUrl?: string;
backgroundImageUrl?: string;
pixelatedBackground?: boolean;
bannerImageUrl?: string; // Banner image in the info panel when no activity is selected
theme?: SkillGraphTheme
alternateSources?: string[]; // List of alternate pageSourceUrls to import user projects from
Expand Down
1 change: 1 addition & 0 deletions skillmap/src/lib/skillMapParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ function inflateMetadata(section: MarkdownSection): PageMetadata {
description: section.attributes["description"],
infoUrl: cleanInfoUrl(section.attributes["infourl"]),
backgroundImageUrl: section.attributes["backgroundurl"],
pixelatedBackground: isTrue(section.attributes["pixelatedbackground"]),
bannerImageUrl: section.attributes["bannerurl"],
alternateSources: parseList(section.attributes["alternatesources"]),
theme: {
Expand Down
5 changes: 4 additions & 1 deletion skillmap/src/store/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface SkillMapState {
description: string;
infoUrl?: string;
backgroundImageUrl?: string;
pixelatedBackground?: boolean;
bannerImageUrl?: string;
user: UserState;
pageSourceUrl: string;
Expand Down Expand Up @@ -124,6 +125,7 @@ const topReducer = (state: SkillMapState = initialState, action: any): SkillMapS
description: initialState.description,
infoUrl: initialState.infoUrl,
backgroundImageUrl: undefined,
pixelatedBackground: undefined,
bannerImageUrl: undefined,
alternateSourceUrls: undefined,
theme: {
Expand Down Expand Up @@ -326,7 +328,8 @@ const topReducer = (state: SkillMapState = initialState, action: any): SkillMapS
case actions.SET_PAGE_BACKGROUND_IMAGE_URL:
return {
...state,
backgroundImageUrl: action.backgroundImageUrl
backgroundImageUrl: action.backgroundImageUrl,
pixelatedBackground: action.pixelatedBackground
}
case actions.SET_PAGE_BANNER_IMAGE_URL:
return {
Expand Down
4 changes: 4 additions & 0 deletions skillmap/src/styles/skillgraph.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
max-height: 100%;
}

.skill-graph-background img.pixelated {
image-rendering: pixelated;
}

/*******************************/
/***** HIGH CONTRAST *****/
/*******************************/
Expand Down