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

モバイル用の投稿ダイアログ呼び出しボタンを追加 #128

Closed
wants to merge 0 commits into from

Conversation

furutani-k
Copy link
Member

@furutani-k furutani-k commented Dec 14, 2023

スタイル調整

Issue

変更内容

  • モバイル用の投稿ダイアログ呼び出しボタンを追加
  • モバイル用に投稿ダイアログのスタイルを調整(PC/タブのデザインは変わっていないはず)

確認方法

(確認方法を記載してください)

Screenshot (任意)

Screencast.from.2023.12.14.19.51.15.webm

Summary by CodeRabbit

  • 新機能: モバイル用の投稿ダイアログ呼び出しボタンを追加し、メニューレイアウトに配置しました。これにより、ユーザーはモバイルデバイスから簡単に新しい投稿を作成できます。
  • 新機能: PostDialogコンポーネントにフルスクリーンプロパティを追加しました。これにより、投稿ダイアログがフルスクリーンモードで表示され、ユーザー体験が向上します。
  • スタイル: 投稿エディタのスタイルを更新し、入力フィールドの高さを100%に設定しました。これにより、エディタの見た目と使いやすさが向上します。

@furutani-k furutani-k linked an issue Dec 14, 2023 that may be closed by this pull request
1 task
Copy link

github-actions bot commented Dec 14, 2023

Image description CodeRabbit


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between ebf012a and 9cd959f commits.
Files selected (5)
  • src/app/(menu)/_components/menu/elements/MobileOpenPostDialogButton.tsx (1)
  • src/app/(menu)/layout.tsx (2)
  • src/app/_components/post/PostDialog.tsx (2)
  • src/app/_components/post/PostForm.tsx (1)
  • src/app/_components/post/elements/Editor.tsx (2)
Files skipped from review due to trivial changes (2)
  • src/app/(menu)/layout.tsx
  • src/app/_components/post/elements/Editor.tsx
Review comments generated (4)
  • Review: 3
  • LGTM: 1

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines 44 to 45
const renderablePaths = ['/home', '/search', '/notifications'];
const renderable = renderablePaths.includes(usePathname() as string);
Copy link

@github-actions github-actions bot Dec 14, 2023

Choose a reason for hiding this comment

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

Image description CodeRabbit

usePathname()の戻り値がstringであることを保証するために、型アサーションを使用しています。しかし、この方法は安全ではありません。もしusePathname()undefinedや他の非文字列値を返す場合、ランタイムエラーが発生します。代わりに、usePathname()の戻り値をチェックし、それがstringであることを確認する方がよいでしょう。

- const renderable = renderablePaths.includes(usePathname() as string);
+ const pathname = usePathname();
+ const renderable = typeof pathname === 'string' && renderablePaths.includes(pathname);

Copy link
Member Author

Choose a reason for hiding this comment

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

配列に含まれるかの確認だけなので、仮にundefinedや非文字列値が返されてもランタイムエラーは発生しないので問題ありません。

Choose a reason for hiding this comment

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

Image description CodeRabbit

@furutani-k あなたの観点は理解できます。JavaScriptでは、undefinedや非文字列値を配列のincludesメソッドに渡してもエラーは発生しません。しかし、このコードが将来的に変更され、usePathname()の戻り値が他の操作で使用される場合、型アサーションによる安全でないキャストは問題を引き起こす可能性があります。

そのため、私の提案は、現在のコードがエラーを引き起こす可能性があるというよりも、将来的な問題を予防するためのものです。ただし、あなたの指摘通り、現状では必須ではありません。

Comment on lines 41 to 69
export default function MobileOpenPostDialogButton() {
const [getOpenDialog, setOpenDialog] = useState(false);

const renderablePaths = ['/home', '/search', '/notifications'];
const renderable = renderablePaths.includes(usePathname() as string);
const { data: profile } = useProfile();

return (
<>
{profile && renderable && (
<Box>
<StyledButton
variant="contained"
color="primary"
onClick={() => setOpenDialog(true)}
>
<Send />
</StyledButton>

<PostDialog
fullScreen
open={getOpenDialog}
close={() => setOpenDialog(false)}
/>
</Box>
)}
</>
);
}
Copy link

@github-actions github-actions bot Dec 14, 2023

Choose a reason for hiding this comment

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

Image description CodeRabbit

useStateフックの変数名getOpenDialogは、関数またはメソッドを示唆していますが、実際にはブール値を保持しています。これは混乱を招く可能性があります。より適切な名前に変更することをお勧めします。

- const [getOpenDialog, setOpenDialog] = useState(false);
+ const [isDialogOpen, setDialogOpen] = useState(false);

そして、この新しい変数名をコード内で適切に使用します。

- open={getOpenDialog}
+ open={isDialogOpen}

- onClick={() => setOpenDialog(true)}
+ onClick={() => setDialogOpen(true)}

- close={() => setOpenDialog(false)}
+ close={() => setDialogOpen(false)}

Copy link
Member Author

Choose a reason for hiding this comment

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

既存のコードがget*, set*での記述となっているため、それに合わせたコードとなっています。

