Skip to content

Commit de28263

Browse files
committed
レイアウト改善
1 parent 6e6fe7e commit de28263

File tree

10 files changed

+77
-33
lines changed

10 files changed

+77
-33
lines changed

app/(docs)/@chat/chat/[chatId]/chatArea.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export function ChatAreaContainer(props: { chatId: string; children: ReactNode }
1818
// モバイルでは全画面表示する
1919
"fixed inset-0 pt-20 bg-base-100",
2020
// PCではスクロールで動かない右サイドバー
21-
"lg:sticky lg:top-0 lg:pt-4 lg:w-1/3 lg:h-screen lg:shadow-md lg:bg-base-200 ",
21+
"has-chat-1:sticky has-chat-1:top-16 has-sidebar:top-0 has-chat-1:pt-4",
22+
"has-chat-1:basis-2/5 has-chat-1:max-w-chat-area has-chat-1:h-[calc(100vh-4rem)] has-sidebar:h-screen",
23+
"has-chat-1:shadow-md has-chat-1:bg-base-200",
24+
// navbar(z-40)よりは下、ChatListForSectionのdropdown(デフォルトでz-999だがz-30に変えている)よりも上
25+
"z-35",
2226
"p-4",
2327
"flex flex-col",
2428
"overflow-y-auto"

app/(docs)/@docs/[lang]/[pageId]/chatForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ export function ChatForm({ path, sectionContent, close }: ChatFormProps) {
101101

102102
return (
103103
<form
104-
className="border border-2 border-secondary shadow-lg rounded-box bg-base-100"
104+
className="border border-2 border-secondary shadow-lg rounded-box bg-base-100/60 backdrop-blur-xs"
105105
style={{
106106
width: "100%",
107107
textAlign: "center",
108108
}}
109109
onSubmit={handleSubmit}
110110
>
111111
<textarea
112-
className="textarea textarea-ghost textarea-md rounded-box"
112+
className="textarea textarea-ghost textarea-md rounded-box bg-transparent!"
113113
placeholder={
114114
"質問を入力してください" /* +
115115
(exampleData

app/(docs)/@docs/[lang]/[pageId]/loading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function Loading() {
22
return (
3-
<div className="p-4 mx-auto w-full max-w-200">
3+
<div className="p-4 mx-auto flex-1 w-full max-w-docs">
44
<div className="skeleton h-8 w-3/4 my-4">{/* heading1 */}</div>
55
<div className="skeleton h-20 w-full my-2">{/* <p> */}</div>
66
<div className="skeleton h-7 w-2/4 mt-4 mb-3">{/* heading2 */}</div>

app/(docs)/@docs/[lang]/[pageId]/pageContent.tsx

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ export function PageContent(props: PageContentProps) {
169169
gridTemplateColumns: `1fr auto`,
170170
}}
171171
>
172-
<Heading className="max-w-200" level={1}>
172+
<Heading className="max-w-docs" level={1}>
173173
{pageEntry.index}章: {pageEntry.title}
174174
</Heading>
175175
<div />
176176
{dynamicMdContent.map((section, index) => (
177177
<Fragment key={section.id}>
178178
<div
179-
className="min-w-1/2 max-w-200 text-justify"
179+
className="min-w-1/2 max-w-docs text-justify"
180180
id={section.id} // 目次からaタグで飛ぶために必要
181181
ref={(el) => {
182182
sectionRefs.current[index] = el;
@@ -197,16 +197,17 @@ export function PageContent(props: PageContentProps) {
197197
</div>
198198
</Fragment>
199199
))}
200+
<PageTransition
201+
lang={path.lang}
202+
prevPage={props.prevPage}
203+
nextPage={props.nextPage}
204+
/>
205+
<div />
200206
</div>
201-
<PageTransition
202-
lang={path.lang}
203-
prevPage={props.prevPage}
204-
nextPage={props.nextPage}
205-
/>
206207
{isFormVisible ? (
207-
// sidebarの幅が80であることからleft-84 (sidebar.tsx参照)
208-
// replがz-10を使用することからそれの上にするためz-20
209-
<div className="fixed bottom-4 right-4 left-4 lg:left-84 z-20">
208+
// leftは sidebarの幅 + 4
209+
// replがz-10, chatAreaがz-35を使用することからそれの上にするためz-40
210+
<div className="fixed bottom-4 right-4 left-4 has-sidebar:left-[calc(var(--container-sidebar)+1rem)] z-40">
210211
<ChatForm
211212
path={path}
212213
sectionContent={dynamicMdContent}
@@ -248,11 +249,15 @@ function ChatListForSection(props: {
248249

249250
return (
250251
<>
251-
{/*PC表示かつチャットを表示していない → チャットリストを表示*/}
252+
{/*xl以上の幅かつチャットを表示していない → チャットリストを表示
253+
see also globals.css
254+
*/}
252255
<ul
253256
className={clsx(
254-
chatId === null ? "hidden lg:block" : "hidden",
255-
"mt-2 ml-4 max-w-60",
257+
chatId === null
258+
? "hidden has-chat-1:block"
259+
: "hidden has-chat-2:block",
260+
"mt-2 ml-4 w-full max-w-chat-list",
256261
"menu menu-sm",
257262
"rounded-lg shadow-sm bg-base-200"
258263
)}
@@ -265,17 +270,23 @@ function ChatListForSection(props: {
265270
</span>
266271
</li>
267272
{filteredChatHistories.map(({ title, chatId }) => (
268-
<li key={chatId} className="">
269-
<Link href={`/chat/${chatId}`} scroll={false}>
273+
<li key={chatId}>
274+
<Link
275+
className="text-wrap text-justify"
276+
href={`/chat/${chatId}`}
277+
scroll={false}
278+
>
270279
{title}
271280
</Link>
272281
</li>
273282
))}
274283
</ul>
275-
{/*PCでない or PC表示でチャットを表示している小さい吹き出しを表示*/}
284+
{/*xl未満 or xl以上でチャットを表示している小さいボタンを表示*/}
276285
<details
277286
className={clsx(
278-
chatId === null ? "block lg:hidden" : "block",
287+
chatId === null
288+
? "block has-chat-1:hidden"
289+
: "block has-chat-2:block",
279290
"dropdown dropdown-end",
280291
"mt-2 ml-2"
281292
)}
@@ -288,12 +299,17 @@ function ChatListForSection(props: {
288299
className={clsx(
289300
"menu menu-sm dropdown-content",
290301
"w-max max-w-[75vw]",
302+
"z-30",
291303
"rounded-lg shadow-sm bg-base-200/60 backdrop-blur-xs"
292304
)}
293305
>
294306
{filteredChatHistories.map(({ title, chatId }) => (
295-
<li key={chatId} className="">
296-
<Link href={`/chat/${chatId}`} scroll={false}>
307+
<li key={chatId}>
308+
<Link
309+
className="text-wrap text-justify"
310+
href={`/chat/${chatId}`}
311+
scroll={false}
312+
>
297313
{title}
298314
</Link>
299315
</li>

app/(docs)/@docs/[lang]/[pageId]/pageTransition.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface PageTransitionProps {
99

1010
export function PageTransition({ lang, prevPage, nextPage }: PageTransitionProps) {
1111
return (
12-
<div className="flex justify-between gap-4 mt-12 pt-8 border-t border-base-content/10 min-w-1/2 max-w-200 col-span-2">
12+
<div className="flex justify-between gap-4 mt-12 pt-8 border-t border-base-content/10 w-full max-w-docs">
1313
<div className="flex-1 flex">
1414
{prevPage && (
1515
<Link

app/globals.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,29 @@ mycdark:
154154
/* TailwindCSSでデフォルトで指定されていた絵文字フォントは一応残しておく */
155155
"Apple Color Emoji",
156156
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
157+
158+
/*
159+
デフォルトのbreakpoint:
160+
--breakpoint-sm: 40rem;
161+
--breakpoint-md: 48rem;
162+
--breakpoint-lg: 64rem;
163+
--breakpoint-xl: 80rem;
164+
--breakpoint-2xl: 96rem;
165+
166+
docsは最低40remはないと読みづらい。
167+
lg未満: docsのみ / chat-areaのみ
168+
lg〜xl: docs + chat-list/chat-area
169+
xl〜: sidebar + docs + chat-list/chat-area
170+
2xl〜: sidebar + docs + chat-list + chat-area
171+
172+
navbarの表示はsidebarと連動
173+
*/
174+
--breakpoint-has-sidebar: 80rem;
175+
--breakpoint-has-chat-1: 64rem;
176+
--breakpoint-has-chat-2: 96rem;
177+
178+
--container-docs: 60rem;
179+
--container-sidebar: 20rem;
180+
--container-chat-area: 30rem;
181+
--container-chat-list: 15rem;
157182
}

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default async function RootLayout({
3131
{/* mocha.css がbodyに背景色などを設定してしまうので、それを上書きしている */}
3232
<AutoAnonymousLogin />
3333
<SidebarMdProvider>
34-
<div className="drawer lg:drawer-open min-h-screen">
34+
<div className="drawer has-sidebar:drawer-open min-h-screen">
3535
<input
3636
id="drawer-toggle"
3737
type="checkbox"

app/navbar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function Navbar({ pagesList }: { pagesList: LanguageEntry[] }) {
3232
return (
3333
<>
3434
{/* fixedのヘッダーの分だけスクロールするコンテンツを下に移動するためのdiv */}
35-
<div className="h-16 lg:hidden" />
35+
<div className="h-16 has-sidebar:hidden" />
3636

37-
<div className="h-16 navbar bg-base-300/60 w-full fixed lg:hidden flex gap-4 z-40 shadow-md backdrop-blur-xs">
37+
<div className="h-16 navbar bg-base-300/60 w-full fixed has-sidebar:hidden flex gap-4 z-40 shadow-md backdrop-blur-xs">
3838
<div className="flex-none">
3939
{/* サイドバーを開閉するボタン */}
4040
<label
@@ -57,7 +57,6 @@ export function Navbar({ pagesList }: { pagesList: LanguageEntry[] }) {
5757
</svg>
5858
</label>
5959
</div>
60-
{/* サイドバーが表示されていない場合のみ */}
6160
<Link href="/" className="flex items-center">
6261
<img
6362
src="/icon.svg"

app/sidebar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ export function Sidebar({ pagesList }: { pagesList: LanguageEntry[] }) {
113113
}, [currentLangIndex]);
114114

115115
return (
116-
<div className="bg-base-200 h-full w-80 flex flex-col">
117-
<h2 className="hidden lg:flex flex-row items-center p-4 gap-2">
118-
{/* サイドバーが常時表示されているlg以上の場合のみ */}
116+
<div className="bg-base-200 h-full w-sidebar flex flex-col">
117+
<h2 className="hidden has-sidebar:flex flex-row items-center p-4 gap-2">
118+
{/* サイドバーが常時表示されている場合のみ */}
119119
<Link href="/" className="flex-1 flex items-center">
120120
<img
121121
src="/icon.svg"
@@ -127,7 +127,7 @@ export function Sidebar({ pagesList }: { pagesList: LanguageEntry[] }) {
127127
<ThemeToggle />
128128
<AccountMenu />
129129
</h2>
130-
<span className="block lg:hidden p-4 pb-0">
130+
<span className="block has-sidebar:hidden p-4 pb-0">
131131
<label
132132
htmlFor="drawer-toggle"
133133
aria-label="open sidebar"

app/terminal/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import sub_rs from "./samples/sub.rs?raw";
2828

2929
export default function RuntimeTestPage() {
3030
return (
31-
<div className="p-4 mx-auto w-full max-w-200">
31+
<div className="p-4 mx-auto w-full max-w-docs">
3232
<Heading level={1}>Runtime Test Page</Heading>
3333

3434
<Heading level={2}>REPLとコード実行のサンプル</Heading>

0 commit comments

Comments
 (0)