Files
huly-platform/packages/text-editor/src/components/ReferenceInput.svelte
T
2021-12-03 10:15:21 +01:00

169 lines
4.1 KiB
Svelte

<!--
// Copyright © 2020 Anticrm Platform Contributors.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import Send from './icons/Send.svelte'
import Attach from './icons/Attach.svelte'
import Emoji from './icons/Emoji.svelte'
import GIF from './icons/GIF.svelte'
import TextStyle from './icons/TextStyle.svelte'
import TextEditor from './TextEditor.svelte'
const dispatch = createEventDispatcher()
export let content: string = ''
export let showSend = true
let textEditor: TextEditor
export function submit (): void {
textEditor.submit()
}
</script>
<div class="ref-container">
<div class="textInput">
<div class="inputMsg">
<TextEditor bind:content={content} bind:this={textEditor} on:content={
ev => {
dispatch('message', ev.detail)
content = ''
textEditor.clear()
}
}/>
</div>
{#if showSend}
<button class="sendButton" on:click={submit}><div class="icon"><Send/></div></button>
{/if}
</div>
<div class="buttons">
<div class="tool"><Attach /></div>
<div class="tool"><TextStyle /></div>
<div class="tool"><Emoji /></div>
<div class="tool"><GIF /></div>
</div>
</div>
<style lang="scss">
.ref-container {
display: flex;
flex-direction: column;
min-height: 4.5rem;
.textInput {
display: flex;
justify-content: space-between;
align-items: flex-end;
min-height: 2.75rem;
padding: .75rem 1rem;
background-color: var(--theme-bg-accent-color);
border: 1px solid var(--theme-bg-accent-color);
border-radius: .75rem;
.inputMsg {
display: flex;
align-self: center;
align-items: center;
width: 100%;
height: 100%;
color: var(--theme-content-color);
background-color: transparent;
border: none;
outline: none;
// &.thread {
// width: auto;
// }
// .flex-column {
// display: flex;
// flex-direction: column;
// align-items: center;
// }
// .flex-row {
// display: flex;
// flex-direction: row;
// align-items: flex-end;
// }
// .edit-box-horizontal {
// width: 100%;
// height: 100%;
// margin-top: 7px;
// align-self: center;
// }
// .edit-box-vertical {
// width: 100%;
// height: 100%;
// margin: 4px;
// }
}
.sendButton {
display: flex;
justify-content: center;
align-items: center;
margin-left: 8px;
padding: 0;
width: 20px;
height: 20px;
background-color: transparent;
border: 1px solid transparent;
border-radius: .25rem;
outline: none;
cursor: pointer;
.icon {
width: 20px;
height: 20px;
opacity: 0.3;
cursor: pointer;
&:hover {
opacity: 1;
}
}
&:focus {
border: 1px solid var(--primary-button-focused-border);
box-shadow: 0 0 0 3px var(--primary-button-outline);
& > .icon {
opacity: 1;
}
}
}
}
.buttons {
margin: 10px 0 0 8px;
display: flex;
.tool {
display: flex;
justify-content: center;
align-items: center;
width: 20px;
height: 20px;
opacity: 0.3;
cursor: pointer;
&:hover {
opacity: 1;
}
}
.tool + .tool {
margin-left: 16px;
}
}
}
</style>