-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ridzimeko/dx-alternative
feat: implement alternative translation
- Loading branch information
Showing
4 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
export let alternatives: string[]; | ||
</script> | ||
|
||
<div class="dx-alternatives"> | ||
{#if alternatives.length} | ||
<div class="dx-alternatives-container"> | ||
<h4 class="dx-alternatives-title">Alternatives :</h4> | ||
{#each alternatives as alt} | ||
<p class="dx-alternatives-text">{alt}</p> | ||
{/each} | ||
</div> | ||
{/if} | ||
</div> | ||
|
||
<style scoped> | ||
.dx-alternatives-container { | ||
border: 1px solid var(--pico-form-element-border-color); | ||
border-right: 0; | ||
border-bottom: 0; | ||
background-color: var(--pico-form-element-background-color); | ||
width: 100%; | ||
padding: 0.4rem 1.2rem 1rem 1.2rem; | ||
max-height: 200px; | ||
overflow: auto; | ||
} | ||
.dx-alternatives-title { | ||
font-size: 1em; | ||
color: var(--pico-muted-color); | ||
margin-left: 0; | ||
padding-top: 0.4rem; | ||
} | ||
.dx-alternatives-text { | ||
margin: 0.2rem 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script lang="ts"> | ||
import debounce from '$lib/actions/debounce'; | ||
import { createEventDispatcher } from 'svelte'; | ||
const dispatch = createEventDispatcher(); | ||
export let value = ''; | ||
function handleValue() { | ||
dispatch('dx-input', { value }); | ||
} | ||
</script> | ||
|
||
<div> | ||
<textarea | ||
style="resize: none; margin: 0; height: 100%;" | ||
use:debounce={{ value, func: handleValue, duration: 600 }} | ||
bind:value | ||
placeholder="Enter text here to translate..." | ||
aria-label="Translate text input" | ||
></textarea> | ||
</div> |
14 changes: 10 additions & 4 deletions
14
src/lib/components/Textarea.svelte → src/lib/components/DXTextareaResult.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters