Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative approach to font-sizing #726

Merged
merged 2 commits into from
Apr 30, 2020
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
14 changes: 6 additions & 8 deletions src/components/BaseKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default {
if (this.inSwap) {
classes.push('swapme');
}
if (this.meta && this.meta.name.length >= 2) {
classes.push('smaller');
}
const { KEY_WIDTH, KEY_HEIGHT } = this.config;
if (!isUndefined(this.meta) && !this.printable) {
if (this.colorwayOverride && this.colorwayOverride[this.meta.code]) {
Expand Down Expand Up @@ -150,13 +153,7 @@ export default {
if (this.x > 0) {
styles.push(`left: ${this.x}px;`);
}
if (this.meta && this.meta.name.length >= 2) {
let keySize = 0.61;
if (this.config.SCALE < 1) {
keySize *= (1 + this.config.SCALE) / 2;
}
styles.push(`font-size: ${keySize}rem;`);
}

return styles.join('');
}
},
Expand Down Expand Up @@ -262,11 +259,12 @@ export default {
transform: scale(0.8);
}
.key.smaller {
font-size: 0.61rem;
font-size: var(--default-smaller-key-font-size);
}
.key {
border-radius: 6px;
font-family: 'Montserrat', sans-serif;
font-size: var(--default-key-font-size);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 120%;
Expand Down
16 changes: 16 additions & 0 deletions src/components/BaseKeymap.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<script>
export default {
name: 'base-keymap',
computed: {
styles() {
let keySize = 0.85;
let smolKeySize = 0.61;
if (this.config.SCALE < 1) {
keySize *= (1 + this.config.SCALE) / 2;
smolKeySize *= (1 + this.config.SCALE) / 2;
}
return {
'--default-smaller-key-font-size': `${smolKeySize}rem`,
'--default-key-font-size': `${keySize}rem`,
width: `${this.width}px`,
height: `${this.height}px`
};
}
},
methods: {
calcKeyKeymapDims(w, h) {
return {
Expand Down
9 changes: 1 addition & 8 deletions src/components/PrintKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ export default {
'colorway',
'defaults'
]),
...mapState('app', ['layout', 'layouts', 'previewRequested']),
styles() {
let styles = [];
styles.push(`width: ${this.width}px;`);
styles.push(`height: ${this.height}px;`);
styles.push(`font-size: ${this.fontsize * this.config.SCALE}em;`);
return styles.join('');
}
...mapState('app', ['layout', 'layouts', 'previewRequested'])
},
methods: {
...mapMutations('keymap', ['resizeConfig']),
Expand Down
7 changes: 0 additions & 7 deletions src/components/VisualKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ export default {
'defaults'
]),
...mapState('app', ['layout', 'layouts', 'previewRequested']),
styles() {
let styles = [];
styles.push(`width: ${this.width}px;`);
styles.push(`height: ${this.height}px;`);
styles.push(`font-size: ${this.fontsize * 0.4}rem;`);
return styles.join('');
},
currentLayer() {
const layout = this.layouts[this.layout];
const keymap = this.getLayer(this.layer);
Expand Down
7 changes: 0 additions & 7 deletions src/components/VisualTesterKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ export default {
'activeLayoutMeta',
'codeToPosition'
]),
styles() {
const styles = [];
styles.push(`width: ${this.width}px;`);
styles.push(`height: ${this.height}px;`);
styles.push(`font-size: ${this.fontsize * this.config.SCALE}em;`);
return styles.join('');
},
layout: {
get() {
return this.$store.state.tester.layout;
Expand Down