Skip to content

Commit

Permalink
#6687 make improve fonts ui option work in lab
Browse files Browse the repository at this point in the history
  • Loading branch information
piorek committed Jun 5, 2018
1 parent bb80452 commit 0104f51
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 4 deletions.
3 changes: 2 additions & 1 deletion js/lab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"files": [
"dist/**/*.js",
"lib/*",
"src/theme/static/*.css"
"src/theme/static/*.css",
"src/theme/static/fonts/**/*"
]
}
22 changes: 22 additions & 0 deletions js/lab/src/plugin/UIOptionFeaturesHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class UIOptionFeaturesHelper {
private showPublicationFeature: ShowPublicationFeature;
private autoCloseBracketsFeature: AutoCloseBracketsFeature;
private autoSaveFeature: AutoSaveFeature;
private improveFontsFeature: ImproveFontsFeature;

constructor(
private app: JupyterLab,
Expand All @@ -39,6 +40,7 @@ export default class UIOptionFeaturesHelper {
this.showPublicationFeature = new ShowPublicationFeature(this.panel);
this.autoCloseBracketsFeature = new AutoCloseBracketsFeature(this.panel);
this.autoSaveFeature = new AutoSaveFeature(this.settings, this.app.commands);
this.improveFontsFeature = new ImproveFontsFeature();

this.app.shell.activeChanged.connect((sender, args) => {
if (args.newValue !== this.panel) {
Expand Down Expand Up @@ -71,12 +73,14 @@ export default class UIOptionFeaturesHelper {
this.showPublicationFeature.init(data.beakerx.ui_options.show_publication);
this.autoCloseBracketsFeature.init(data.beakerx.ui_options.auto_close)
this.autoSaveFeature.init(data.beakerx.ui_options.auto_save);
this.improveFontsFeature.init(data.beakerx.ui_options.improve_fonts);
}

private updateFeatures(data): void {
this.showPublicationFeature.update(data.beakerx.ui_options.show_publication);
this.autoCloseBracketsFeature.update(data.beakerx.ui_options.auto_close)
this.autoSaveFeature.update(data.beakerx.ui_options.auto_save);
this.improveFontsFeature.update(data.beakerx.ui_options.improve_fonts);
}

private loadSettings(): Promise<any> {
Expand Down Expand Up @@ -165,3 +169,21 @@ class AutoSaveFeature implements IUIOptionsFeature {
});
}
}

class ImproveFontsFeature implements IUIOptionsFeature {

public init(isEnabled: boolean): void {
if (isEnabled) {
document.body.classList.add('improveFonts');
}
}

public update(isEnabled: boolean): void {
if (isEnabled) {
document.body.classList.add('improveFonts');
} else {
document.body.classList.remove('improveFonts');
}
}

}
54 changes: 52 additions & 2 deletions js/lab/src/theme/static/fonts.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,56 @@
* limitations under the License.
*/

body {
@font-face {
font-family: 'Roboto Mono';
src: url('fonts/robotomono/robotomono.woff') format('woff'),
url('fonts/robotomono/robotomono.ttf') format('truetype');

font-style: normal;
font-weight: normal;
}

@font-face {
font-family: 'Roboto Mono';
src: url('fonts/robotomono/robotomono-bold.woff') format('woff'),
url('fonts/robotomono/robotomono-bold.ttf') format('truetype');
font-weight: bold;
}

@font-face {
font-family: 'Lato';
src: url('fonts/lato/Lato-Regular.woff') format('woff'),
url('fonts/lato/Lato-Regular.ttf') format('truetype');

font-style: normal;
font-weight: normal;
}

@font-face {
font-family: 'Lato';
src: url('fonts/lato/Lato-Black.woff') format('woff'),
url('fonts/lato/Lato-Black.ttf') format('truetype');
font-weight: bold;
}

.improveFonts .CodeMirror pre,
.improveFonts .rendered_html pre,
.improveFonts .rendered_html code,
.improveFonts .output_area pre {
font-family: "Roboto Mono", monospace, sans-serif;
}

div.output_text {
line-height: 1.3em;
}

.improveFonts .widget-html-content,
.improveFonts .rendered_html,
.improveFonts .cm-header-1,
.improveFonts .cm-header-2,
.improveFonts .cm-header-3,
.improveFonts .cm-header-4,
.improveFonts .cm-header-5,
.improveFonts .cm-header-6 {
font-family: "Lato", Helvetica, sans-serif;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion js/notebook/src/tree/Widgets/UIOptions/UIOptionsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class UIOptionsWidget extends Widget implements UIOptionsWidgetInterface
id: 'improve_fonts',
name: 'improve_fonts',
label: 'Customize fonts (Roboto Mono and Lato)',
isLabSupported: false,
isLabSupported: true,
},
{
id: 'show_publication',
Expand Down

0 comments on commit 0104f51

Please sign in to comment.