Skip to content

Commit

Permalink
feat(new tool): Morse converter
Browse files Browse the repository at this point in the history
Fix #1001
  • Loading branch information
sharevb committed Apr 28, 2024
1 parent 80e46c9 commit 74527c0
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as morseConverter } from './morse-converter';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
Expand Down Expand Up @@ -100,6 +101,7 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
morseConverter,
],
},
{
Expand Down
12 changes: 12 additions & 0 deletions src/tools/morse-converter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ArrowsShuffle } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'Morse COde Converter',
path: '/morse-converter',
description: 'Encode/Decode to Morse code',
keywords: ['morse', 'converter'],
component: () => import('./morse-converter.vue'),
icon: ArrowsShuffle,
createdAt: new Date('2024-04-20'),
});
56 changes: 56 additions & 0 deletions src/tools/morse-converter/morse-converter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<script setup lang="ts">
import { decode, encode } from 'morsee';
import { computedCatch } from '@/composable/computed/catchedComputed';
const encodeInput = ref('');
const encodeOutput = computed(() => encode(encodeInput.value));
const decodeInput = ref('');
const [decodeOutput, decodeError] = computedCatch(() => decode(decodeInput.value), {
defaultValue: '',
defaultErrorMessage: 'Unable to decode your text',
});
</script>

<template>
<c-card title="Encode">
<div flex gap-3>
<c-input-text
v-model:value="encodeInput"
label="Your text:"
placeholder="The string to encode"
rows="4"
multiline raw-text monospace autosize flex-1
/>
</div>
<c-input-text
label="Your text encoded to Morse code:"
:value="encodeOutput"
rows="3"
placeholder="Your string encoded"
multiline monospace readonly autosize mt-5
/>
</c-card>
<c-card title="Decode">
<div flex gap-3>
<c-input-text
v-model:value="decodeInput"
label="Your Morse encoded text:"
placeholder="The string to decode"
rows="4"
multiline raw-text monospace autosize flex-1
/>
</div>
<c-alert v-if="decodeError" type="error" mt-12 title="Error while decoding">
{{ decodeError }}
</c-alert>
<c-input-text
v-else
label="Your decoded text:"
:value="decodeOutput"
placeholder="Your string decoded"
rows="3"
multiline monospace readonly autosize mt-5
/>
</c-card>
</template>

0 comments on commit 74527c0

Please sign in to comment.