aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/unit_setting.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2024-05-22 12:25:24 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2024-05-22 12:25:24 +0000
commitfd1011f622870385d8a694d60b66269e731b36cd (patch)
tree57e6766d33235f1a2c16af7ff21260cb46777c99 /src/components/settings_modal/helpers/unit_setting.js
parent3e99006e2ab06d2c8ade2eb20e12b1d2fbbcaac2 (diff)
parenteb27f1205b7bf077b81d698d24c2be656cc59023 (diff)
Merge branch 'scrobbles-age' into 'develop'
Add setting to only show scrobbles newer than certain age. See merge request pleroma/pleroma-fe!1904
Diffstat (limited to 'src/components/settings_modal/helpers/unit_setting.js')
-rw-r--r--src/components/settings_modal/helpers/unit_setting.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/components/settings_modal/helpers/unit_setting.js b/src/components/settings_modal/helpers/unit_setting.js
new file mode 100644
index 00000000..c9c23cb0
--- /dev/null
+++ b/src/components/settings_modal/helpers/unit_setting.js
@@ -0,0 +1,48 @@
+import Select from 'src/components/select/select.vue'
+import Setting from './setting.js'
+
+export const allCssUnits = ['cm', 'mm', 'in', 'px', 'pt', 'pc', 'em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', '%']
+export const defaultHorizontalUnits = ['px', 'rem', 'vw']
+export const defaultVerticalUnits = ['px', 'rem', 'vh']
+
+export default {
+ ...Setting,
+ components: {
+ ...Setting.components,
+ Select
+ },
+ props: {
+ ...Setting.props,
+ min: Number,
+ units: {
+ type: Array,
+ default: () => allCssUnits
+ },
+ unitSet: {
+ type: String,
+ default: 'none'
+ }
+ },
+ computed: {
+ ...Setting.computed,
+ stateUnit () {
+ return this.state.replace(/\d+/, '')
+ },
+ stateValue () {
+ return this.state.replace(/\D+/, '')
+ }
+ },
+ 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)
+ },
+ updateUnit (e) {
+ this.configSink(this.path, this.stateValue + e.target.value)
+ }
+ }
+}