Skip to content

Commit 9f37829

Browse files
initial tsdocs for src/chat/ and src/jss/
1 parent e9587ba commit 9f37829

7 files changed

Lines changed: 95 additions & 29 deletions

File tree

src/chat/bookmarks.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
/* global alert confirm */
1+
/**
2+
* Functions related to chat and bookmarks
3+
* @packageDocumentation
4+
*/
25

6+
/* global alert confirm */
37
const UI = {
48
authn: require('../authn/authn'),
59
icons: require('../iconBase'),

src/chat/dateFolder.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
/* global $rdf */
2-
/** Track back through the YYYY/MM/DD tree to find the previous/next day
3-
**
1+
/**
2+
* Contains the [[DateFolder]] class
3+
* @packageDocumentation
44
*/
55

6+
/* global $rdf */
7+
68
const kb = require('../store.js')
79
const ns = require('../ns.js')
810

11+
/**
12+
* Track back through the YYYY/MM/DD tree to find the previous/next day
13+
*/
914
module.exports = class DateFolder {
1015
constructor (rootThing, leafFileName, membershipProperty) {
1116
this.root = rootThing

src/chat/infinite.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// Common code for a discussion are a of messages about something
2-
// This version runs over a series of files for different time periods
3-
//
4-
// Parameters for the whole chat like its title are stred on
5-
// index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
6-
//
1+
/**
2+
* Contains the [[infiniteMessageArea]] class
3+
* @packageDocumentation
4+
*/
5+
76
/* global alert $rdf */
87
import DateFolder from './dateFolder'
98

@@ -87,6 +86,13 @@ function desktopNotification (str) {
8786
// want to be respectful there is no need to bother them any more.
8887
}
8988

89+
/**
90+
* Common code for a chat (discussion area of messages about something)
91+
* This version runs over a series of files for different time periods
92+
*
93+
* Parameters for the whole chat like its title are stored on
94+
* index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
95+
*/
9096
export function infiniteMessageArea (dom, kb, chatChannel, options) {
9197
kb = kb || UI.store
9298
const ns = UI.ns

src/chat/message.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Contains the [[renderMessage]] function,
3+
* along with [[elementForImageURI]],
4+
* [[creatorAndDate]], and [[creatorAndDateHorizontal]]
5+
* @packageDocumentation
6+
*/
7+
18
/* global $rdf */
29

310
import { messageToolbar, sentimentStripLinked } from './messageTools'
@@ -24,6 +31,9 @@ const messageBodyStyle = UI.style.messageBodyStyle
2431
// const { messageToolbar, sentimentStripLinked } = require('./messageTools')
2532
const label = UI.utils.label
2633

34+
/**
35+
* HTML component for an image
36+
*/
2737
export function elementForImageURI (imageUri, options) {
2838
const img = dom.createElement('img')
2939
let height = '10'
@@ -62,6 +72,10 @@ function nick (person) {
6272
return '' + label(person)
6373
}
6474

75+
/**
76+
* Displays creator and date for a chat message
77+
* inside the `td1` element
78+
*/
6579
export function creatorAndDate (td1, creator, date, message) {
6680
var nickAnchor = td1.appendChild(anchor(nick(creator), creator))
6781
if (creator.uri) {
@@ -76,6 +90,10 @@ export function creatorAndDate (td1, creator, date, message) {
7690
td1.appendChild(anchor(date, message))
7791
}
7892

93+
/**
94+
* Horizontally displays creator and date for a chat message
95+
* inside the `td1` element
96+
*/
7997
export function creatorAndDateHorizontal (td1, creator, date, message) {
8098
var nickAnchor = td1.appendChild(anchor(label(creator), creator))
8199
if (creator.uri) {
@@ -92,8 +110,9 @@ export function creatorAndDateHorizontal (td1, creator, date, message) {
92110
td1.appendChild(dom.createElement('br'))
93111
}
94112

95-
// BODY of renderMessage
96-
113+
/**
114+
* Renders a chat message inside a `messageTable`
115+
*/
97116
export function renderMessage (
98117
messageTable,
99118
bindings,

src/chat/messageTools.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
/* global $rdf */
2-
/* Tools for doing things with a message
3-
* Let is be cretiev here. Allow all sorts of things to
1+
/**
2+
* Tools for doing things with a message
3+
* Let us be creative here. Allow all sorts of things to
44
* be done to a message - linking to new or old objects in an open way
55
*
66
* Ideas: Bookmark, Like, star, pin at top of chat, reply as new thread,
7-
* If you made it originally: edit, delete, attach
7+
* If you made it originally: edit, delete, attach
8+
* @packageDocumentation
89
*/
910

11+
/* global $rdf */
12+
1013
const UI = {
1114
authn: require('../authn/authn'),
1215
icons: require('../iconBase'),
@@ -55,7 +58,8 @@ function updatePromise (del, ins) {
5558
}) // promise
5659
}
5760

58-
/* Emoji in Unicode
61+
/**
62+
* Emoji in Unicode
5963
*/
6064

6165
var emoji = {}
@@ -64,7 +68,8 @@ emoji[ns.schema('DisagreeAction')] = '👎'
6468
emoji[ns.schema('EndorseAction')] = '⭐️'
6569
emoji[ns.schema('LikeAction')] = '❤️'
6670

67-
/* Strip of sentiments expressed
71+
/**
72+
* Create strip of sentiments expressed
6873
*/
6974
export function sentimentStrip (target, doc) {
7075
const actions = kb.each(null, ns.schema('target'), target, doc)
@@ -73,12 +78,12 @@ export function sentimentStrip (target, doc) {
7378
const strings = sentiments.map(x => emoji[x] || '')
7479
return dom.createTextNode(strings.join(' '))
7580
}
76-
/** Strip of sentiments expressed
81+
/**
82+
* Create strip of sentiments expressed, with hyperlinks
7783
*
7884
* @param target {NamedNode} - The thing about which they are expressed
79-
* @param doc {NamedNode} - The document iun which they are expressed
85+
* @param doc {NamedNode} - The document in which they are expressed
8086
*/
81-
8287
export function sentimentStripLinked (target, doc) {
8388
var strip = dom.createElement('span')
8489
function refresh () {
@@ -107,6 +112,9 @@ export function sentimentStripLinked (target, doc) {
107112
return strip
108113
}
109114

115+
/**
116+
* Creates a message toolbar component
117+
*/
110118
export function messageToolbar (message, messageRow, userContext) {
111119
const div = dom.createElement('div')
112120
function closeToolbar () {
@@ -225,12 +233,12 @@ export function messageToolbar (message, messageRow, userContext) {
225233
// https://schema.org/AgreeAction
226234
me = UI.authn.currentUser() // If already logged on
227235
if (me) {
228-
// Things yo mnust be logged in fo
236+
// Things you mnust be logged in for
229237
var context1 = { me, dom, div }
230238
div.appendChild(
231239
sentimentButton(
232240
context1,
233-
message, // @@ use UI.widgets.sentimentButton
241+
message, // @@ TODO use UI.widgets.sentimentButton
234242
UI.icons.iconBase + THUMBS_UP_ICON,
235243
ns.schema('AgreeAction'),
236244
message.doc(),

src/chat/thread.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/**
2+
* Contains the [[thread]] function
3+
* @packageDocumentation
4+
*/
5+
16
/* global $rdf */
2-
// Common code for a discussion are a of messages about something
3-
//
47
var UI = {
58
authn: require('../authn/authn'),
69
icons: require('../iconBase'),
@@ -17,7 +20,10 @@ const utils = require('../utils')
1720

1821
// var buttonStyle = 'font-size: 100%; margin: 0.8em; padding:0.5em; background-color: white;'
1922

20-
module.exports = function (dom, kb, subject, messageStore, options) {
23+
/**
24+
* HTML component for a chat thread
25+
*/
26+
module.exports = function thread (dom, kb, subject, messageStore, options) {
2127
kb = kb || UI.store
2228
messageStore = messageStore.doc() // No hash
2329
var ns = UI.ns
@@ -71,8 +77,9 @@ module.exports = function (dom, kb, subject, messageStore, options) {
7177
}
7278
}
7379

74-
// Form for a new message
75-
//
80+
/**
81+
* Form for a new message
82+
*/
7683
var newMessageForm = function () {
7784
var form = dom.createElement('tr')
7885
var lhs = dom.createElement('td')
@@ -232,7 +239,6 @@ module.exports = function (dom, kb, subject, messageStore, options) {
232239
ele = ele2
233240
}
234241
}
235-
236242
var deleteMessage = function (message) {
237243
var deletions = kb
238244
.statementsMatching(message)
@@ -372,6 +378,7 @@ module.exports = function (dom, kb, subject, messageStore, options) {
372378
query.pat.add(v.msg, ns.foaf('maker'), v.creator)
373379
query.pat.add(v.msg, ns.sioc('content'), v.content)
374380
}
381+
375382
function doneQuery () {
376383
messageTable.fresh = true // any new are fresh and so will be greenish
377384
}

src/jss/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1+
/**
2+
* Contains [[getClasses]] and [[getStylesheet]] functions,
3+
* usable as wrappers around JSS (A CSS authoring tool).
4+
* See https://cssinjs.org/
5+
* @packageDocumentation
6+
*/
7+
18
import { create, Jss, Styles, StyleSheet } from 'jss'
29
import preset from 'jss-preset-default'
310

411
const stylesheetsMap = new Map<HTMLElement, Jss>()
512

13+
/**
14+
* returns a StyleSheet object.
15+
* See https://cssinjs.org/ for more info about JSS.
16+
* (despite the name, see https://github.com/solid/solid-ui/issues/199)
17+
*/
618
export function getClasses (insertionPoint: HTMLElement, styles: Partial<Styles>): StyleSheet {
719
const stylesheet = getStylesheet(insertionPoint)
820
return stylesheet.createStyleSheet(styles).attach()
921
}
1022

23+
/**
24+
* returns a JSS object.
25+
* See https://cssinjs.org/ for more info about JSS.
26+
* (despite the name, see https://github.com/solid/solid-ui/issues/199)
27+
*/
1128
export function getStylesheet (insertionPoint: HTMLElement): Jss {
1229
const cachedStylesheet = stylesheetsMap.get(insertionPoint)
1330
if (cachedStylesheet) {

0 commit comments

Comments
 (0)