Open platform to collect and prioritize feedback
Better UX on ShowIdea Page and markdown display (#109)
Guilherme Oenningcfb2cc0d02d9
diff --git a/public/assets/styles/main.scss b/public/assets/styles/main.scssindex f81c8dcd1..3e5462034 100644--- a/public/assets/styles/main.scss+++ b/public/assets/styles/main.scss@@ -14,11 +14,16 @@ body {background-color: $menu-color;margin-bottom: 30px;height: 40px;++ .fdr-avatar {+ margin-right: 5px;+ }div, a {border: none;color: textColorFor($menu-color);}+a::before {content: none;}@@ -33,12 +38,50 @@ body {float: right;}+.subtitle {+ font-size: 11px;+ font-weight: 600;+ letter-spacing: .3px;+ line-height: 16px;+ text-transform: uppercase;+ color: #999;+}+code {- padding: 2px 4px;- font-size: 90%;- color: #c7254e;- background-color: #f9f2f4;- border-radius: 4px;+ font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;+}++.markdown-body {+ blockquote {+ padding: 0 1em;+ color: #6a737d;+ border-left: 0.25em solid #dfe2e5;+ }+ pre {+ overflow: hidden;+ padding: 16px;+ line-height: 1.45;+ background-color: #f6f8fa;+ border-radius: 3px;+ code {+ display: inline;+ max-width: auto;+ padding: 0;+ margin: 0;+ overflow: visible;+ line-height: inherit;+ word-wrap: normal;+ background-color: transparent;+ border: 0;+ }+ }+ code {+ padding: 0.2em;+ font-size: 85%;+ margin: 0;+ background-color: rgba(27,31,35,0.05);+ border-radius: 3px;+ }}.ui.inline.dropdown {@@ -49,29 +92,11 @@ code {.fdr-avatar,.ui.menu .item>img:not(.ui) {- border-radius: .25rem;- width: 2em;- display: inline-block;- margin-right: 0.5em;+ border-radius: 2rem;+ width: 30px;vertical-align: middle;}-.comment-input {- display: inline-block;- width: 85%;-}--.ui.comments {- .fdr-avatar {- vertical-align: top;- margin-top: 2px;- }- .comment > .content {- display: inline-block;- max-width: 85%;- }-}-.no-border {border-radius: 0px !important;}diff --git a/public/assets/styles/variables.scss b/public/assets/styles/variables.scssindex 2f2607db8..a75a13d84 100644--- a/public/assets/styles/variables.scss+++ b/public/assets/styles/variables.scss@@ -1,6 +1,6 @@$main-color: #0069ff; //#0c9-$bg-color: #f9f9f9;-$menu-color: #fff;+$bg-color: #fff;+$menu-color: #f9f9f9;@function textColorFor($color) {@if (lightness($color) > 60) {diff --git a/public/components/CommentInput.tsx b/public/components/CommentInput.tsxindex 9eeab6bbf..8f4354ebc 100644--- a/public/components/CommentInput.tsx+++ b/public/components/CommentInput.tsx@@ -54,7 +54,7 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpuconst button = user? <Button className="primary" onClick={ () => this.submit() }>- Add Comment+ Submit</Button>: <div className="ui message signin-message"><div className="header">@@ -64,16 +64,16 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpu<SocialSignInList orientation="horizontal" size="small" /></div>;- return <div>- <Gravatar name={this.user.name} hash={this.user.gravatar}/>- <div className="ui form comment-input">+ return <div className="comment-input">+ <Gravatar name={ this.user.name } hash={ this.user.gravatar }/>+ <div className="ui form"><DisplayError error={this.state.error} /><div className="field"><textarea onKeyUp={(e) => { this.setState({ content: e.currentTarget.value }); }}rows={3}placeholder="Write a comment..."></textarea></div>- { (this.state.content || user) && button }+ { this.state.content && user && button }</div></div>;}diff --git a/public/components/ResponseForm.tsx b/public/components/ResponseForm.tsxindex 2d18ecfd1..52282a4e3 100644--- a/public/components/ResponseForm.tsx+++ b/public/components/ResponseForm.tsx@@ -10,12 +10,12 @@ interface ResponseFormProps {}interface ResponseFormState {- active: boolean;error?: Failure;}export class ResponseForm extends React.Component<ResponseFormProps, ResponseFormState> {private user: User;+ private modal: HTMLDivElement;private text: HTMLTextAreaElement;private status: HTMLSelectElement;@@ -29,9 +29,7 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseForsuper(props);this.user = this.session.getCurrentUser();- this.state = {- active: false- };+ this.state = { };}private async submit() {@@ -46,47 +44,56 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor}}- private activate() {- this.setState({ active: true });+ private showModal() {+ $(this.modal).modal('show');}- private deactivate() {- this.setState({ active: false });+ private closeModel() {+ $(this.modal).modal('hide');}public render() {- const button = <Button className="primary" onClick={async () => this.activate()}>Respond</Button>;+ const button = <Button className="primary" onClick={async () => this.showModal()}>Respond</Button>;- const form = <div className="ui reply form">- <DisplayError fields={['status']} error={this.state.error} />- <div className="two fields">+ const modal = <div className="ui form modal" ref={(e) => this.modal = e! }>++ <div className="content">+ <DisplayError fields={['status']} error={this.state.error} />+ <div className="two fields">+ <div className="field">+ <label>Status</label>+ <select className="ui dropdown"+ ref={(input) => this.status = input!}>+ <option selected={this.props.idea.status === 0} value="0">Open</option>+ <option selected={this.props.idea.status === 1} value="1">Started</option>+ <option selected={this.props.idea.status === 2} value="2">Completed</option>+ <option selected={this.props.idea.status === 3} value="3">Declined</option>+ </select>+ </div>+ </div>+ <DisplayError fields={['text']} error={this.state.error} /><div className="field">- <label>Status</label>- <select className="ui dropdown"- ref={(input) => this.status = input!}>- <option selected={this.props.idea.status === 0} value="0">New</option>- <option selected={this.props.idea.status === 1} value="1">Started</option>- <option selected={this.props.idea.status === 2} value="2">Completed</option>- <option selected={this.props.idea.status === 3} value="3">Declined</option>- </select>+ <textarea+ ref={(input) => this.text = input!}+ defaultValue={this.props.idea.response && this.props.idea.response.text}+ placeholder="What's going on with this idea? Let your users know what are your plans...">+ </textarea></div></div>- <DisplayError fields={['text']} error={this.state.error} />- <div className="field">- <textarea- ref={(input) => this.text = input!}- defaultValue={this.props.idea.response && this.props.idea.response.text}- placeholder="What's going on with this idea? Let your users know what are your plans...">- </textarea>++ <div className="actions">+ <Button className="primary" onClick={() => this.submit()}>+ Submit+ </Button>+ <Button className="basic" onClick={async () => this.closeModel()}>+ Cancel+ </Button></div>- <Button className="primary" onClick={() => this.submit()}>- Submit- </Button>- <Button className="basic" onClick={async () => this.deactivate()}>- Cancel- </Button></div>;- return this.state.active ? form : button;+ return <div>+ { button }+ { modal }+ </div>;}}diff --git a/public/components/ShowIdeaResponse.tsx b/public/components/ShowIdeaResponse.tsxindex 9d1b1f663..ac15fe7de 100644--- a/public/components/ShowIdeaResponse.tsx+++ b/public/components/ShowIdeaResponse.tsx@@ -18,7 +18,7 @@ export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {<Moment date={props.response.respondedOn} /></span><div className="content">- <MultiLineText text={ props.response.text } markdown={true} />+ <MultiLineText text={ props.response.text } style="full" /></div></div>;}diff --git a/public/components/common/MultiLineText.tsx b/public/components/common/MultiLineText.tsxindex 0a42a482c..d298326c1 100644--- a/public/components/common/MultiLineText.tsx+++ b/public/components/common/MultiLineText.tsx@@ -1,12 +1,13 @@import * as React from 'react';import * as md from 'markdown-it';-const cm = md('commonmark', { html: false, linkify: true }).enable('linkify');+const simple = md('commonmark', { html: false, breaks: true, linkify: true }).disable('heading').disable('image');+const full = md('commonmark', { html: false, breaks: true, linkify: true });interface MultiLineText {className?: string;text?: string;- markdown?: boolean;+ style: 'full' | 'simple';}export const MultiLineText = (props: MultiLineText) => {@@ -14,11 +15,6 @@ export const MultiLineText = (props: MultiLineText) => {return <p></p>;}- if (props.markdown) {- return <div className={props.className} dangerouslySetInnerHTML={{__html: cm.render(props.text)}}></div>;- }-- return <div className={props.className}>{props.text.split('\n').map((item, i) =>- <span dangerouslySetInnerHTML={{__html: cm.renderInline(item) + '<br />'}}></span>- )}</div>;+ const func = props.style === 'full' ? full : simple;+ return <div className={ `markdown-body ${props.className || ''}` } dangerouslySetInnerHTML={{__html: func.render(props.text)}}></div>;};diff --git a/public/pages/site/ShowIdeaPage.scss b/public/pages/site/ShowIdeaPage.scssnew file mode 100644index 000000000..c6361e01b--- /dev/null+++ b/public/pages/site/ShowIdeaPage.scss@@ -0,0 +1,32 @@+.ShowIdeaPage {+ .idea-header {+ h1 {+ font-weight: 400;+ margin: 0px;+ }+ .fdr-avatar {+ width: 24px;+ }+ }++ .ui.comments {+ .fdr-avatar {+ margin-right: 5px;+ vertical-align: top;+ margin-top: 2px;+ }+ .comment > .content {+ display: inline-block;+ max-width: 85%;+ }+ }++ .comment-input {+ margin-top: 10px;++ .form {+ display: inline-block;+ width: 85%;+ }+ }+}\ No newline at end of filediff --git a/public/pages/site/ShowIdeaPage.tsx b/public/pages/site/ShowIdeaPage.tsxindex 9bb6c8584..09ef81b83 100644--- a/public/pages/site/ShowIdeaPage.tsx+++ b/public/pages/site/ShowIdeaPage.tsx@@ -12,6 +12,8 @@ import { Button, Gravatar, Moment, MultiLineText, Footer, Header, SocialSignInBuimport { inject, injectables } from '@fider/di';import { Session } from '@fider/services';+import './ShowIdeaPage.scss';+export class ShowIdeaPage extends React.Component<{}, {}> {private user: User;private idea: Idea;@@ -37,52 +39,63 @@ export class ShowIdeaPage extends React.Component<{}, {}> {<div className="content"><span className="author">{ c.user.name }</span><div className="metadata">- <Moment date={c.createdOn} />+ · <Moment date={c.createdOn} /></div><div className="text">- <MultiLineText text={ c.content } />+ <MultiLineText text={ c.content } style="simple" /></div></div></div>- ) : <p>There are no comments yet.</p>;+ ) : <p>No comments have been added yet.</p>;- return <div>+ return <div className="ShowIdeaPage"><Header /><div className="page ui container">- <div className="ui items unstackable">- <div className="item">+ <div className="ui stackable grid container">+ <div className="twelve wide column">+ <div className="ui items unstackable">+ <div className="item">+ <SupportCounter user={this.user} idea={this.idea} />++ <div className="idea-header">+ <h1 className="ui header">{ this.idea.title }</h1>++ <span className="info">+ Shared <Moment date={this.idea.createdOn} /> by <Gravatar name={ this.idea.user.name } hash={ this.idea.user.gravatar }/> <b>{ this.idea.user.name }</b>+ </span>+ </div>+ </div>+ </div>- <SupportCounter user={this.user} idea={this.idea} />+ <span className="subtitle">Description</span>+ {+ this.idea.description+ ? <MultiLineText className="description" text={ this.idea.description } style="simple" />+ : <p className="description">This idea has no description.</p>+ }- <div className="idea-header">- <h1 className="ui header">{ this.idea.title }</h1>+ <ShowIdeaResponse status={ this.idea.status } response={ this.idea.response } />- <p>- <Gravatar name={this.idea.user.name} hash={this.idea.user.gravatar}/> <b>{this.idea.user.name}</b> - <span className="info">- <Moment date={this.idea.createdOn} />- </span>- </p>- </div></div>- </div>- <MultiLineText className="description" text={ this.idea.description } markdown={true} />- <ShowIdeaResponse status={ this.idea.status } response={ this.idea.response } />-- {- this.session.isStaff() &&- <div>- <div className="ui hidden divider"></div>- <ResponseForm idea={ this.idea } />+ {+ this.session.isStaff() &&+ <div className="four wide column">+ <span className="subtitle">Actions</span>+ <br /><br />+ <ResponseForm idea={ this.idea } />+ </div>+ }++ <div className="sixteen wide column">+ <div className="ui comments">+ <span className="subtitle">Discussion</span>+ { commentsList }+ <CommentInput idea={this.idea} />+ </div></div>- }-- <div className="ui comments">- <h3 className="ui dividing header">Discussion</h3>- { commentsList }- <CommentInput idea={this.idea} /></div>+</div><Footer /></div>;diff --git a/public/pages/site/SiteHomePage.scss b/public/pages/site/SiteHomePage.scssindex 69545e4b1..396577eb0 100644--- a/public/pages/site/SiteHomePage.scss+++ b/public/pages/site/SiteHomePage.scss@@ -8,15 +8,19 @@.fdr-idea-list {> .item {- min-height: 105px;-- .header {+ a {max-width: 85%;+ color: #000;+ font-size: 18px;+ &:hover {+ color: $main-color;+ }}}> .item > .content {.description {+ color:rgba(0, 0, 0, 0.6);min-height: 20px;margin-bottom: 10px;}@@ -27,7 +31,6 @@margin-bottom: 20px;border: none;border-bottom: 1.5px dashed $main-color;- color: $main-color;font-size: 18px;background-color: $bg-color;padding: 0px 0px 10px 0px;diff --git a/public/pages/site/SiteHomePage.tsx b/public/pages/site/SiteHomePage.tsxindex 090fde45e..8ae5f4f78 100644--- a/public/pages/site/SiteHomePage.tsx+++ b/public/pages/site/SiteHomePage.tsx@@ -52,14 +52,11 @@ export class SiteHomePage extends React.Component<{}, SiteHomePageState> {{ x.totalComments > 0 && <div className="info right">{ x.totalComments } <i className="comments outline icon"/></div> }- <a href={`/ideas/${x.number}/${x.slug}`} className="header">+ <a href={`/ideas/${x.number}/${x.slug}`}>{ x.title }</a>- <MultiLineText className="description" text={ x.description } markdown={true} />+ <MultiLineText className="description" text={ x.description } style="simple" /><ShowIdeaResponse status={ x.status } response={ x.response } />- <div className="info">- <Moment date={x.createdOn} />- </div></div></div>);@@ -80,7 +77,7 @@ We'd love to hear what you're thinking about. This is the place for you to submi<div className="ui grid stackable"><div className="six wide column">- <MultiLineText className="welcome-message" text={ welcomeMessage } markdown={true} />+ <MultiLineText className="welcome-message" text={ welcomeMessage } style="full" /><IdeaInput placeholder={this.tenant.invitation || 'Tell us your ideas'} /></div><div className="ten wide column">diff --git a/public/tsd.d.ts b/public/tsd.d.tsindex 79dd5187f..e5da26ff2 100644--- a/public/tsd.d.ts+++ b/public/tsd.d.ts@@ -1,4 +1,5 @@interface JQuery {+ modal(action: string): any;popup(args: any): any;dropdown(args?: any): any;}