Skip to content

Commit

Permalink
umputun#299 add italic format button
Browse files Browse the repository at this point in the history
  • Loading branch information
Mavrin committed Apr 12, 2019
1 parent eb7ba37 commit cffaa71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions web/app/@types/markdown-toolbar-element/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ declare namespace JSX {
'markdown-toolbar': {
for: string;
children?: any;
className: string;
};
'md-bold': any;
'md-header': any;
'md-italic': any;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
markdown-toolbar {
.input__toolbar {
display: block;
float: right;
}
Expand Down
13 changes: 13 additions & 0 deletions web/app/components/input/markdown-toolbar-icons/italic-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @jsx h */
import { h } from 'preact';

export default function ItalicIcon() {
return (
<svg className="input__toolbar-icon" viewBox="0 0 6 16" version="1.1" width="6" height="16" aria-hidden="true">
<path
fill-rule="evenodd"
d="M2.81 5h1.98L3 14H1l1.81-9zm.36-2.7c0-.7.58-1.3 1.33-1.3.56 0 1.13.38 1.13 1.03 0 .75-.59 1.3-1.33 1.3-.58 0-1.13-.38-1.13-1.03z"
/>
</svg>
);
}
7 changes: 6 additions & 1 deletion web/app/components/input/markdown-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@ import { h, Component, RenderableProps } from 'preact';
import '@github/markdown-toolbar-element';
import BoldIcon from './markdown-toolbar-icons/bold-icon';
import HeaderIcon from './markdown-toolbar-icons/header-icon';
import ItalicIcon from './markdown-toolbar-icons/italic-icon';

interface Props {
textareaId: string;
}

const boldLabel = 'Add bold text <cmd-b>';
const headerLabel = 'Add header text';
const italicLabel = 'Add italic text <cmd-i>';

export default class MarkdownToolbar extends Component<Props> {
render(props: RenderableProps<Props>) {
return (
<markdown-toolbar for={props.textareaId}>
<markdown-toolbar className="input__toolbar" for={props.textareaId}>
<div className="input__toolbar-group">
<md-header className="input__toolbar-item" title={headerLabel} aria-label={headerLabel}>
<HeaderIcon />
</md-header>
<md-bold className="input__toolbar-item" title={boldLabel} aria-label={boldLabel}>
<BoldIcon />
</md-bold>
<md-italic className="input__toolbar-item" title={italicLabel} aria-label={italicLabel}>
<ItalicIcon />
</md-italic>
</div>
</markdown-toolbar>
);
Expand Down

0 comments on commit cffaa71

Please sign in to comment.