Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/mobile article comment #4201

Merged
merged 17 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
"defaultMessage": "Asset not found",
"description": "ASSET_NOT_FOUND"
},
"4OMGUj": {
"defaultMessage": "Comment Details"
},
"4RpVDe": {
"defaultMessage": "Delete Draft"
},
Expand Down Expand Up @@ -1134,10 +1137,6 @@
"Q8Qw5B": {
"defaultMessage": "Description"
},
"QGBMmO": {
"defaultMessage": "Published",
"description": "src/components/Forms/CommentFormBeta/index.tsx"
},
"QQSdHP": {
"defaultMessage": "View More"
},
Expand Down Expand Up @@ -1798,6 +1797,9 @@
"defaultMessage": "Open IPNS page",
"description": "src/components/UserProfile/WalletLabel/index.tsx"
},
"jwnump": {
"defaultMessage": "Comment..."
},
"jy3tx0": {
"defaultMessage": "broadcast in {circlename}",
"description": "src/components/Notice/CommentNotice/CircleNewBroadcastNotice.tsx"
Expand Down Expand Up @@ -2111,6 +2113,9 @@
"sy+pv5": {
"defaultMessage": "Email"
},
"syEQFE": {
"defaultMessage": "Publish"
},
"tBt9u0": {
"defaultMessage": "Sign in",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2212,10 +2217,6 @@
"w+6UiO": {
"defaultMessage": "Add Invitation"
},
"w/Bet8": {
"defaultMessage": "Comment Details",
"description": "src/views/ArticleDetail/index.tsx"
},
"wCgTu5": {
"defaultMessage": "Comments"
},
Expand Down
17 changes: 9 additions & 8 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
"defaultMessage": "Asset not found",
"description": "ASSET_NOT_FOUND"
},
"4OMGUj": {
"defaultMessage": "Comment Details"
},
"4RpVDe": {
"defaultMessage": "Delete Draft"
},
Expand Down Expand Up @@ -1134,10 +1137,6 @@
"Q8Qw5B": {
"defaultMessage": "Description"
},
"QGBMmO": {
"defaultMessage": "Published",
"description": "src/components/Forms/CommentFormBeta/index.tsx"
},
"QQSdHP": {
"defaultMessage": "View More"
},
Expand Down Expand Up @@ -1798,6 +1797,9 @@
"defaultMessage": "Open IPNS page",
"description": "src/components/UserProfile/WalletLabel/index.tsx"
},
"jwnump": {
"defaultMessage": "Comment..."
},
"jy3tx0": {
"defaultMessage": "broadcast in {circlename}",
"description": "src/components/Notice/CommentNotice/CircleNewBroadcastNotice.tsx"
Expand Down Expand Up @@ -2111,6 +2113,9 @@
"sy+pv5": {
"defaultMessage": "Email"
},
"syEQFE": {
"defaultMessage": "Publish"
},
"tBt9u0": {
"defaultMessage": "Sign in",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2212,10 +2217,6 @@
"w+6UiO": {
"defaultMessage": "Add Invitation"
},
"w/Bet8": {
"defaultMessage": "Comment Details",
"description": "src/views/ArticleDetail/index.tsx"
},
"wCgTu5": {
"defaultMessage": "Comments"
},
Expand Down
17 changes: 9 additions & 8 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
"defaultMessage": "资源不存在",
"description": "ASSET_NOT_FOUND"
},
"4OMGUj": {
"defaultMessage": "评论详情"
},
"4RpVDe": {
"defaultMessage": "刪除草稿"
},
Expand Down Expand Up @@ -1134,10 +1137,6 @@
"Q8Qw5B": {
"defaultMessage": "描述"
},
"QGBMmO": {
"defaultMessage": "发布",
"description": "src/components/Forms/CommentFormBeta/index.tsx"
},
"QQSdHP": {
"defaultMessage": "查看更多"
},
Expand Down Expand Up @@ -1798,6 +1797,9 @@
"defaultMessage": "打开 IPNS 页面",
"description": "src/components/UserProfile/WalletLabel/index.tsx"
},
"jwnump": {
"defaultMessage": "发布评论..."
},
"jy3tx0": {
"defaultMessage": "在 {circlename} 发布广播",
"description": "src/components/Notice/CommentNotice/CircleNewBroadcastNotice.tsx"
Expand Down Expand Up @@ -2111,6 +2113,9 @@
"sy+pv5": {
"defaultMessage": "邮箱"
},
"syEQFE": {
"defaultMessage": "发布"
},
"tBt9u0": {
"defaultMessage": "登录",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2212,10 +2217,6 @@
"w+6UiO": {
"defaultMessage": "新增邀请"
},
"w/Bet8": {
"defaultMessage": "评论详情",
"description": "src/views/ArticleDetail/index.tsx"
},
"wCgTu5": {
"defaultMessage": "评论"
},
Expand Down
17 changes: 9 additions & 8 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
"defaultMessage": "資源不存在",
"description": "ASSET_NOT_FOUND"
},
"4OMGUj": {
"defaultMessage": "評論詳情"
},
"4RpVDe": {
"defaultMessage": "刪除草稿"
},
Expand Down Expand Up @@ -1134,10 +1137,6 @@
"Q8Qw5B": {
"defaultMessage": "描述"
},
"QGBMmO": {
"defaultMessage": "發布",
"description": "src/components/Forms/CommentFormBeta/index.tsx"
},
"QQSdHP": {
"defaultMessage": "查看更多"
},
Expand Down Expand Up @@ -1798,6 +1797,9 @@
"defaultMessage": "打開 IPNS 頁面",
"description": "src/components/UserProfile/WalletLabel/index.tsx"
},
"jwnump": {
"defaultMessage": "發布評論..."
},
"jy3tx0": {
"defaultMessage": "在 {circlename} 發布廣播",
"description": "src/components/Notice/CommentNotice/CircleNewBroadcastNotice.tsx"
Expand Down Expand Up @@ -2111,6 +2113,9 @@
"sy+pv5": {
"defaultMessage": "電子郵件"
},
"syEQFE": {
"defaultMessage": "發布"
},
"tBt9u0": {
"defaultMessage": "登入",
"description": "src/components/Forms/EmailLoginForm/index.tsx"
Expand Down Expand Up @@ -2212,10 +2217,6 @@
"w+6UiO": {
"defaultMessage": "新增邀請"
},
"w/Bet8": {
"defaultMessage": "評論詳情",
"description": "src/views/ArticleDetail/index.tsx"
},
"wCgTu5": {
"defaultMessage": "評論"
},
Expand Down
1 change: 1 addition & 0 deletions src/common/enums/article.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const COMMENTS_COUNT = 15
export const TOOLBAR_FIXEDTOOLBAR_ID = 'toolbar/fixedToolbar/id'
1 change: 1 addition & 0 deletions src/common/enums/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const CLOSE_ACTIVE_DIALOG = 'closeActiveDialog'
export const OPEN_SUBSCRIBE_CIRCLE_DIALOG = 'openSubscribeCircleDialog'
export const OPEN_SET_USER_NAME_DIALOG = 'openSetUserNameDialog'
export const OPEN_SHOW_NOMAD_BADGE_DIALOG = 'openShowNomadBadgeDialog'
export const OPEN_ARTICLE_DETAIL_DIALOG = 'openArticleDetailDialog'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo? OPEN_COMMENT_DETAIL_DIALOG?


// Toast
export const TOAST_SEND_EMAIL_VERIFICATION = 'toastSendEmailVerification'
Expand Down
2 changes: 2 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type ButtonHeight =
| '1.25rem'
| '1.5rem'
| '1.75rem'
| '1.875rem'
| '2rem'
| '2.25rem'
| '2.5rem'
Expand All @@ -54,6 +55,7 @@ export type ButtonSpacingX =
| 'baseTight'
| 'tight'
| 'base'
| 'baseLoose'
| 'loose'

type ButtonColor =
Expand Down
12 changes: 12 additions & 0 deletions src/components/Button/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ span.container {
}
}

.spacingXBaseLoose {
&:not(.isTransparent) {
padding-right: var(--spacing-base-loose);
padding-left: var(--spacing-base-loose);
}

& .hotarea {
margin-right: calc(var(--spacing-base-loose) * -1);
margin-left: calc(var(--spacing-base-loose) * -1);
}
}

.spacingXLoose {
&:not(.isTransparent) {
padding-right: var(--spacing-loose);
Expand Down
46 changes: 39 additions & 7 deletions src/components/CommentBeta/FooterActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { ERROR_CODES, ERROR_MESSAGES } from '~/common/enums'
import { makeMentionElement, translate } from '~/common/utils'
import {
CommentFormBeta,
CommentFormBetaDialog,
CommentFormType,
LanguageContext,
Media,
Spacer,
toast,
ViewerContext,
Expand Down Expand Up @@ -152,13 +154,43 @@ const BaseFooterActions = ({
<section className={styles.left}>
{hasUpvote && <UpvoteButton {...buttonProps} />}
{hasReply && (
<ReplyButton
type={type}
{...buttonProps}
{...replyButtonProps}
{...replyCustomButtonProps}
onClick={toggleShowForm}
/>
<>
<Media at="sm">
<CommentFormBetaDialog
articleId={article?.id}
type={'article'}
replyToId={comment.id}
parentId={comment.parentComment?.id || comment.id}
submitCallback={submitCallback}
// closeCallback={() => setShowForm(false)}
isInCommentDetail={isInCommentDetail}
defaultContent={`${makeMentionElement(
comment.author.id,
comment.author.userName || '',
comment.author.displayName || ''
)} `}
>
{({ openDialog }) => (
<ReplyButton
type={type}
{...buttonProps}
{...replyButtonProps}
{...replyCustomButtonProps}
onClick={openDialog}
/>
)}
</CommentFormBetaDialog>
</Media>
<Media greaterThan="sm">
<ReplyButton
type={type}
{...buttonProps}
{...replyButtonProps}
{...replyCustomButtonProps}
onClick={toggleShowForm}
/>
</Media>
</>
)}
</section>
</footer>
Expand Down
36 changes: 32 additions & 4 deletions src/components/Dialog/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,30 @@ export const TextButton: React.FC<DialogTextButtonProps> = ({

export type DialogRoundedButtonProps = {
text: React.ReactNode
color?: 'greyDarker' | 'green' | 'red'
textSize?: 'sm' | 'xm'
textWeight?: 'md' | 'normal'

color?: 'greyDarker' | 'green' | 'red' | 'white' | 'black'
icon?: React.ReactNode
loading?: boolean
} & ButtonProps

export const RoundedButton: React.FC<
React.PropsWithChildren<DialogRoundedButtonProps>
> = forwardRef(
({ text, color = 'green', loading, icon, disabled, ...restProps }, ref) => {
(
{
text,
textSize = 'xm',
textWeight = 'md',
color = 'green',
loading,
icon,
disabled,
...restProps
},
ref
) => {
let buttonProps: ButtonProps = restProps

switch (color) {
Expand All @@ -84,6 +99,19 @@ export const RoundedButton: React.FC<
case 'red':
buttonProps = { ...buttonProps, borderColor: 'red', textColor: 'red' }
break
case 'white':
buttonProps = {
...buttonProps,
textColor: 'white',
}
break
case 'black':
buttonProps = {
...buttonProps,
borderColor: 'greyLight',
textColor: 'black',
}
break
}

return (
Expand All @@ -95,8 +123,8 @@ export const RoundedButton: React.FC<
>
<TextIcon
icon={icon || (loading && <IconSpinner16 size="md" />)}
size="xm"
weight="md"
size={textSize}
weight={textWeight}
textPlacement="left"
>
{!loading ? text : null}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dialog/Content/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
display: flex;
flex-direction: column;
flex-shrink: 1;
max-height: calc(70vh - 4.25rem); /* 4.25rem is the height of header */
max-height: calc(90vh - 4.25rem); /* 4.25rem is the height of header */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

90vh is not enough space for mobile browser, and it might break other dialogs with fixedHeight prop?

overflow-x: hidden;
overflow-y: auto;
-webkit-overflow-scrolling: touch;

&.fixedHeight {
height: calc(70vh - 4.25rem); /* 4.25rem is the height of header */
height: calc(90vh - 4.25rem); /* 4.25rem is the height of header */

@media (--sm-up) {
height: min(34rem, 64vh);
Expand Down
Loading
Loading