UPD: Refactoring

This commit is contained in:
Robert Kossessa
2024-01-24 01:12:43 +01:00
parent 077e3f48b8
commit 5720effb78
15 changed files with 100 additions and 83 deletions

View File

@@ -1,9 +1,9 @@
<script setup> <script setup>
import ProfileManager from '@/components/ProfileManager.vue' import ProfileManager from '@/components/ProfileManager.vue'
import DevicePreview from '@/DevicePreview.vue' import DevicePreview from '@/components/device-gui/DevicePreview.vue'
import ConfigPane from '@/ConfigPane.vue' import ConfigPane from '@/components/ConfigPane.vue'
import Navbar from '@/Navbar.vue' import Navbar from '@/components/Navbar.vue'
import ConfigSelect from '@/ConfigSelect.vue' import ConfigSelect from '@/components/ConfigSelect.vue'
import { ref } from 'vue' import { ref } from 'vue'
const currentConfigPage = ref('program_settings') const currentConfigPage = ref('program_settings')

View File

@@ -1,25 +0,0 @@
<template>
<div>
<component :is="configPages[page]" />
</div>
</template>
<script setup>
import LEDsConfig from '@/LEDsConfig.vue'
import ProgramConfig from '@/ProgramConfig.vue'
import MappingConfig from '@/MappingConfig.vue'
import HapticConfig from '@/HapticConfig.vue'
const props = defineProps({
page: {
type: String,
default: 'program_settings',
},
})
const configPages = {
program_settings: ProgramConfig,
feedback_designer: HapticConfig,
mapping_configuration: MappingConfig,
light_designer: LEDsConfig,
}
</script>

View File

@@ -0,0 +1,38 @@
<template>
<div>
<div
class="px-6 h-20 flex items-center bg-zinc-900 bg-opacity-40"
@mouseenter="$refs.configPaneTitle.scramble(0.15, 100)">
<div>
<h1 class="text-lg">
<ScrambleText ref="configPaneTitle" class="align-middle" :text="$t(`config_options.${page}.title`)" />
</h1>
<p class="text-xs text-muted-foreground">
{{ $t(`config_options.${page}.subtitle`) }}
</p>
</div>
</div>
<component :is="configPages[page]" />
</div>
</template>
<script setup>
import LEDsConfig from '@/components/config/LEDsConfig.vue'
import ProgramConfig from '@/components/config/ProgramConfig.vue'
import MappingConfig from '@/components/config/MappingConfig.vue'
import HapticConfig from '@/components/config/HapticConfig.vue'
import ScrambleText from '@/components/effects/ScrambleText.vue'
defineProps({
page: {
type: String,
default: 'program_settings',
},
})
const configPages = {
program_settings: ProgramConfig,
feedback_designer: HapticConfig,
mapping_configuration: MappingConfig,
light_designer: LEDsConfig,
}
</script>

View File

