aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2024-04-24 15:58:26 +0300
committerHenry Jameson <me@hjkos.com>2024-04-24 15:58:26 +0300
commit6ff0a7f0215de1acd0490020b53485c45550df79 (patch)
tree7ead835abb83cbefe138164ee6a78a1fa9027380 /src/components/settings_modal/helpers
parentdef68e9cda881447bb2d278248635d7ff4f2498f (diff)
refactor sizesetting into unitsetting allowing more unit types with i18n support
Diffstat (limited to 'src/components/settings_modal/helpers')
-rw-r--r--src/components/settings_modal/helpers/unit_setting.js (renamed from src/components/settings_modal/helpers/size_setting.js)8
-rw-r--r--src/components/settings_modal/helpers/unit_setting.vue (renamed from src/components/settings_modal/helpers/size_setting.vue)19
2 files changed, 17 insertions, 10 deletions
diff --git a/src/components/settings_modal/helpers/size_setting.js b/src/components/settings_modal/helpers/unit_setting.js
index 12cef705..c9c23cb0 100644
--- a/src/components/settings_modal/helpers/size_setting.js
+++ b/src/components/settings_modal/helpers/unit_setting.js
@@ -17,6 +17,10 @@ export default {
units: {
type: Array,
default: () => allCssUnits
+ },
+ unitSet: {
+ type: String,
+ default: 'none'
}
},
computed: {
@@ -30,6 +34,10 @@ export default {
},
methods: {
...Setting.methods,
+ getUnitString (value) {
+ if (this.unitSet === 'none') return value
+ return this.$t(['settings', 'units', this.unitSet, value].join('.'))
+ },
updateValue (e) {
this.configSink(this.path, parseInt(e.target.value) + this.stateUnit)
},
diff --git a/src/components/settings_modal/helpers/size_setting.vue b/src/components/settings_modal/helpers/unit_setting.vue
index 6c3fbaeb..d6aafe26 100644
--- a/src/components/settings_modal/helpers/size_setting.vue
+++ b/src/components/settings_modal/helpers/unit_setting.vue
@@ -1,7 +1,7 @@
<template>
<span
v-if="matchesExpertLevel"
- class="SizeSetting"
+ class="UnitSetting"
>
<label
:for="path"
@@ -23,7 +23,7 @@
:id="path"
:model-value="stateUnit"
:disabled="disabled"
- class="css-unit-input"
+ class="unit-input unstyled"
@change="updateUnit"
>
<option
@@ -31,7 +31,7 @@
:key="option"
:value="option"
>
- {{ option }}
+ {{ getUnitString(option) }}
</option>
</Select>
{{ ' ' }}
@@ -42,20 +42,19 @@
</span>
</template>
-<script src="./size_setting.js"></script>
+<script src="./unit_setting.js"></script>
<style lang="scss">
-.SizeSetting {
+.UnitSetting {
.number-input {
max-width: 6.5em;
+ text-align: right;
}
- .css-unit-input,
- .css-unit-input select {
- margin-left: 0.5em;
- width: 4em;
- max-width: 4em;
+ .unit-input,
+ .unit-input select {
min-width: 4em;
+ width: auto;
}
}