Skip to content

Commit e8e31b9

Browse files
committed
Asynchronously update CSS variables to the activity values
1 parent d174406 commit e8e31b9

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

src/components/Activity.vue

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<template>
2-
<div>
2+
<div :style="cssProps">
33
<v-app id="inspire">
44
<sidebar mobileDrawAnim=0></sidebar>
55
<v-toolbar color="indigo" dark fixed app>
66
<template v-if="activity.drawerEnabled">
7-
<v-toolbar-side-icon @click.stop="toggleSidebar()"></v-toolbar-side-icon>
7+
<v-toolbar-side-icon @click.stop="toggleSidebar()"></v-toolbar-side-icon>
88
</template>
99
<template v-if="activity.showName">
10-
<v-toolbar-title>
11-
{{ activity.name }}
12-
</v-toolbar-title>
13-
</template>
10+
<v-toolbar-title>
11+
{{ activity.name }}
12+
</v-toolbar-title>
13+
</template>
1414
<v-spacer></v-spacer>
1515
<v-toolbar-items>
1616
<!-- template serves as an invisible wrapper to conditional render more than one element -->
1717
<template v-if="status == 200">
18-
1918
<v-btn v-on:click="runProgramLegacy()" flat>
2019
<v-icon>play_arrow</v-icon>
2120
Esegui
2221
</v-btn>
23-
2422
<!--
2523
<v-btn v-if="isDefault != 'True'" @click="overwrite = 1, saveProgram()" flat>
2624
<v-icon>save</v-icon>
@@ -65,6 +63,7 @@
6563
</v-toolbar-items>
6664
</v-toolbar>
6765
<v-content>
66+
6867
<div style="height: 480px; width: 600px;">
6968
<div ref="blocklyTotal" style="height: 100%; width: 100%;" class="blocklyTotal">
7069
<div ref="blocklyArea" style="height: 100%; width: 100%;" class="blocklyArea">
@@ -73,6 +72,7 @@
7372
</div>
7473
</div>
7574
</div>
75+
7676
</v-content>
7777
<!-- Runtime modal -->
7878
<v-dialog v-model="runtimeDialog" width="500">
@@ -81,15 +81,14 @@
8181
Esecuzione
8282
</v-card-title>
8383
<template v-if="activity.exec.camera">
84-
<v-card-text v-if="runtimeDialog">
85-
<v-img v-if="runtimeDialog" :src="webcamStream" />
86-
</v-card-text>
87-
</template>
88-
84+
<v-card-text v-if="runtimeDialog">
85+
<v-img v-if="runtimeDialog" :src="webcamStream" />
86+
</v-card-text>
87+
</template>
8988
<v-divider></v-divider>
9089
<template v-if="activity.exec.log">
91-
{{ log }}
92-
</template>
90+
{{ log }}
91+
</template>
9392
<v-card-actions>
9493
<v-spacer></v-spacer>
9594
<v-btn color="primary" flat @click="runtimeDialog = false; stopProgram()">
@@ -280,6 +279,11 @@ export default {
280279
import('vue-prism-component')
281280
},
282281
data: () => ({
282+
cssProps : {
283+
'--bodyFont': 'Roboto',
284+
'--codeFont': 'Ubuntu Mono',
285+
},
286+
activityStyle: null,
283287
activity: null,
284288
log: null,
285289
settings: null,
@@ -337,6 +341,7 @@ export default {
337341
.then(function(response) {
338342
console.log("Activity loaded", response.data)
339343
this.activity = response.data
344+
this.updateCssProps()
340345
}.bind(this))
341346
342347
@@ -358,6 +363,29 @@ export default {
358363
359364
},
360365
methods: {
366+
updateCssProps() {
367+
console.log("Updating CSS Props")
368+
let bodyFont = this.activity.bodyFont
369+
let fontFamilyBody = ''
370+
if (bodyFont == 'opensans') {
371+
fontFamilyBody = 'Open Sans'
372+
} else if (bodyFont == 'roboto') {
373+
fontFamilyBody = 'Roboto'
374+
}
375+
let codeFont = this.activity.codeFont
376+
let fontFamilyCode = ''
377+
if (codeFont == 'ubuntumono') {
378+
fontFamilyCode = 'Ubuntu Mono'
379+
} else if (codeFont == 'robotomono') {
380+
fontFamilyCode = 'Roboto Mono'
381+
}
382+
383+
this.cssProps = {
384+
'--bodyFont': fontFamilyBody,
385+
'--codeFont': fontFamilyCode,
386+
}
387+
},
388+
361389
initBlockly: function(settings) {
362390
// Extend the default blocks set
363391
this.blocksExtensions(settings);
@@ -1829,6 +1857,15 @@ export default {
18291857
18301858
</script>
18311859
<style scoped>
1860+
.application {
1861+
font-family: var(--bodyFont)
1862+
}
1863+
1864+
pre,
1865+
code {
1866+
font-family: var(--codeFont)
1867+
}
1868+
18321869
.blocklyDiv {
18331870
position: absolute;
18341871
}

src/components/ActivityEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export default {
350350
defaultView: 'blocks',
351351
viste: [
352352
{ text: 'Blocchi', value: 'blocks' },
353-
{ text: 'Esecuzione', value: 'exec', },
353+
{ text: 'Esecuzione', value: 'exec', disabled: true},
354354
{ text: 'Python', value: 'python', disabled: true }
355355
],
356356
};

0 commit comments

Comments
 (0)