Choose a reason for hiding this comment

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

Image description CodeRabbit

@furutani-k 既存のコードがget*, set*の形式で記述されているとのこと、理解しました。ただし、この場合にはgetOpenDialogが実際には状態(ブール値)を保持しており、関数やメソッドを示唆する名前となっています。これは混乱を招く可能性があります。

一般的に、get*set*のプレフィックスは、値を取得または設定するための関数やメソッドに使用されます。一方、状態変数は通常、その状態を表す名前が付けられます。例えば、ダイアログが開いているかどうかを示すブール値であれば、isDialogOpenのような名前が適切です。

したがって、私の提案は、混乱を避けるためにも、この特定の状況ではget*, set*の命名規則から逸脱し、より明確な名前を使用することです。

Copy link
Member

Choose a reason for hiding this comment

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

@furutani-k 取得される値は関数(所謂getter)ではなく、状態を表すのでopenisOpenに名称変更する方向でお願いします。
既存の箇所も随時直していく感じで

src/app/_components/post/PostForm.tsx Outdated Show resolved Hide resolved
@furutani-k furutani-k marked this pull request as ready for review December 14, 2023 11:42
export default function MobileOpenPostDialogButton() {
const [getOpenDialog, setOpenDialog] = useState(false);

const renderablePaths = ['/home', '/search', '/notifications'];
Copy link
Member

@takecchi takecchi Dec 20, 2023

Choose a reason for hiding this comment

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

@furutani-k
今後ユーザーページでも呟ける必要があるので、パス制限いらないかも?
DMや設定などボタン不要なパスを一覧にするほうが良さそう。


return (
<>
{profile && renderable && (
Copy link
Member

@takecchi takecchi Dec 20, 2023

Choose a reason for hiding this comment

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

@furutani-k ログインチェックにはuseAuthを使われるのが良いかと!

return (
<>
{profile && renderable && (
<Box>
Copy link
Member

@takecchi takecchi Dec 20, 2023

Choose a reason for hiding this comment

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

@furutani-k ここBoxで囲う必要がないような気がします。

Comment on lines 41 to 69
export default function MobileOpenPostDialogButton() {
const [getOpenDialog, setOpenDialog] = useState(false);

const renderablePaths = ['/home', '/search', '/notifications'];
const renderable = renderablePaths.includes(usePathname() as string);
const { data: profile } = useProfile();

return (
<>
{profile && renderable && (
<Box>
<StyledButton
variant="contained"
color="primary"
onClick={() => setOpenDialog(true)}
>
<Send />
</StyledButton>

<PostDialog
fullScreen
open={getOpenDialog}
close={() => setOpenDialog(false)}
/>
</Box>
)}
</>
);
}
Copy link
Member

Choose a reason for hiding this comment

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

@furutani-k 取得される値は関数(所謂getter)ではなく、状態を表すのでopenisOpenに名称変更する方向でお願いします。
既存の箇所も随時直していく感じで

Comment on lines 11 to 12
height: 100% !important;
vertical-align: top;
Copy link
Member

@takecchi takecchi Dec 20, 2023

Choose a reason for hiding this comment

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

@furutani-k
MUIがheightをJSで制御してるのが厄介ですね。
可能な限り!importantは使用したくはないですが...

こちらでも触ってみます。

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 9cd959f and 8e5fad5 commits.
Files selected (1)
  • src/app/_components/post/PostDialog.tsx (2)
Files not summarized due to errors (1)
  • src/app/_components/post/PostDialog.tsx (nothing obtained from openai)
Files not reviewed due to errors (1)
  • src/app/_components/post/PostDialog.tsx (no response)
Review comments generated (0)
  • Review: 0
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 8e5fad5 and 6531e8f commits.
Files selected (1)
  • src/app/layout.tsx (2)
Files not summarized due to errors (1)
  • src/app/layout.tsx (nothing obtained from openai)
Files not reviewed due to errors (1)
  • src/app/layout.tsx (no response)
Review comments generated (0)
  • Review: 0
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

@takecchi takecchi closed this Dec 20, 2023
@takecchi takecchi force-pushed the feature/issues-112-mobile-post-form branch from 6531e8f to 0c90ca6 Compare December 20, 2023 11:58
@takecchi takecchi changed the title モバイル用の投稿ダイアログ呼び出しボタンを追加 モバイル用の投稿ダイアログ呼び出しボタンを追加https://github.com/cuculus-dev/cuculus/tree/feature/issues-112-mobile-post-form Dec 20, 2023
@takecchi takecchi changed the title モバイル用の投稿ダイアログ呼び出しボタンを追加https://github.com/cuculus-dev/cuculus/tree/feature/issues-112-mobile-post-form モバイル用の投稿ダイアログ呼び出しボタンを追加 Dec 20, 2023
@takecchi
Copy link
Member

takecchi commented Dec 20, 2023

#134
間違えて差分ゼロにしてしまったのでこちらでマージ

@takecchi takecchi mentioned this pull request Dec 20, 2023
takecchi added a commit that referenced this pull request Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(SP)投稿フォーム
2 participants