Skip to content

Commit 04c199b

Browse files
authored
Adds Conversation UI (#173)
Implements a new conversation UI for an easy overview of all the comments on a case
2 parents 9ab8eb1 + c8f553e commit 04c199b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3729
-743
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
],
2121

2222
"plugins": [
23+
"babel-plugin-styled-components",
2324
"syntax-dynamic-import",
2425
"transform-object-rest-spread",
2526
["transform-class-properties", { "spec": true }]

.flowconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.*/node_modules/jsonlint-lines-primitives
66

77
[include]
8-
./node_modules/immutable
98
./node_modules/fbjs/flow/lib
109

1110
[libs]

app/assets/stylesheets/CaseOverview.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535

3636
.CaseOverviewRight
3737
+flex($fg: 0, $fs: 1, $fb: 20em)
38+
@media screen and (max-width: $mobileCutoff)
39+
+flex($fg: 1, $fs: 1, $fb: 20em)
40+
3841
min-width: 15em
3942
& > *
4043
margin: 1em

app/assets/stylesheets/CommentThread.sass

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,6 @@
88
background-color: #bfaeec
99

1010
.CommentThreads
11-
position: absolute
12-
top: 0
13-
right: -290px
14-
width: 267px
15-
font-family: $sansFont
16-
font-weight: 500
17-
font-size: 12pt
18-
19-
&__footer
20-
border-top: 1px solid #351D7A
21-
padding: 0.25em
22-
display: flex
23-
24-
& > *
25-
flex-grow: 1
26-
27-
& .CommentThreads__new-button.o-button
28-
width: 100% !important
29-
background-color: $darkPurple
30-
margin: 0
31-
padding: 0.5em
32-
border-width: 0
33-
font-size: 11pt
34-
letter-spacing: 0.4px
35-
font-weight: 500
36-
color: white
37-
&:hover,
38-
&:focus
39-
background-color: darken($darkPurple, 10%)
40-
&:disabled
41-
cursor: initial
42-
background-color: transparent
4311

4412
&__banner
4513
+banner

app/assets/stylesheets/Narrative.sass

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ article
9090
position: relative
9191

9292
p,
93-
div[data-block]
93+
& > .DraftEditor-root div[data-block],
94+
& > div > .DraftEditor-root div[data-block]
9495
margin: 1em 0
9596

9697
@media screen and (max-width: $mobileCutoff)
@@ -103,7 +104,7 @@ article
103104
background-color: rgb(159, 187, 214)
104105
text-shadow: none
105106

106-
a:not([data-edgenote])
107+
.DraftEditor-root a:not(.c-edgenote-entity):not(.c-edgenote-entity--inactive):not(.pt-button)
107108
color: $darkGreen
108109

109110
&:hover

app/controllers/comment_threads_controller.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CommentThreadsController < ApplicationController
99
def index
1010
@forum = current_reader.active_community.forums.find_by(case: @case)
1111
@comment_threads = if @forum.nil?
12-
[]
12+
CommentThread.none
1313
else
1414
@forum.comment_threads
1515
.visible_to_reader?(current_reader)
@@ -34,7 +34,7 @@ def create
3434
def show
3535
current_reader.update active_community_id: @comment_thread.forum
3636
.community.id
37-
redirect_to inline_comment_thread_url @comment_thread
37+
redirect_to conversation_comment_thread_url @comment_thread
3838
end
3939

4040
def destroy
@@ -64,9 +64,8 @@ def comment_thread_params
6464
params.require(:comment_thread).permit(:start, :length, :block_index, :original_highlight_text)
6565
end
6666

67-
def inline_comment_thread_url(comment_thread)
67+
def conversation_comment_thread_url(comment_thread)
6868
"#{case_url(I18n.locale, comment_thread.card.case.slug)}" \
69-
"/#{comment_thread.card.element.case_element.position}" \
70-
"/cards/#{comment_thread.card_id}/comments/#{comment_thread.id}"
69+
"/conversation/#{comment_thread.id}"
7170
end
7271
end

app/javascript/Case.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const PreTest = asyncComponent(() =>
3636
const PostTest = asyncComponent(() =>
3737
import('quiz/PostTest').then(m => m.default)
3838
)
39+
const Conversation = asyncComponent(() =>
40+
import('conversation').then(m => m.default)
41+
)
3942

4043
function mapStateToProps ({ quiz, caseData }: State) {
4144
return {
@@ -125,6 +128,7 @@ class Case extends React.Component<{
125128
<Route exact path="/" component={CaseOverview} />
126129
<Route path={needsPretest ? '/*' : 'miss'} component={PreTest} />
127130
<Route path={hasQuiz ? '/quiz/' : 'miss'} component={PostTest} />
131+
<Route path="/conversation" component={Conversation} />
128132
<Route path="/:position/" component={CaseElement} />
129133
</Switch>
130134
</div>

app/javascript/card/CardContents.jsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Statistics from 'utility/Statistics'
1919
import CitationTooltip from './CitationTooltip'
2020
import CommentThreadsTag from 'comments/CommentThreadsTag'
2121
import { OnScreenTracker } from 'utility/Tracker'
22+
import { FocusContainer } from 'utility/A11y'
23+
import { ScrollIntoView } from 'utility/ScrollView'
2224

2325
import type { ContextRouter, Match } from 'react-router-dom'
2426

@@ -111,6 +113,7 @@ class CardContents extends React.Component<Props, *> {
111113
theseCommentThreadsOpen,
112114
hoveredCommentThread,
113115
selectedCommentThread,
116+
acceptingSelection,
114117
readOnly,
115118
commentable,
116119
title,
@@ -140,18 +143,25 @@ class CardContents extends React.Component<Props, *> {
140143
transition: 'padding-top 0.1s, flex 0.3s',
141144
}}
142145
>
146+
{theseCommentThreadsOpen ? <ScrollIntoView /> : null}
147+
143148
{editing && <EditorToolbar cardId={id} />}
144149
{title}
145-
<Editor
146-
readOnly={readOnly}
147-
customStyleMap={styleMap}
148-
onChange={(eS: EditorState) => onChange(eS)}
149-
{...{
150-
blockRenderMap,
151-
editorState,
152-
handleKeyCommand,
153-
}}
154-
/>
150+
<FocusContainer
151+
active={!!(theseCommentThreadsOpen && acceptingSelection)}
152+
priority={100}
153+
>
154+
<Editor
155+
readOnly={readOnly}
156+
customStyleMap={styleMap}
157+
onChange={(eS: EditorState) => onChange(eS)}
158+
{...{
159+
blockRenderMap,
160+
editorState,
161+
handleKeyCommand,
162+
}}
163+
/>
164+
</FocusContainer>
155165

156166
{commentable &&
157167
solid && <CommentThreadsTag cardId={id} match={match} />}

app/javascript/card/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function mapStateToProps (
5353
const anyCommentThreadsOpen = matchPath(pathname, commentThreadsOpen())
5454
const anyCommentsOpen = matchPath(pathname, commentsOpen())
5555
const selectedCommentThread =
56-
anyCommentsOpen && anyCommentsOpen.params.commentThreadId
56+
anyCommentsOpen && anyCommentsOpen.params.threadId
5757

5858
return {
5959
commentable:

app/javascript/catalog/Sidebar.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Sidebar = ({
3535
image={reader.imageUrl}
3636
text={reader.name}
3737
href="/profile/edit"
38-
hashKey={reader.email}
38+
hashKey={reader.hashKey}
3939
/>
4040
<Enrollments
4141
loading={loading}
@@ -62,5 +62,8 @@ export const Container = styled.aside`
6262
const IdentigradientElement = styled(Element)`
6363
& > ${ElementImage} {
6464
${identiconStyle};
65+
&:after {
66+
font-size: 16px;
67+
}
6568
}
6669
`

0 commit comments

Comments
 (0)