@@ -10,7 +10,7 @@
@mouseenter="$refs.configSelect[index].scramble(0.15, 100)"> @mouseenter="$refs.configSelect[index].scramble(0.15, 100)">
<div> <div>
<h1 class="text-lg" :class="{'text-muted-foreground': config.disabled}"> <h1 class="text-lg" :class="{'text-muted-foreground': config.disabled}">
<ScrambleReveal ref="configSelect" class="align-middle" :text="$t(`config_options.${config.id}.title`)" /> <ScrambleText ref="configSelect" class="align-middle" :text="$t(`config_options.${config.id}.title`)" />
<Badge <Badge
v-if="config.hasOwnProperty('badgeKey')" v-if="config.hasOwnProperty('badgeKey')"
v-t="config.badgeKey" v-t="config.badgeKey"
@@ -25,7 +25,7 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import ScrambleReveal from '@/components/ScrambleText.vue' import ScrambleText from '@/components/effects/ScrambleText.vue'
import { Badge } from '@/components/ui/badge/index.js' import { Badge } from '@/components/ui/badge/index.js'
const config_tabs = ref([ const config_tabs = ref([

View File

@@ -2,7 +2,7 @@
<div> <div>
<div class="p-4"> <div class="p-4">
<h1 class="text-lg"> <h1 class="text-lg">
<ScrambleReveal :text="$t('profiles.title')" /> <ScrambleText :text="$t('profiles.title')" />
</h1> </h1>
<p class="text-xs text-muted-foreground"> <p class="text-xs text-muted-foreground">
{{ $t('profiles.subtitle') }} {{ $t('profiles.subtitle') }}
@@ -10,15 +10,19 @@
</div> </div>
<Separator /> <Separator />
<Pop /> <Pop />
<DeviceBar />
<SchemaTest />
</div> </div>
</template> </template>
<script> <script>
import Pop from '@/components/patterns/Pop.vue' import Pop from '@/components/old/Pop.vue'
import ScrambleReveal from '@/components/ScrambleText.vue' import ScrambleReveal from '@/components/effects/ScrambleText.vue'
import { Separator } from '@/components/ui/separator/index.js' import { Separator } from '@/components/ui/separator/index.js'
import SchemaTest from '@/components/SchemaTest.vue'
import DeviceBar from '@/components/device-gui/DeviceBar.vue'
export default { export default {
name: 'ProfileManager', name: 'ProfileManager',
components: { Separator, Pop, ScrambleReveal }, components: { DeviceBar: DeviceBar, SchemaTest, Separator, Pop, ScrambleText: ScrambleReveal },
} }
</script> </script>

View File

@@ -30,7 +30,7 @@
<TabsTrigger value="fd"> <TabsTrigger value="fd">
<div class="grid grid-flow-row auto-rows-max justify-items-center "> <div class="grid grid-flow-row auto-rows-max justify-items-center ">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-fd.svg"> <img src="../../assets/gui-ico/ico-fd.svg">
</div> </div>
<span <span
class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.fine_detents') class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.fine_detents')
@@ -40,7 +40,7 @@
<TabsTrigger value="cd"> <TabsTrigger value="cd">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-cd.svg"> <img src="../../assets/gui-ico/ico-cd.svg">
</div> </div>
<span <span
class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.coarse_detents') class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.coarse_detents')
@@ -50,7 +50,7 @@
<TabsTrigger value="vr"> <TabsTrigger value="vr">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-vf.svg"> <img src="../../assets/gui-ico/ico-vf.svg">
</div> </div>
<span <span
class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.viscous_rotation') class="text-xs leading-3 text-wrap">{{ $t('config_options.feedback_designer.feedback_type.viscous_rotation')
@@ -60,7 +60,7 @@
<TabsTrigger value="rt"> <TabsTrigger value="rt">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-rc.svg"> <img src="../../assets/gui-ico/ico-rc.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.feedback_designer.feedback_type.return_to_center') }} {{ $t('config_options.feedback_designer.feedback_type.return_to_center') }}

View File

@@ -29,7 +29,7 @@
<TabsTrigger value="fd"> <TabsTrigger value="fd">
<div class="grid grid-flow-row auto-rows-max justify-items-center "> <div class="grid grid-flow-row auto-rows-max justify-items-center ">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-fd.svg"> <img src="../../assets/gui-ico/ico-fd.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
Fine Detents Fine Detents
@@ -39,7 +39,7 @@
<TabsTrigger value="cd"> <TabsTrigger value="cd">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-cd.svg"> <img src="../../assets/gui-ico/ico-cd.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
Coarse Detents Coarse Detents
@@ -49,7 +49,7 @@
<TabsTrigger value="vr"> <TabsTrigger value="vr">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-vf.svg"> <img src="../../assets/gui-ico/ico-vf.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
Viscous Rotation Viscous Rotation
@@ -59,7 +59,7 @@
<TabsTrigger value="rt"> <TabsTrigger value="rt">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-rc.svg"> <img src="../../assets/gui-ico/ico-rc.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
Return to Center Return to Center

View File

@@ -30,7 +30,7 @@
<TabsTrigger value="fd"> <TabsTrigger value="fd">
<div class="grid grid-flow-row auto-rows-max justify-items-center "> <div class="grid grid-flow-row auto-rows-max justify-items-center ">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-key-o.svg"> <img src="../../assets/gui-ico/ico-key-o.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.mapping_configuration.key_mapping.switch.a') }} {{ $t('config_options.mapping_configuration.key_mapping.switch.a') }}
@@ -41,7 +41,7 @@
<TabsTrigger value="cd"> <TabsTrigger value="cd">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-key.svg"> <img src="../../assets/gui-ico/ico-key.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.mapping_configuration.key_mapping.switch.b') }} {{ $t('config_options.mapping_configuration.key_mapping.switch.b') }}
@@ -52,7 +52,7 @@
<TabsTrigger value="vr"> <TabsTrigger value="vr">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-key-g.svg"> <img src="../../assets/gui-ico/ico-key-g.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.mapping_configuration.key_mapping.switch.c') }} {{ $t('config_options.mapping_configuration.key_mapping.switch.c') }}
@@ -63,7 +63,7 @@
<TabsTrigger value="rt"> <TabsTrigger value="rt">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="size-16 mb-2"> <div class="size-16 mb-2">
<img src="@/assets/gui-ico/ico-key-d.svg"> <img src="../../assets/gui-ico/ico-key-d.svg">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.mapping_configuration.key_mapping.switch.d') }} {{ $t('config_options.mapping_configuration.key_mapping.switch.d') }}

View File

@@ -30,7 +30,7 @@
<TabsTrigger value="fd"> <TabsTrigger value="fd">
<div class="grid grid-flow-row auto-rows-max justify-items-center "> <div class="grid grid-flow-row auto-rows-max justify-items-center ">
<div class="w-24 size-w mb-2"> <div class="w-24 size-w mb-2">
<img src="@/assets/gui-ico/ico-usb-logo.svg" alt="usb-logo"> <img src="../../assets/gui-ico/ico-usb-logo.svg" alt="usb-logo">
</div> </div>
<span <span
class="text-xs leading-3 text-wrap">{{ $t('config_options.program_settings.connection_type.usb') class="text-xs leading-3 text-wrap">{{ $t('config_options.program_settings.connection_type.usb')
@@ -40,7 +40,7 @@
<TabsTrigger value="cd"> <TabsTrigger value="cd">
<div class="grid grid-flow-row auto-rows-max justify-items-center"> <div class="grid grid-flow-row auto-rows-max justify-items-center">
<div class="w-24 size-w mb-2"> <div class="w-24 size-w mb-2">
<img src="@/assets/gui-ico/ico-midi-logo.svg" alt="midi-logo"> <img src="../../assets/gui-ico/ico-midi-logo.svg" alt="midi-logo">
</div> </div>
<span class="text-xs leading-3 text-wrap"> <span class="text-xs leading-3 text-wrap">
{{ $t('config_options.program_settings.connection_type.midi') }} {{ $t('config_options.program_settings.connection_type.midi') }}

View File

@@ -14,9 +14,9 @@
</div> </div>
</template> </template>
<script> <script>
import QuickPreview from '@/components/patterns/QuickPreview.vue' import QuickPreview from '@/components/old/QuickPreview.vue'
import ScrambleReveal from '@/components/ScrambleText.vue' import ScrambleReveal from '@/components/effects/ScrambleText.vue'
import ConfigSelect from '@/ConfigSelect.vue' import ConfigSelect from '@/components/ConfigSelect.vue'
export default { export default {
name: 'DevicePreview', name: 'DevicePreview',

View File

@@ -28,6 +28,8 @@ const props = defineProps({
}, },
}) })
let scrambling = false
const content = ref('') const content = ref('')
function randomCharacter(characterSet = props.characterSet) { function randomCharacter(characterSet = props.characterSet) {
@@ -35,6 +37,8 @@ function randomCharacter(characterSet = props.characterSet) {
} }
function scramble(scrambleAmount = props.scrambleAmount, replaceInterval = props.replaceInterval, fillInterval = props.fillInterval, characterSet = props.characterSet, text = props.text) { function scramble(scrambleAmount = props.scrambleAmount, replaceInterval = props.replaceInterval, fillInterval = props.fillInterval, characterSet = props.characterSet, text = props.text) {
if (scrambling) return
scrambling = true
content.value = '' content.value = ''
const fillContent = function() { const fillContent = function() {
if (content.value.length < text.length) { if (content.value.length < text.length) {
@@ -59,6 +63,8 @@ function scramble(scrambleAmount = props.scrambleAmount, replaceInterval = props
const index = indices[Math.floor(Math.random() * indices.length)] const index = indices[Math.floor(Math.random() * indices.length)]
content.value = content.value.substring(0, index) + text.charAt(index) + content.value.substring(index + 1) content.value = content.value.substring(0, index) + text.charAt(index) + content.value.substring(index + 1)
setTimeout(replaceContent, replaceInterval * (1 + Math.random())) setTimeout(replaceContent, replaceInterval * (1 + Math.random()))
} else {
scrambling = false
} }
} }
replaceContent() replaceContent()

View File

@@ -12,18 +12,12 @@ import {
CommandShortcut, CommandShortcut,
} from '@/components/ui/command' } from '@/components/ui/command'
import { Input } from '@/components/ui/input' import { Input } from '@/components/ui/input'
import PixelBarTest from '@/components/device-gui/PixelBarTest.vue' import PixelBarTest from '@/components/device-gui/DeviceBar.vue'
import SchemaTest from '@/components/SchemaTest.vue' import SchemaTest from '@/components/SchemaTest.vue'
</script> </script>
<template> <template>
<div class="h-60">
<!-- Dumping ground for testing components -->
<PixelBarTest />
<SchemaTest />
<input <input
v-model="defaultName" v-model="defaultName"
type="text" type="text"
@@ -49,7 +43,7 @@ import SchemaTest from '@/components/SchemaTest.vue'
<CommandSeparator /> <CommandSeparator />
</Command> </Command>
</div>
</template> </template>
<script> <script>