#49 ぼちぼち

This commit is contained in:
2025-06-28 02:32:40 +09:00
parent ba1c1f1adf
commit 8020586ec6
19 changed files with 168 additions and 106 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import { API_BASE_URL } from '@/config'
import { Button } from '@/components/ui/button'
import type { Post, Tag } from '@/types'
@@ -64,9 +65,9 @@ export default ({ post, onSave }: Props) => {
</div>
{/* 送信 */}
<button onClick={handleSubmit}
<Button onClick={handleSubmit}
className="px-4 py-2 bg-blue-600 text-white rounded disabled:bg-gray-400">
</button>
</Button>
</div>)
}
+10 -9
View File
@@ -1,9 +1,11 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { Link, useParams } from 'react-router-dom'
import TagSearch from '@/components/TagSearch'
import SubsectionTitle from '@/components/common/SubsectionTitle'
import SidebarComponent from '@/components/layout/SidebarComponent'
import { API_BASE_URL } from '@/config'
import TagSearch from './TagSearch'
import SidebarComponent from './layout/SidebarComponent'
import { CATEGORIES } from '@/consts'
import type { Category, Post, Tag } from '@/types'
@@ -45,17 +47,16 @@ export default ({ post }: Props) => {
<SidebarComponent>
<TagSearch />
{CATEGORIES.map ((cat: Category) => cat in tags && (
<>
<h2>{categoryNames[cat]}</h2>
<div className="my-3">
<SubsectionTitle>{categoryNames[cat]}</SubsectionTitle>
<ul>
{tags[cat].map (tag => (
<li key={tag.id} className="mb-2">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}
className="text-blue-600 hover:underline">
<li key={tag.id} className="mb-1">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}>
{tag.name}
</Link>
</li>))}
</ul>
</>))}
</div>))}
</SidebarComponent>)
}
+6 -3
View File
@@ -1,7 +1,8 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import { Link, useNavigate, useLocation } from 'react-router-dom'
import { API_BASE_URL } from '../config'
import { API_BASE_URL } from '@/config'
import { cn } from '@/lib/utils'
import type { Tag } from '@/types'
@@ -23,8 +24,10 @@ const TagSearchBox: React.FC = (props: Props) => {
<ul className="absolute left-0 right-0 z-50 w-full bg-gray-800 border border-gray-600 rounded shadow">
{suggestions.map ((tag, i) => (
<li key={tag.id}
className={`px-3 py-2 cursor-pointer ${
i === activeIndex ? 'bg-blue-600 text-white' : 'hover:bg-gray-700' }`}
className={cn ('px-3 py-2 cursor-pointer',
(i === activeIndex
? 'bg-blue-600 text-white'
: 'hover:bg-gray-700'))}
onMouseDown={() => onSelect (tag)}
>
{tag.name}
+18 -21
View File
@@ -2,8 +2,9 @@ import React, { useEffect, useState } from 'react'
import axios from 'axios'
import { Link, useParams } from 'react-router-dom'
import { API_BASE_URL } from '@/config'
import TagSearch from './TagSearch'
import SidebarComponent from './layout/SidebarComponent'
import TagSearch from '@/components/TagSearch'
import SidebarComponent from '@/components/layout/SidebarComponent'
import SectionTitle from '@/components/common/SectionTitle'
import type { Post, Tag } from '@/types'
@@ -12,12 +13,6 @@ type TagByCategory = { [key: string]: Tag[] }
type Props = { posts: Post[] }
const tagNameMap: { [key: string]: string } = {
general: '一般',
deerjikist: 'ニジラー',
nico: 'ニコニコタグ' }
export default ({ posts }: Props) => {
const [tags, setTags] = useState<TagByCategory> ({ })
const [tagsCounts, setTagsCounts] = useState<{ [key: number]: number }> ({ })
@@ -47,18 +42,20 @@ export default ({ posts }: Props) => {
return (
<SidebarComponent>
<TagSearch />
{['general', 'deerjikist', 'nico'].map (cat => cat in tags && <>
<h2>{tagNameMap[cat]}</h2>
<ul>
{tags[cat].map (tag => (
<li key={tag.id} className="mb-2">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}
className="text-blue-600 hover:underline">
{tag.name}
</Link>
<span className="ml-1">{tagsCounts[tag.id]}</span>
</li>))}
</ul>
</>)}
<SectionTitle></SectionTitle>
<ul>
{['general', 'deerjikist', 'nico'].map (cat => cat in tags && (
<>
{tags[cat].map (tag => (
<li key={tag.id} className="mb-1">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}>
{tag.name}
</Link>
<span className="ml-1">{tagsCounts[tag.id]}</span>
</li>))}
</>))}
</ul>
<SectionTitle></SectionTitle>
<Link></Link>
</SidebarComponent>)
}
+5 -5
View File
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
import SettingsDialogue from './SettingsDialogue'
import { Button } from './ui/button'
import clsx from 'clsx'
import { cn } from '@/lib/utils'
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
import type { User } from '@/types'
@@ -33,10 +33,10 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
title: string
menu?: Menu
base?: string }) => (
<Link to={to} className={clsx ('hover:text-orange-500 h-full flex items-center',
(location.pathname.startsWith (base ?? to)
? 'bg-gray-700 px-4 font-bold'
: 'px-2'))}>
<Link to={to} className={cn ('hover:text-orange-500 h-full flex items-center',
(location.pathname.startsWith (base ?? to)
? 'bg-gray-700 px-4 font-bold'
: 'px-2'))}>
{title}
</Link>)
+9
View File
@@ -0,0 +1,9 @@
import React from 'react'
type Props = { children: React.ReactNode }
export default ({ children }: Props) => (
<div className="max-w-xl mx-auto p-4 space-y-4">
{children}
</div>)
+28
View File
@@ -0,0 +1,28 @@
import React from 'react'
type Props = { children: React.ReactNode
checkBox?: { label: string
checked: boolean
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void } }
export default ({ children, checkBox }: Props) => {
if (!(checkBox))
{
return (
<label className="block font-semibold mb-1">
{children}
</label>)
}
return (
<div className="flex gap-2 mb-1">
<label className="flex-1 block font-semibold">{children}</label>
<label className="flex items-center block gap-1">
<input type="checkbox"
checked={checkBox.checked}
onChange={checkBox.onChange} />
{checkBox.label}
</label>
</div>)
}
@@ -0,0 +1,9 @@
import React from 'react'
type Props = { children: React.ReactNode }
export default ({ children }: Props) => (
<h1 className="text-2xl font-bold mb-2">
{children}
</h1>)
@@ -0,0 +1,9 @@
import React from 'react'
type Props = { children: React.ReactNode }
export default ({ children }: Props) => (
<h2 className="text-xl my-4">
{children}
</h2>)
@@ -0,0 +1,9 @@
import React from 'react'
type Props = { children: React.ReactNode }
export default ({ children }: Props) => (
<h3 className="my-2">
{children}
</h3>)
+3 -2
View File
@@ -1,4 +1,5 @@
import React, { useState } from 'react'
import { cn } from '@/lib/utils'
type TabProps = { name: string
init?: boolean
@@ -6,7 +7,7 @@ type TabProps = { name: string
type Props = { children: React.ReactElement<{ name: string }>[] }
export const Tab = ({ children }: TabProps) => children
export const Tab = ({ children }: TabProps) => <>{children}</>
export default ({ children }: Props) => {
@@ -23,7 +24,7 @@ export default ({ children }: Props) => {
{tabs.map ((tab, i) => (
<a key={i}
href="#"
className={`text-blue-400 hover:underline ${ i === current ? 'font-bold' : '' }`}
className={cn (i === current && 'font-bold')}
onClick={ev => {
ev.preventDefault ()
setCurrent (i)