-
Notifications
You must be signed in to change notification settings - Fork 0
チャンネルヘッダーを実装 #43
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
Open
Meiryo7743
wants to merge
31
commits into
main
Choose a base branch
from
feat/channel-header
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
チャンネルヘッダーを実装 #43
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
79265f4
feat: add ChannelHeader (WIP)
Meiryo7743 2243a75
fix: modify the header structure of AppShell and ChannelHeader (but s…
Meiryo7743 e9052dc
fix: page.tsx
Meiryo7743 2d02130
feat: add the ChannelHeader to display a channel name at the AppShell…
Meiryo7743 1d8a8b1
fix: AppShell
Meiryo7743 b041024
fix: ChannelHeader
Meiryo7743 28e5b19
fix: errors on import order
Meiryo7743 2e0b3af
fix: resolve errors found by ESLint
Meiryo7743 53ce296
fix: ChannelHeader
Meiryo7743 4cc9e67
fix: resolve errors found by ESLint
Meiryo7743 3def0b2
fix: title format
Meiryo7743 6767588
chore: renamed
Meiryo7743 6e8181d
fix: modify
Meiryo7743 0537bad
fix: move AppShell as a global component
Meiryo7743 6226c6b
fix: wrap AppShell
Meiryo7743 c79d380
Revert "fix: wrap AppShell"
saka-naname eb366a7
Revert "fix: move AppShell as a global component"
saka-naname d7fd1be
Revert "fix: modify"
saka-naname 6f22186
Revert "chore: renamed"
saka-naname ece91ab
fix: 一旦ChannelHeaderだけにタイトル表示の機能を持たせる
saka-naname fedf36e
feat: 現在のチャンネルをContextで管理
saka-naname 734a202
feat: ドキュメントタイトルの変更機能をCurrentChannelControllerに移動
saka-naname c2309be
Merge branch 'main' into feat/channel-header (resolve conflict)
saka-naname ab76c1f
fix: 移植
saka-naname f65a5b6
fix: 誤って追加した参照を削除
saka-naname cc408fc
feat: タイトルの設定をgenerateMetadataに移管
saka-naname 28be38d
chore: lint
saka-naname 65050ac
feat: チャンネルヘッダーの表示
saka-naname 0f906d6
fix: Change error comment into Japanese
saka-naname 5a72b62
fix: Remove unneccesary include
saka-naname 445a15b
fix: Style
saka-naname File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,14 @@ | ||
| "use client"; | ||
|
|
||
| import { Text } from "@mantine/core"; | ||
|
|
||
| import { useCurrentChannel } from "#/hooks/useCurrentChannel"; | ||
|
|
||
| /** | ||
| * 余計な再描画を防ぐため、チャンネル名を参照する部分を AppShell から分離 | ||
| */ | ||
| export default function MobileChannelDisplay() { | ||
| const { currentChannel } = useCurrentChannel(); | ||
|
|
||
| return <Text hiddenFrom="sm">{currentChannel && currentChannel.slug}</Text>; | ||
| } |
4 changes: 2 additions & 2 deletions
4
src/app/channels/[channel_id]/_components/Channel/Channel.module.css
This file contains hidden or 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 |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| .root { | ||
| position: relative; | ||
| display: flex; | ||
| flex-direction: column; | ||
| max-width: 100%; | ||
| height: 100svh; | ||
| min-height: 100vh; | ||
| padding-top: 3rem; | ||
| } | ||
|
|
||
| .message-area { | ||
| display: flex; | ||
| flex-direction: column; | ||
| height: 100%; | ||
| overflow-y: scroll; | ||
| } | ||
| } |
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
src/app/channels/[channel_id]/_components/ChannelHeader/ChannelHeader.module.css
This file contains hidden or 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,10 @@ | ||
| .root { | ||
| position: absolute; | ||
| top: 3rem; | ||
| z-index: 10; | ||
| width: 100%; | ||
| height: 3rem; | ||
| padding-inline: 1rem; | ||
| background-color: var(--mantine-color-body); | ||
| border-bottom: 1px solid var(--mantine-color-gray-3); | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
src/app/channels/[channel_id]/_components/ChannelHeader/ChannelHeader.tsx
This file contains hidden or 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 @@ | ||
| "use client"; | ||
|
|
||
| import { Group } from "@mantine/core"; | ||
|
|
||
| import styles from "./ChannelHeader.module.css"; | ||
|
|
||
| import { useCurrentChannel } from "#/hooks/useCurrentChannel"; | ||
|
|
||
| const ChannelHeader: React.FC = () => { | ||
| const { currentChannel } = useCurrentChannel(); | ||
|
|
||
| return ( | ||
| <Group className={styles["root"]} visibleFrom="sm"> | ||
| {currentChannel && currentChannel.slug} | ||
| </Group> | ||
| ); | ||
| }; | ||
|
|
||
| export default ChannelHeader; |
28 changes: 28 additions & 0 deletions
28
src/app/channels/[channel_id]/_components/CurrentChannelController.tsx
This file contains hidden or 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,28 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
|
|
||
| import { Channel } from "@prisma/client"; | ||
|
|
||
| import { useCurrentChannel } from "#/hooks/useCurrentChannel"; | ||
|
|
||
| export default function CurrentChannelController({ | ||
| channel, | ||
| }: { | ||
| channel: Channel | null; | ||
| }) { | ||
| const { setCurrentChannel } = useCurrentChannel(); | ||
|
|
||
| /** | ||
| * チャンネルのページを開いている間、コンテキストにチャンネルの情報を保存する | ||
| */ | ||
| useEffect(() => { | ||
| setCurrentChannel(channel); | ||
|
|
||
| return () => { | ||
| setCurrentChannel(null); | ||
| }; | ||
| }, [channel, setCurrentChannel]); | ||
|
|
||
| return null; | ||
| } |
Meiryo7743 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| "use client"; | ||
|
|
||
| import { createContext, SetStateAction, useState } from "react"; | ||
|
|
||
| import { Channel } from "@prisma/client"; | ||
|
|
||
| export type CurrentChannelContextType = { | ||
| currentChannel: Channel | null; | ||
| setCurrentChannel: React.Dispatch<SetStateAction<Channel | null>>; | ||
| }; | ||
|
|
||
| export const CurrentChannelContext = | ||
| createContext<CurrentChannelContextType | null>(null); | ||
|
|
||
| export function CurrentChannelProvider({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| const [currentChannel, setCurrentChannel] = useState<Channel | null>(null); | ||
|
|
||
| return ( | ||
| <CurrentChannelContext.Provider | ||
| value={{ | ||
| currentChannel, | ||
| setCurrentChannel, | ||
| }} | ||
| > | ||
| {children} | ||
| </CurrentChannelContext.Provider> | ||
| ); | ||
| } |
This file contains hidden or 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,20 @@ | ||
| "use client"; | ||
|
|
||
| import { useContext } from "react"; | ||
|
|
||
| import { CurrentChannelContext } from "#/contexts/CurrentChannelContext"; | ||
|
|
||
| /** | ||
| * 現在開いているチャンネルの情報を利用する | ||
| * @returns getter 及び setter | ||
| */ | ||
| export function useCurrentChannel() { | ||
| const context = useContext(CurrentChannelContext); | ||
|
|
||
| if (!context) | ||
| throw new Error( | ||
| "useCurrentChannel は <CurrentChannelProvider> 内で使用される必要があります" | ||
| ); | ||
|
|
||
| return context; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sidebarがあるとき横が突き抜けてしまっているようです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正します!