-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
400 additions
and
8 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,20 @@ | ||
import React from 'react'; | ||
import Parser from 'html-react-parser'; | ||
import memoize from 'memoizee'; | ||
|
||
const Markdown = ({ source }) => { | ||
const descriptionHTML = window.md.makeHtml(source); | ||
source = Parser(descriptionHTML); | ||
|
||
if(source){ | ||
return ( | ||
<div className='Markdown'>{source}</div> | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
const MemoizedMarkdown = memoize(Markdown); | ||
MemoizedMarkdown.displayName = 'Markdown'; | ||
export default MemoizedMarkdown; |
60 changes: 60 additions & 0 deletions
60
app/assets/javascripts/components/jquery_wrappers/Popover.js
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,60 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default class Popover extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.saveChildRef = this.saveChildRef.bind(this); | ||
this.saveContentRef = this.saveContentRef.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
const { | ||
delay, | ||
trigger, | ||
title | ||
} = this.props; | ||
|
||
$(this.childRef).popover({ | ||
delay, | ||
trigger, | ||
title, | ||
html: true, | ||
content: this.contentRef | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
$(this.childRef).popover('destroy'); | ||
} | ||
|
||
saveChildRef(ref) { | ||
this.childRef = ref; | ||
} | ||
|
||
saveContentRef(ref) { | ||
this.contentRef = ref; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
{ this.props.children({ ref: this.saveChildRef }) } | ||
<div style={{ display: 'none' }}> | ||
{ this.props.renderContent({ ref: this.saveContentRef })} | ||
</div> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
Popover.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
delay: PropTypes.number, | ||
trigger: PropTypes.string | ||
}; | ||
|
||
Popover.defaultProps = { | ||
delay: 0 | ||
}; |
19 changes: 19 additions & 0 deletions
19
app/assets/javascripts/components/story/StoryDescriptionIcon.js
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,19 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const StoryDescriptionIcon = ({ description }) => { | ||
if (description) { | ||
return ( | ||
<span className='Story__description-icon' > | ||
<i className={`mi md-dark md-16 question_answer`}>question_answer</i> | ||
</span> | ||
) | ||
} | ||
return null | ||
}; | ||
|
||
StoryDescriptionIcon.propTypes = { | ||
description: PropTypes.string | ||
}; | ||
|
||
export default StoryDescriptionIcon; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import moment from 'moment'; | ||
import Markdown from '../Markdown'; | ||
import Popover from 'components/jquery_wrappers/Popover.js'; | ||
|
||
export const StoryPopoverContent = ({ description, notes, createdAt, storyType, requestedByName }) => ( | ||
<div> | ||
<div className='popover__content__subtitle'> | ||
{ | ||
I18n.translate('requested by user on date', { | ||
user: requestedByName, | ||
date: moment(createdAt).format('DD MM YYYY, h:mm a') | ||
}) | ||
} | ||
|
||
<div className='text-right'> | ||
{ I18n.translate('story.type.' + storyType) } | ||
</div> | ||
</div> | ||
|
||
{ | ||
Boolean(description) && ( | ||
<div> | ||
<h1 className='popover__content__title'>{ I18n.translate('description') }</h1> | ||
<div className='markdown-wrapper'> | ||
<Markdown source={description}/> | ||
</div> | ||
</div> | ||
)} | ||
|
||
{ | ||
Boolean(notes.length) && ( | ||
<div> | ||
<h1 className='popover__content__title'>{ I18n.translate('notes') }</h1> | ||
{ notes.map((note) => | ||
<div className='markdown-wrapper' key={note.id}> | ||
<Markdown source={note.note}/> | ||
<div className='markdown-wrapper__text-right' data-test-id={note.id}> | ||
{ note.userName + " - " + note.createdAt } | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
) | ||
|
||
const StoryPopover = ({ description, notes, createdAt, title, storyType, requestedByName , children }) => ( | ||
<Popover | ||
delay={200} | ||
trigger="hover" | ||
title={title} | ||
renderContent={({ ref }) => ( | ||
<div className='popover__content' ref={ref}> | ||
<StoryPopoverContent | ||
description={description} | ||
notes={notes} | ||
createdAt={createdAt} | ||
storyType={storyType} | ||
requestedByName={requestedByName} | ||
/> | ||
</div> | ||
)} | ||
> | ||
{ | ||
({ ref }) => ( | ||
<bold ref={ref}> | ||
{ children } | ||
</bold> | ||
) | ||
} | ||
</Popover> | ||
); | ||
|
||
StoryPopover.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
description: PropTypes.string, | ||
storyType: PropTypes.string.isRequired, | ||
requestedByName: PropTypes.string, | ||
createdAt: PropTypes.string, | ||
notes: PropTypes.array, | ||
}; | ||
|
||
export default StoryPopover; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
.full-heigth { | ||
height:100%; | ||
} | ||
|
||
.markdown-wrapper{ | ||
background: $white; | ||
border-left: 4px solid $lightgrey-17; | ||
margin-top: 5px; | ||
padding: 10px; | ||
|
||
&__text-rigth{ | ||
float: right; | ||
vertical-align: top; | ||
color: $darkgrey-8; | ||
font-size: 0.75em; | ||
} | ||
} | ||
|
||
.popover { | ||
&__content { | ||
padding: 5px 5px 0 5px; | ||
word-wrap: break-word; | ||
|
||
&__title { | ||
font-size: 13px; | ||
} | ||
|
||
&__subtitle { | ||
color: $darkgrey-8; | ||
font-size: 0.85em; | ||
padding: 0 2px; | ||
margin: 5px 0 5px; | ||
|
||
.text-right{ | ||
margin-left: 10px; | ||
float: right; | ||
vertical-align: top; | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.