-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2' into feat/config-viewer
- Loading branch information
Showing
39 changed files
with
871 additions
and
1,003 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,84 @@ | ||
import React from "react"; | ||
import { Mention, MentionsInput } from "react-mentions"; | ||
import PropTypes from "prop-types"; | ||
import { Icon } from "../Icon"; | ||
|
||
const mentionsStyle = { | ||
control: { | ||
fontSize: 14 | ||
}, | ||
|
||
"&multiLine": { | ||
control: { | ||
minHeight: 80 | ||
}, | ||
highlighter: { | ||
padding: 9, | ||
paddingTop: 11 | ||
}, | ||
input: { | ||
padding: 9, | ||
borderRadius: "0.375rem", | ||
borderColor: "rgb(229 231 235)" | ||
} | ||
}, | ||
|
||
suggestions: { | ||
list: { | ||
backgroundColor: "white", | ||
border: "1px solid rgba(0,0,0,0.15)", | ||
fontSize: 14 | ||
}, | ||
item: { | ||
padding: 5, | ||
borderBottom: "1px solid rgba(0,0,0,0.15)", | ||
"&focused": { | ||
backgroundColor: "#cee4e5" | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const Suggestion = ({ display, icon }) => ( | ||
<div className="flex items-center"> | ||
{icon && <Icon name={icon} size="xl" />} | ||
<p className="pl-2">{display}</p> | ||
</div> | ||
); | ||
|
||
export const CommentInput = ({ data, value, onChange, markup, trigger }) => ( | ||
<MentionsInput | ||
value={value} | ||
onChange={(e) => onChange(e.target.value)} | ||
a11ySuggestionsListLabel="Suggested mentions" | ||
style={mentionsStyle} | ||
allowSpaceInQuery | ||
allowSuggestionsAboveCursor | ||
> | ||
<Mention | ||
markup={markup} | ||
trigger={trigger} | ||
data={data} | ||
renderSuggestion={Suggestion} | ||
className="bg-blue-200 rounded" | ||
/> | ||
</MentionsInput> | ||
); | ||
|
||
CommentInput.propTypes = { | ||
data: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
display: PropTypes.string, | ||
icon: PropTypes.string | ||
}) | ||
).isRequired, | ||
value: PropTypes.string.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
trigger: PropTypes.string, | ||
markup: PropTypes.string | ||
}; | ||
|
||
CommentInput.defaultProps = { | ||
trigger: "@", | ||
markup: "@[__display__](user:__id__)" | ||
}; |
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,32 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
export const CommentText = ({ text, onClickTag }) => { | ||
// markup @[__display__](user:__id__) | ||
const tags = text.match(/@\[.*?\]\(user:.*?\)/gi) || []; | ||
const otherText = text.split(/@\[.*?\]\(user:.*?\)/gi); | ||
return tags.reduce( | ||
(display, myTag, index) => { | ||
const tagDisplay = myTag.match(/\[.*?\]/gi)[0].slice(1, -1); | ||
const tagData = myTag.match(/\(user:.*?\)/gi)[0].slice(6, -1); | ||
return [ | ||
...display, | ||
<button | ||
type="button" | ||
key={tagData} | ||
onClick={() => onClickTag("user", tagData)} | ||
className="bg-blue-200 rounded" | ||
> | ||
{tagDisplay} | ||
</button>, | ||
otherText[index + 1] | ||
]; | ||
}, | ||
[otherText[0]] | ||
); | ||
}; | ||
|
||
CommentText.propTypes = { | ||
text: PropTypes.string.isRequired, | ||
onClickTag: PropTypes.func.isRequired | ||
}; |
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,4 @@ | ||
import { CommentInput } from "./comment-input"; | ||
import { CommentText } from "./comment-text"; | ||
|
||
export { CommentInput, CommentText }; |
Oops, something went wrong.