forked from pinterest/querybook
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ui: add ui * update; * update * update * update * refactor const * fix * fix * update
- Loading branch information
Showing
12 changed files
with
721 additions
and
2 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
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 |
---|---|---|
|
@@ -131,4 +131,11 @@ | |
right: 42px; | ||
} | ||
} | ||
|
||
.execution-selector-section, | ||
.StatementExecutionPicker { | ||
* { | ||
white-space: nowrap; | ||
} | ||
} | ||
} |
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,19 @@ | ||
import * as DraftJs from 'draft-js'; | ||
|
||
export interface IComment { | ||
id: number; | ||
// TODO: clean this | ||
text: string | DraftJs.ContentState; | ||
uid: number; | ||
created_at: number; | ||
updated_at: number; | ||
|
||
child_comments?: IComment[]; | ||
|
||
reactions: IReaction[]; | ||
} | ||
|
||
export interface IReaction { | ||
reaction: string; | ||
uid: number; | ||
} |
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,73 @@ | ||
import * as React from 'react'; | ||
|
||
import { TooltipDirection } from 'const/tooltip'; | ||
import { IconButton } from 'ui/Button/IconButton'; | ||
import { Popover, PopoverLayout } from 'ui/Popover/Popover'; | ||
|
||
interface IProps { | ||
uid: number; | ||
popoverLayout?: PopoverLayout; | ||
tooltipPos?: TooltipDirection; | ||
} | ||
interface IEmojiListProps { | ||
onClick: (emoji: string) => void; | ||
} | ||
|
||
const emojis = ['👍', '👀', '🙂', '😍', '🙁', '❌', '🤌', '🌟', '🔥', '🩵']; | ||
|
||
const EmojiList: React.FunctionComponent<IEmojiListProps> = ({ onClick }) => ( | ||
<div className="EmojiList flex-row"> | ||
{emojis.map((emoji) => ( | ||
<div | ||
key={emoji} | ||
className="Emoji mh8" | ||
onClick={() => onClick(emoji)} | ||
> | ||
{emoji} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
|
||
export const AddReactionButton: React.FunctionComponent<IProps> = ({ | ||
uid, | ||
popoverLayout = ['bottom', 'right'], | ||
tooltipPos = 'down', | ||
}) => { | ||
const addReactionButtonRef = React.useRef<HTMLAnchorElement>(); | ||
|
||
const [showEmojis, setShowEmojis] = React.useState(false); | ||
|
||
const handleEmojiClick = React.useCallback( | ||
(emoji: string) => { | ||
// TODO: make this work (with backend) | ||
console.log(emoji, 'added by', uid); | ||
}, | ||
[uid] | ||
); | ||
|
||
return ( | ||
<div className="AddReactionButton"> | ||
<IconButton | ||
icon="Plus" | ||
invertCircle | ||
size={18} | ||
tooltip="React" | ||
tooltipPos={tooltipPos} | ||
ref={addReactionButtonRef} | ||
onClick={() => setShowEmojis(true)} | ||
/> | ||
{showEmojis ? ( | ||
<Popover | ||
onHide={() => setShowEmojis(false)} | ||
anchor={addReactionButtonRef.current} | ||
layout={popoverLayout} | ||
hideArrow | ||
noPadding | ||
> | ||
<EmojiList onClick={handleEmojiClick} /> | ||
</Popover> | ||
) : null} | ||
</div> | ||
); | ||
}; |
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,82 @@ | ||
import * as DraftJS from 'draft-js'; | ||
import * as React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { UserAvatar } from 'components/UserBadge/UserAvatar'; | ||
import { UserName } from 'components/UserBadge/UserName'; | ||
import { IComment } from 'const/comment'; | ||
import { fromNow } from 'lib/utils/datetime'; | ||
import { IStoreState } from 'redux/store/types'; | ||
import { IconButton } from 'ui/Button/IconButton'; | ||
import { RichTextEditor } from 'ui/RichTextEditor/RichTextEditor'; | ||
import { StyledText } from 'ui/StyledText/StyledText'; | ||
|
||
import { AddReactionButton } from './AddReactionButton'; | ||
import { Reactions } from './Reactions'; | ||
|
||
interface IProps { | ||
comment: IComment; | ||
editComment: (text: DraftJS.ContentState) => void; | ||
isBeingEdited: boolean; | ||
} | ||
|
||
export const Comment: React.FunctionComponent<IProps> = ({ | ||
comment, | ||
editComment, | ||
isBeingEdited, | ||
}) => { | ||
const userInfo = useSelector((state: IStoreState) => state.user.myUserInfo); | ||
const { text, uid, created_at: createdAt, reactions } = comment; | ||
const textContentState = React.useMemo( | ||
() => DraftJS.ContentState.createFromText(text as string), | ||
[text] | ||
); | ||
|
||
return ( | ||
<div className="Comment"> | ||
<div className="Comment-top horizontal-space-between"> | ||
<div className="Comment-top-left flex-row"> | ||
<UserAvatar uid={uid} tiny /> | ||
<UserName uid={uid} /> | ||
<StyledText size="xsmall" color="lightest" cursor="default"> | ||
{fromNow(createdAt)} | ||
</StyledText> | ||
</div> | ||
<div className="Comment-top-right flex-row"> | ||
{isBeingEdited ? ( | ||
<StyledText | ||
className="Editing-text mr4" | ||
color="accent" | ||
weight="bold" | ||
> | ||
editing | ||
</StyledText> | ||
) : null} | ||
<div className="Comment-top-right-buttons flex-row"> | ||
{uid === userInfo.uid && !isBeingEdited ? ( | ||
<div className="Comment-edit"> | ||
<IconButton | ||
icon="Edit" | ||
invertCircle | ||
size={18} | ||
tooltip="Edit Comment" | ||
tooltipPos="left" | ||
onClick={() => | ||
editComment(textContentState) | ||
} | ||
/> | ||
</div> | ||
) : null} | ||
<div className="mh8"> | ||
<AddReactionButton uid={userInfo.uid} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="Comment-text mt4"> | ||
<RichTextEditor value={textContentState} readOnly={true} /> | ||
{reactions.length ? <Reactions reactions={reactions} /> : null} | ||
</div> | ||
</div> | ||
); | ||
}; |
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,34 @@ | ||
import * as React from 'react'; | ||
|
||
import { SoftButton } from 'ui/Button/Button'; | ||
import { Popover } from 'ui/Popover/Popover'; | ||
|
||
import { Comments } from './Comments'; | ||
|
||
export const CommentButton: React.FunctionComponent = () => { | ||
const [showComments, setShowComments] = React.useState(false); | ||
const commentButtonRef = React.useRef<HTMLAnchorElement>(); | ||
return ( | ||
<> | ||
<SoftButton | ||
className="block-crud-button" | ||
onClick={() => setShowComments((curr) => !curr)} | ||
icon="MessageSquare" | ||
aria-label="Comments" | ||
data-balloon-pos="left" | ||
ref={commentButtonRef} | ||
/> | ||
{showComments ? ( | ||
<Popover | ||
onHide={() => setShowComments(false)} | ||
anchor={commentButtonRef.current} | ||
layout={['bottom', 'right']} | ||
hideArrow | ||
noPadding | ||
> | ||
<Comments /> | ||
</Popover> | ||
) : null} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.