1
0
Fork 0

Add markown compatible help icon in comment textarea

This commit is contained in:
kimsible 2020-08-07 19:00:51 +02:00 committed by Chocobozzz
parent cb54210c19
commit 3c176894ba
7 changed files with 65 additions and 5 deletions

View File

@ -3,6 +3,20 @@
<img [src]="getAvatarUrl()" alt="Avatar" />
<div class="form-group">
<my-help class="markdown-guide" helpType="custom" iconName="markdown" i18n-title title="Markdown compatible">
<ng-template ptTemplate="customHtml">
<div i18n>
Markdown compatible that supports:
<ul>
<li>Emphasis: <strong>**bold**</strong>, <i>_italic_</i></li>
<li>Links</li>
<li>Break lines</li>
<li>Lists</li>
</ul>
</div>
</ng-template>
</my-help>
<textarea i18n-placeholder placeholder="Add comment..." myAutoResize
[readonly]="(user === null) ? true : false"
(click)="openVisitorModal($event)"

View File

@ -19,11 +19,49 @@ form {
.form-group {
flex-grow: 1;
margin: 0;
position: relative;
$peertube-textarea-height: 60px;
$markdown-icon-height: 18px;
$markdown-icon-width: 30px;
.markdown-guide {
position: absolute;
top: 5px;
left: 4px;
@media screen and (max-width: 600px) {
left: 0;
}
::ng-deep .help-tooltip-button {
my-global-icon {
height: $markdown-icon-height;
width: $markdown-icon-width;
svg {
opacity: 0.5;
}
}
&:focus, &:active, &:hover {
my-global-icon svg {
opacity: 1;
}
}
}
}
textarea {
@include peertube-textarea(100%, 60px);
@include peertube-textarea(100%, $peertube-textarea-height);
@include button-focus(pvar(--mainColorLightest));
text-indent: $markdown-icon-width;
@media screen and (max-width: 600px) {
text-indent: $markdown-icon-width + 5px;
}
&:focus::placeholder {
opacity: 0;
}

View File

@ -4,6 +4,7 @@ import { HooksService } from '@app/core/plugins/hooks.service'
const icons = {
// misc icons
'npm': require('!!raw-loader?!../../../assets/images/misc/npm.svg').default,
'markdown': require('!!raw-loader?!../../../assets/images/misc/markdown.svg').default,
'language': require('!!raw-loader?!../../../assets/images/misc/language.svg').default,
'video-lang': require('!!raw-loader?!../../../assets/images/misc/video-lang.svg').default,
'support': require('!!raw-loader?!../../../assets/images/misc/support.svg').default,

View File

@ -26,8 +26,8 @@
role="button"
class="help-tooltip-button"
container="body"
title="Get help"
i18n-title
[title]="title"
tabindex=0
popoverClass="help-popover"
[attr.aria-pressed]="isPopoverOpened"
[ngbPopover]="tooltipTemplate"
@ -36,5 +36,5 @@
(onHidden)="onPopoverHidden()"
(onShown)="onPopoverShown()"
>
<my-global-icon iconName="help"></my-global-icon>
<my-global-icon [iconName]="iconName"></my-global-icon>
</span>

View File

@ -5,14 +5,17 @@
cursor: pointer;
border: none;
margin: 5px;
my-global-icon {
width: 17px;
position: relative;
top: -1px;
margin: 5px;
@include apply-svg-color(pvar(--greyForegroundColor))
}
@include disable-outline;
}
::ng-deep {

View File

@ -1,5 +1,6 @@
import { AfterContentInit, Component, ContentChildren, Input, OnChanges, OnInit, QueryList, TemplateRef } from '@angular/core'
import { MarkdownService } from '@app/core'
import { GlobalIconName } from '@app/shared/shared-icons'
import { PeerTubeTemplateDirective } from '../angular'
@Component({
@ -11,6 +12,8 @@ import { PeerTubeTemplateDirective } from '../angular'
export class HelpComponent implements OnInit, OnChanges, AfterContentInit {
@Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom'
@Input() tooltipPlacement = 'right auto'
@Input() iconName: GlobalIconName = 'help'
@Input() title = $localize`Get help`
@ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'preHtml' | 'customHtml' | 'postHtml'>>

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="24" viewBox="0 0 208 128"><rect width="198" height="118" x="5" y="5" ry="10" stroke="#000" stroke-width="10" fill="none"/><path d="M30 98V30h20l20 25 20-25h20v68H90V59L70 84 50 59v39zm125 0l-30-33h20V30h20v35h20z"/></svg>

After

Width:  |  Height:  |  Size: 281 B