Skip to content

Commit

Permalink
Fix Key Legend Scaling (qmk#724)
Browse files Browse the repository at this point in the history
* fix object types of SCALE, KEY_X_SPACING and KEY_Y_SPACING

Need Numbers instead of Strings.

* use new key legend scaling

* linting

Co-authored-by: Yan-Fa Li <yanfali@gmail.com>
  • Loading branch information
noroadsleft and yanfali authored Apr 29, 2020
1 parent 2c5c639 commit ca433af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/components/BaseKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ export default {
if (this.inSwap) {
classes.push('swapme');
}
if (this.meta && this.meta.name.length >= 2) {
classes.push('smaller');
} else {
classes.push('thicker');
}
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 @@ -155,6 +150,13 @@ 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
6 changes: 3 additions & 3 deletions src/store/modules/keymap.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const mutations = {
KEY_X_SPACING,
KEY_Y_SPACING
} = state.config;
Vue.set(state.config, 'SCALE', (defaults.MAX_X / max.x).toFixed(3));
Vue.set(state.config, 'SCALE', (defaults.MAX_X / max.x).toFixed(3) * 1);
Vue.set(state.config, 'KEY_WIDTH', (KEY_WIDTH *= state.config.SCALE));
Vue.set(state.config, 'KEY_HEIGHT', (KEY_HEIGHT *= state.config.SCALE));
Vue.set(
Expand All @@ -331,12 +331,12 @@ const mutations = {
Vue.set(
state.config,
'KEY_X_SPACING',
(KEY_X_SPACING *= state.config.SCALE)
(KEY_X_SPACING *= state.config.SCALE).toFixed(3) * 1
);
Vue.set(
state.config,
'KEY_Y_SPACING',
(KEY_Y_SPACING *= state.config.SCALE)
(KEY_Y_SPACING *= state.config.SCALE).toFixed(3) * 1
);
},
initKeymap(state, { layout, layer, code = 'KC_NO' }) {
Expand Down

0 comments on commit ca433af

Please sign in to comment.