@kids-reporter/routing-ui 0.1.0-alpha.5 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/input.d.ts +6 -2
- package/dist/components/input.d.ts.map +1 -1
- package/dist/components/input.js +30 -9
- package/dist/components/input.js.map +1 -1
- package/dist/header/shared-components.d.ts.map +1 -1
- package/dist/header/shared-components.js +2 -1
- package/dist/header/shared-components.js.map +1 -1
- package/dist/styles.css +11 -0
- package/package.json +6 -5
- package/.prettierignore +0 -17
- package/babel.config.cjs +0 -31
- package/eslint.config.mjs +0 -56
- package/prettier.config.mjs +0 -13
- package/scripts/build.sh +0 -18
- package/src/components/button.tsx +0 -108
- package/src/components/index.tsx +0 -2
- package/src/components/input.tsx +0 -171
- package/src/constants/default-values.tsx +0 -153
- package/src/footer.tsx +0 -149
- package/src/header/desktop-header.tsx +0 -132
- package/src/header/header-context.tsx +0 -82
- package/src/header/index.tsx +0 -104
- package/src/header/is-logged-in-setter.tsx +0 -27
- package/src/header/menu/header-menu-item-group.tsx +0 -37
- package/src/header/menu/header-menu-item.tsx +0 -132
- package/src/header/menu/index.tsx +0 -205
- package/src/header/mobile-back-button-href-setter.tsx +0 -22
- package/src/header/mobile-header.tsx +0 -77
- package/src/header/post-title-setter.tsx +0 -22
- package/src/header/shared-components.tsx +0 -325
- package/src/hooks/index.ts +0 -3
- package/src/hooks/use-is-at-top.ts +0 -23
- package/src/hooks/use-media-query.ts +0 -57
- package/src/hooks/use-scroll-level.ts +0 -52
- package/src/icons/index.tsx +0 -378
- package/src/index.ts +0 -11
- package/src/styles.css +0 -354
- package/src/types/index.ts +0 -10
- package/src/utils/cn.ts +0 -41
- package/src/utils/generate-social-media-config.ts +0 -75
- package/src/utils/index.ts +0 -2
- package/tsconfig.json +0 -33
package/src/components/input.tsx
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { cva } from 'class-variance-authority'
|
|
4
|
-
import { forwardRef, useRef, useState } from 'react'
|
|
5
|
-
|
|
6
|
-
import { SearchIconSmall } from '../icons'
|
|
7
|
-
import { cn } from '../utils/cn'
|
|
8
|
-
|
|
9
|
-
// Close icon component
|
|
10
|
-
const CloseIcon = ({ className }: { className?: string }) => (
|
|
11
|
-
<svg
|
|
12
|
-
width="20"
|
|
13
|
-
height="20"
|
|
14
|
-
viewBox="0 0 20 20"
|
|
15
|
-
fill="none"
|
|
16
|
-
className={className}
|
|
17
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
-
>
|
|
19
|
-
<circle cx="10" cy="10" r="10" fill="currentColor" />
|
|
20
|
-
<path
|
|
21
|
-
d="M7 7l6 6M13 7l-6 6"
|
|
22
|
-
stroke="white"
|
|
23
|
-
strokeWidth="1.5"
|
|
24
|
-
strokeLinecap="round"
|
|
25
|
-
strokeLinejoin="round"
|
|
26
|
-
/>
|
|
27
|
-
</svg>
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const inputVariants = cva(
|
|
31
|
-
// Base styles
|
|
32
|
-
'desktop:bg-white! px-4 py-1.5 h-11 flex items-center rounded-full border border-transparent bg-neutral-100 prose-p1 transition-colors duration-200 hover:border-neutral-600',
|
|
33
|
-
{
|
|
34
|
-
variants: {
|
|
35
|
-
state: {
|
|
36
|
-
default: 'border-transparent',
|
|
37
|
-
hover: 'border-neutral-600',
|
|
38
|
-
focus: 'border-neutral-600',
|
|
39
|
-
active: 'border-neutral-600',
|
|
40
|
-
unfocus: 'border-transparent',
|
|
41
|
-
error: 'border-red-600',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
defaultVariants: {
|
|
45
|
-
state: 'default',
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
export type InputProps = {
|
|
51
|
-
placeholder?: string
|
|
52
|
-
value?: string
|
|
53
|
-
onChange?: (value: string) => void
|
|
54
|
-
onClear?: () => void
|
|
55
|
-
showClearButton?: boolean
|
|
56
|
-
children?: React.ReactNode
|
|
57
|
-
inputRef?: React.RefObject<HTMLInputElement>
|
|
58
|
-
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value'>
|
|
59
|
-
|
|
60
|
-
const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
61
|
-
(
|
|
62
|
-
{
|
|
63
|
-
placeholder = '搜尋更多新聞、議題',
|
|
64
|
-
value,
|
|
65
|
-
onChange,
|
|
66
|
-
onClear,
|
|
67
|
-
showClearButton = true,
|
|
68
|
-
className,
|
|
69
|
-
onFocus,
|
|
70
|
-
onBlur,
|
|
71
|
-
inputRef,
|
|
72
|
-
...props
|
|
73
|
-
},
|
|
74
|
-
ref
|
|
75
|
-
) => {
|
|
76
|
-
const [internalValue, setInternalValue] = useState('')
|
|
77
|
-
const [isFocused, setIsFocused] = useState(false)
|
|
78
|
-
const [isActive, setIsActive] = useState(false)
|
|
79
|
-
const innerInputRef = useRef<HTMLInputElement>(null)
|
|
80
|
-
const currentValue = value !== undefined ? value : internalValue
|
|
81
|
-
const hasValue = currentValue.length > 0
|
|
82
|
-
|
|
83
|
-
// Determine current state
|
|
84
|
-
const currentState = isFocused
|
|
85
|
-
? 'focus'
|
|
86
|
-
: hasValue
|
|
87
|
-
? isActive
|
|
88
|
-
? 'active'
|
|
89
|
-
: 'unfocus'
|
|
90
|
-
: 'default'
|
|
91
|
-
|
|
92
|
-
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
93
|
-
const newValue = e.target.value
|
|
94
|
-
if (onChange) {
|
|
95
|
-
onChange(newValue)
|
|
96
|
-
} else {
|
|
97
|
-
setInternalValue(newValue)
|
|
98
|
-
}
|
|
99
|
-
setIsActive(true)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
103
|
-
if (onFocus) {
|
|
104
|
-
onFocus(e)
|
|
105
|
-
}
|
|
106
|
-
setIsFocused(true)
|
|
107
|
-
setIsActive(true)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
111
|
-
if (onBlur) {
|
|
112
|
-
onBlur(e)
|
|
113
|
-
}
|
|
114
|
-
setIsFocused(false)
|
|
115
|
-
setIsActive(false)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const handleClear = (e: React.MouseEvent) => {
|
|
119
|
-
e.preventDefault()
|
|
120
|
-
e.stopPropagation()
|
|
121
|
-
|
|
122
|
-
if (onChange) {
|
|
123
|
-
onChange('')
|
|
124
|
-
} else {
|
|
125
|
-
setInternalValue('')
|
|
126
|
-
}
|
|
127
|
-
if (onClear) {
|
|
128
|
-
onClear()
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const currentRef = inputRef ?? innerInputRef
|
|
132
|
-
currentRef.current?.focus()
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const inputClasses = cn(inputVariants({ state: currentState }), className)
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<div className="gap-2 flex flex-col">
|
|
139
|
-
<div className={inputClasses} ref={ref}>
|
|
140
|
-
<div className="text-neutral-600">
|
|
141
|
-
<SearchIconSmall />
|
|
142
|
-
</div>
|
|
143
|
-
<input
|
|
144
|
-
type="text"
|
|
145
|
-
value={currentValue}
|
|
146
|
-
onChange={handleChange}
|
|
147
|
-
onFocus={handleFocus}
|
|
148
|
-
onBlur={handleBlur}
|
|
149
|
-
placeholder={placeholder}
|
|
150
|
-
className="placeholder:font-medium ml-2 max-w-[72%] flex-1 flex-shrink-1 bg-transparent text-neutral-900 placeholder:text-neutral-400 focus:outline-none"
|
|
151
|
-
ref={inputRef ?? innerInputRef}
|
|
152
|
-
{...props}
|
|
153
|
-
/>
|
|
154
|
-
|
|
155
|
-
{showClearButton && hasValue && (
|
|
156
|
-
<button
|
|
157
|
-
type="button"
|
|
158
|
-
onClick={handleClear}
|
|
159
|
-
className="p-1/2 ml-auto flex-shrink-0 cursor-pointer rounded-full text-neutral-400 transition-colors hover:text-neutral-600 active:bg-neutral-200"
|
|
160
|
-
aria-label="Clear input"
|
|
161
|
-
>
|
|
162
|
-
<CloseIcon />
|
|
163
|
-
</button>
|
|
164
|
-
)}
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
export default Input
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { SettingsIconSmall } from '../icons'
|
|
2
|
-
import { MenuItem } from '../types'
|
|
3
|
-
|
|
4
|
-
export const SUBSCRIBE_URL = 'https://solink.soundon.fm/kidstwreporter'
|
|
5
|
-
export const DONATE_URL = 'https://support.twreporter.org/'
|
|
6
|
-
export const PRIVACY_POLICY = 'https://www.twreporter.org/a/privacy-policy'
|
|
7
|
-
export const SEARCH_PLACEHOLDER = '搜尋更多新聞、議題'
|
|
8
|
-
|
|
9
|
-
export const MENU_ITEMS: MenuItem[] = [
|
|
10
|
-
{
|
|
11
|
-
label: '最新',
|
|
12
|
-
href: '/all',
|
|
13
|
-
subItems: [],
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
label: '專題',
|
|
17
|
-
href: '/topic/page',
|
|
18
|
-
subItems: [],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: '新聞',
|
|
22
|
-
href: '/category/news',
|
|
23
|
-
subItems: [
|
|
24
|
-
{ label: '焦點新聞', href: '/category/news/times' },
|
|
25
|
-
{ label: '真的假的', href: '/category/news/knowledge' },
|
|
26
|
-
{ label: '人物故事', href: '/category/news/story' },
|
|
27
|
-
{ label: '文化報導', href: '/category/news/explore' },
|
|
28
|
-
{ label: '專欄', href: '/category/news/column' },
|
|
29
|
-
{ label: '英文新聞', href: '/categories/news/english-version' },
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: '多媒體',
|
|
34
|
-
href: '/category/comics',
|
|
35
|
-
subItems: [
|
|
36
|
-
{ label: '圖解新聞', href: '/category/comics/times' },
|
|
37
|
-
{ label: '新聞遊戲', href: '/category/comics/test-news' },
|
|
38
|
-
{ label: '圖文故事', href: '/category/comics/graphic-story' },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
label: '校園',
|
|
43
|
-
href: '/category/campus',
|
|
44
|
-
subItems: [
|
|
45
|
-
{ label: '校園寶可夢', href: '/category/campus/campus-pokemon' },
|
|
46
|
-
{ label: '上課好好玩', href: '/category/campus/teaching' },
|
|
47
|
-
{ label: '小讀者連線', href: '/category/campus/joining' },
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: 'Podcast',
|
|
52
|
-
href: '/category/listening-news',
|
|
53
|
-
subItems: [
|
|
54
|
-
{
|
|
55
|
-
label: '小記者,問什麼?',
|
|
56
|
-
href: '/category/listening-news/kids-reporter-ask',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: '新聞讀報',
|
|
60
|
-
href: '/category/listening-news/multilingual-listening-news',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: '新聞關鍵字',
|
|
64
|
-
href: '/category/listening-news/listening-news-keywords',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
label: '文化關鍵字',
|
|
68
|
-
href: '/category/listening-news/listening-news-culture-keywords',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: '教案',
|
|
74
|
-
href: '/category/classroom',
|
|
75
|
-
subItems: [],
|
|
76
|
-
},
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
export const ADDITIONAL_MENU_ITEMS: MenuItem[] = [
|
|
80
|
-
{
|
|
81
|
-
label: '閱讀探索設定',
|
|
82
|
-
href: '/reading-settings',
|
|
83
|
-
subItems: [],
|
|
84
|
-
showIcon: true,
|
|
85
|
-
icon: <SettingsIconSmall />,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
label: '關於我們',
|
|
89
|
-
href: '/about',
|
|
90
|
-
subItems: [],
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: '呼叫報導仔流程',
|
|
94
|
-
href: '/about#callkidsreporter',
|
|
95
|
-
subItems: [],
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: '投稿專區',
|
|
99
|
-
href: 'https://forms.gle/49AEG8kFj7QWjgij8',
|
|
100
|
-
subItems: [],
|
|
101
|
-
external: true,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
label: '加入小記者',
|
|
105
|
-
href: 'https://forms.gle/eGq5jagNTwriwSCX6',
|
|
106
|
-
subItems: [],
|
|
107
|
-
external: true,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: '訂閱Podcast',
|
|
111
|
-
href: 'https://solink.soundon.fm/kidstwreporter',
|
|
112
|
-
subItems: [],
|
|
113
|
-
external: true,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
label: '聯絡我們',
|
|
117
|
-
href: '/about#mail',
|
|
118
|
-
subItems: [],
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
label: '前往《報導者》',
|
|
122
|
-
href: 'https://www.twreporter.org/',
|
|
123
|
-
subItems: [],
|
|
124
|
-
external: true,
|
|
125
|
-
},
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
export const SOCIAL_MEDIA_ITEMS = [
|
|
129
|
-
{
|
|
130
|
-
label: 'Facebook',
|
|
131
|
-
href: 'https://www.facebook.com/twreporter/',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
label: 'Instagram',
|
|
135
|
-
href: 'https://www.instagram.com/twreporter/',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
label: 'YouTube',
|
|
139
|
-
href: 'https://www.youtube.com/@TwreporterOrg',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
label: 'Threads',
|
|
143
|
-
href: 'https://www.threads.com/@twreporter',
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
label: 'Medium',
|
|
147
|
-
href: 'https://medium.com/twreporter',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
label: 'RSS',
|
|
151
|
-
href: 'https://kids-storage.twreporter.org/rss/rss.xml',
|
|
152
|
-
},
|
|
153
|
-
]
|
package/src/footer.tsx
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import Button from './components/button'
|
|
4
|
-
import {
|
|
5
|
-
ADDITIONAL_MENU_ITEMS,
|
|
6
|
-
DONATE_URL,
|
|
7
|
-
PRIVACY_POLICY,
|
|
8
|
-
SOCIAL_MEDIA_ITEMS,
|
|
9
|
-
} from './constants/default-values'
|
|
10
|
-
import { MenuItem, SocialMediaHrefs } from './types'
|
|
11
|
-
import { generateSocialMediaConfig } from './utils/generate-social-media-config'
|
|
12
|
-
|
|
13
|
-
type FooterProps = {
|
|
14
|
-
socialMediaHrefs?: SocialMediaHrefs
|
|
15
|
-
additionalMenuItems?: MenuItem[]
|
|
16
|
-
donateUrl?: string
|
|
17
|
-
privacyPolicyUrl?: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const Footer = ({
|
|
21
|
-
socialMediaHrefs = SOCIAL_MEDIA_ITEMS.map((item) => item.href),
|
|
22
|
-
additionalMenuItems = ADDITIONAL_MENU_ITEMS,
|
|
23
|
-
donateUrl = DONATE_URL,
|
|
24
|
-
privacyPolicyUrl = PRIVACY_POLICY,
|
|
25
|
-
}: FooterProps) => {
|
|
26
|
-
const socialMediaConfig = generateSocialMediaConfig(socialMediaHrefs)
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<footer className="w-full bg-neutral-white">
|
|
30
|
-
{/* Main Footer Content */}
|
|
31
|
-
<div className="py-12 desktop:py-14 w-full bg-neutral-white px-(--margin-mobile) desktop:px-(--margin-desktop)">
|
|
32
|
-
<div className="max-w-300 mx-auto">
|
|
33
|
-
<div className="gap-8 flex flex-col items-center desktop:flex-row desktop:justify-between">
|
|
34
|
-
{/* Logo and Description */}
|
|
35
|
-
<div className="max-w-100 gap-6 flex w-full flex-col items-center desktop:items-start">
|
|
36
|
-
<div className="flex items-center">
|
|
37
|
-
<a href="/" className="flex items-center">
|
|
38
|
-
<img
|
|
39
|
-
src="/assets/images/footer-logo.svg"
|
|
40
|
-
alt="少年報導者"
|
|
41
|
-
loading="lazy"
|
|
42
|
-
width={238}
|
|
43
|
-
height={26}
|
|
44
|
-
/>
|
|
45
|
-
</a>
|
|
46
|
-
</div>
|
|
47
|
-
<p className="w-full prose-p2 text-neutral-900">
|
|
48
|
-
《少年報導者》是由非營利媒體《報導者》針對兒少打造的深度新聞報導品牌,與兒童和少年一起理解世界,參與未來。
|
|
49
|
-
</p>
|
|
50
|
-
<Button size={44} variant="secondary" asChild className="w-75">
|
|
51
|
-
<a href={donateUrl} target="_blank" rel="noreferrer">
|
|
52
|
-
贊助我們
|
|
53
|
-
</a>
|
|
54
|
-
</Button>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<div className="gap-6 flex flex-row">
|
|
58
|
-
<div className="gap-2 flex flex-col">
|
|
59
|
-
{additionalMenuItems.slice(0, 4).map((link) => (
|
|
60
|
-
<a
|
|
61
|
-
key={link.label}
|
|
62
|
-
href={link.href}
|
|
63
|
-
className="min-w-30 prose-p2-bold text-neutral-900 transition-colors duration-200 hover:text-red-400"
|
|
64
|
-
target={link.external ? '_blank' : undefined}
|
|
65
|
-
rel={link.external ? 'noopener noreferrer' : undefined}
|
|
66
|
-
>
|
|
67
|
-
{link.label}
|
|
68
|
-
</a>
|
|
69
|
-
))}
|
|
70
|
-
</div>
|
|
71
|
-
<div className="gap-2 flex flex-col">
|
|
72
|
-
{additionalMenuItems.slice(4).map((link) => (
|
|
73
|
-
<a
|
|
74
|
-
key={link.label}
|
|
75
|
-
href={link.href}
|
|
76
|
-
className="min-w-30 prose-p2-bold text-neutral-900 transition-colors duration-200 hover:text-red-400"
|
|
77
|
-
target={link.external ? '_blank' : undefined}
|
|
78
|
-
rel={link.external ? 'noopener noreferrer' : undefined}
|
|
79
|
-
>
|
|
80
|
-
{link.label}
|
|
81
|
-
</a>
|
|
82
|
-
))}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<div className="py-6 w-full bg-red-400 px-(--margin-mobile) desktop:px-(--margin-desktop)">
|
|
90
|
-
<div className="max-w-300 mx-auto">
|
|
91
|
-
<div className="gap-5 desktop:gap-4 flex flex-col items-center desktop:flex-row desktop:justify-between">
|
|
92
|
-
<div className="gap-4 order-1 flex items-center desktop:order-2">
|
|
93
|
-
{socialMediaConfig.map((social) => {
|
|
94
|
-
const IconComponent = social.icon
|
|
95
|
-
return (
|
|
96
|
-
<a
|
|
97
|
-
key={social.label}
|
|
98
|
-
href={social.href}
|
|
99
|
-
className="relative text-neutral-white transition-colors duration-200 hover:text-neutral-200"
|
|
100
|
-
target="_blank"
|
|
101
|
-
rel="noopener noreferrer"
|
|
102
|
-
aria-label={social.label}
|
|
103
|
-
>
|
|
104
|
-
<div className="peer w-6 h-6 relative z-10 flex items-center justify-center rounded-full text-neutral-white transition-all duration-200 hover:text-red-500">
|
|
105
|
-
{IconComponent && <IconComponent />}
|
|
106
|
-
</div>
|
|
107
|
-
<div className="p-2 peer-hover:bg-white absolute top-1/2 left-1/2 z-1 flex h-[23px] w-[23px] -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full transition-all duration-200"></div>
|
|
108
|
-
</a>
|
|
109
|
-
)
|
|
110
|
-
})}
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<div className="text-center prose-p3 text-neutral-white desktop:order-1 desktop:text-left">
|
|
114
|
-
<p className="desktop:inline">
|
|
115
|
-
衛部救字第1131363879號|勸募期間 2025/1/1~12/31
|
|
116
|
-
<span className="hidden desktop:inline">|</span>
|
|
117
|
-
</p>
|
|
118
|
-
<p className="desktop:inline">
|
|
119
|
-
<a
|
|
120
|
-
href={privacyPolicyUrl}
|
|
121
|
-
target="_blank"
|
|
122
|
-
className="desktop:ml-1 text-neutral-white underline"
|
|
123
|
-
rel="noopener noreferrer"
|
|
124
|
-
>
|
|
125
|
-
隱私政策
|
|
126
|
-
</a>
|
|
127
|
-
|
|
|
128
|
-
<a
|
|
129
|
-
href="https://www.twreporter.org/a/license-footer"
|
|
130
|
-
target="_blank"
|
|
131
|
-
className="desktop:ml-1 text-neutral-white underline"
|
|
132
|
-
rel="noopener noreferrer"
|
|
133
|
-
>
|
|
134
|
-
許可協議
|
|
135
|
-
</a>
|
|
136
|
-
</p>
|
|
137
|
-
<p className="hidden desktop:inline">|</p>
|
|
138
|
-
<p className="desktop:inline">
|
|
139
|
-
Copyright © {new Date().getFullYear()} The Reporter
|
|
140
|
-
</p>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
</footer>
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export default Footer
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { LoginIcon } from '../icons'
|
|
4
|
-
import type { MenuItem } from '../types'
|
|
5
|
-
import { cn } from '../utils/cn'
|
|
6
|
-
import {
|
|
7
|
-
ActionButtons,
|
|
8
|
-
BottomNavigation,
|
|
9
|
-
HamburgerButton,
|
|
10
|
-
LogoLink,
|
|
11
|
-
} from './shared-components'
|
|
12
|
-
|
|
13
|
-
type DesktopHeaderProps = {
|
|
14
|
-
onHamburgerOverlayOpen: () => void
|
|
15
|
-
keywords: string[]
|
|
16
|
-
compactMode: boolean
|
|
17
|
-
postTitle?: string
|
|
18
|
-
hide: boolean
|
|
19
|
-
searchPlaceholder: string
|
|
20
|
-
subscribeUrl: string
|
|
21
|
-
menuItems: MenuItem[]
|
|
22
|
-
isLoggedIn?: boolean
|
|
23
|
-
loginUrl?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function DesktopHeader({
|
|
27
|
-
onHamburgerOverlayOpen,
|
|
28
|
-
keywords,
|
|
29
|
-
compactMode,
|
|
30
|
-
postTitle,
|
|
31
|
-
hide,
|
|
32
|
-
searchPlaceholder,
|
|
33
|
-
subscribeUrl,
|
|
34
|
-
menuItems,
|
|
35
|
-
isLoggedIn,
|
|
36
|
-
loginUrl,
|
|
37
|
-
}: DesktopHeaderProps) {
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
<div className="hidden h-(--desktop-header-height) desktop:block"></div>
|
|
41
|
-
<div
|
|
42
|
-
className={cn(
|
|
43
|
-
'top-0 ease-in-out fixed left-1/2 z-1000 hidden w-full -translate-x-1/2 transform transition-all duration-500 desktop:block',
|
|
44
|
-
compactMode && 'bg-white',
|
|
45
|
-
hide
|
|
46
|
-
? 'pointer-events-none -translate-y-full opacity-0'
|
|
47
|
-
: 'translate-y-0 pointer-events-auto opacity-100'
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
<div className="px-12 hidden w-full bg-transparent desktop:block">
|
|
51
|
-
<div className="max-w-300 mx-auto">
|
|
52
|
-
<div
|
|
53
|
-
className={cn(
|
|
54
|
-
'px-4 flex items-center justify-between py-[18px]',
|
|
55
|
-
compactMode && 'py-2.5'
|
|
56
|
-
)}
|
|
57
|
-
>
|
|
58
|
-
<div className={'flex items-center'}>
|
|
59
|
-
<div
|
|
60
|
-
className={cn(
|
|
61
|
-
'ease-in-out overflow-hidden transition-all duration-500',
|
|
62
|
-
compactMode
|
|
63
|
-
? 'translate-x-0 max-w-12 mr-4 w-auto scale-100 opacity-100'
|
|
64
|
-
: '-translate-x-2 w-0 max-w-0 pointer-events-none scale-95 opacity-0'
|
|
65
|
-
)}
|
|
66
|
-
>
|
|
67
|
-
<HamburgerButton
|
|
68
|
-
onHamburgerOverlayOpen={onHamburgerOverlayOpen}
|
|
69
|
-
small
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
72
|
-
<div className={compactMode ? 'mr-12' : 'mr-8'}>
|
|
73
|
-
<LogoLink compactMode={compactMode} />
|
|
74
|
-
</div>
|
|
75
|
-
{postTitle && (
|
|
76
|
-
<div className="pr-12 block">
|
|
77
|
-
<p className="font-medium tracking-wide max-w-124 overflow-hidden prose-p2 text-ellipsis whitespace-nowrap text-neutral-900">
|
|
78
|
-
{postTitle}
|
|
79
|
-
</p>
|
|
80
|
-
</div>
|
|
81
|
-
)}
|
|
82
|
-
<div
|
|
83
|
-
className={cn(
|
|
84
|
-
'ease-in-out overflow-hidden transition-all duration-500',
|
|
85
|
-
compactMode
|
|
86
|
-
? 'max-h-0 -translate-x-8 scale-95 opacity-0'
|
|
87
|
-
: 'max-h-20 max-w-auto scale-100 opacity-100',
|
|
88
|
-
postTitle && compactMode && 'max-w-0'
|
|
89
|
-
)}
|
|
90
|
-
>
|
|
91
|
-
<span className="font-medium translate-y-0 inline-block prose-p2 tracking-[2.2px]! text-nowrap text-neutral-900 opacity-100">
|
|
92
|
-
理解世界 × 參與未來
|
|
93
|
-
</span>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
|
|
97
|
-
<div className="gap-4 flex items-center">
|
|
98
|
-
<ActionButtons
|
|
99
|
-
tags={keywords}
|
|
100
|
-
hideCtaButtons={compactMode}
|
|
101
|
-
searchPlaceholder={searchPlaceholder}
|
|
102
|
-
subscribeUrl={subscribeUrl}
|
|
103
|
-
/>
|
|
104
|
-
<a
|
|
105
|
-
href={isLoggedIn ? '/member' : (loginUrl ?? '/login')}
|
|
106
|
-
className="w-8 h-8 flex items-center justify-center rounded-full text-red-400 transition-colors duration-200 hover:text-red-500"
|
|
107
|
-
aria-label="登入"
|
|
108
|
-
>
|
|
109
|
-
<LoginIcon />
|
|
110
|
-
</a>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
<div
|
|
115
|
-
className={cn(
|
|
116
|
-
'ease-in-out overflow-hidden transition-all duration-500',
|
|
117
|
-
compactMode
|
|
118
|
-
? 'h-0 -translate-y-4 opacity-0'
|
|
119
|
-
: 'translate-y-0 h-auto opacity-100'
|
|
120
|
-
)}
|
|
121
|
-
>
|
|
122
|
-
<BottomNavigation
|
|
123
|
-
onHamburgerOverlayOpen={onHamburgerOverlayOpen}
|
|
124
|
-
menuItems={menuItems}
|
|
125
|
-
/>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
</>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import {
|
|
3
|
-
createContext,
|
|
4
|
-
ReactNode,
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
useMemo,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react'
|
|
10
|
-
|
|
11
|
-
type HeaderContextType = {
|
|
12
|
-
postTitle?: string
|
|
13
|
-
setPostTitle: (title?: string) => void
|
|
14
|
-
isMenuOpen: boolean
|
|
15
|
-
openMenu: () => void
|
|
16
|
-
closeMenu: () => void
|
|
17
|
-
keywords: string[]
|
|
18
|
-
isLoggedIn: boolean
|
|
19
|
-
setIsLoggedIn: (isLoggedIn: boolean) => void
|
|
20
|
-
mobileBackButtonHref?: string
|
|
21
|
-
setMobileBackButtonHref: (href?: string) => void
|
|
22
|
-
loginUrl?: string
|
|
23
|
-
setLoginUrl: (url?: string) => void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const HeaderContext = createContext<HeaderContextType | undefined>(undefined)
|
|
27
|
-
|
|
28
|
-
export function HeaderProvider({
|
|
29
|
-
children,
|
|
30
|
-
keywords,
|
|
31
|
-
}: {
|
|
32
|
-
children: ReactNode
|
|
33
|
-
keywords: string[]
|
|
34
|
-
}) {
|
|
35
|
-
const [postTitle, setPostTitle] = useState<string | undefined>(undefined)
|
|
36
|
-
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
|
37
|
-
const [isLoggedIn, setIsLoggedIn] = useState(false)
|
|
38
|
-
const [mobileBackButtonHref, setMobileBackButtonHref] = useState<
|
|
39
|
-
string | undefined
|
|
40
|
-
>(undefined)
|
|
41
|
-
const [loginUrl, setLoginUrl] = useState<string | undefined>(undefined)
|
|
42
|
-
const openMenu = useCallback(() => setIsMenuOpen(true), [])
|
|
43
|
-
const closeMenu = useCallback(() => setIsMenuOpen(false), [])
|
|
44
|
-
|
|
45
|
-
const contextValue = useMemo(
|
|
46
|
-
() => ({
|
|
47
|
-
postTitle,
|
|
48
|
-
setPostTitle,
|
|
49
|
-
isMenuOpen,
|
|
50
|
-
openMenu,
|
|
51
|
-
closeMenu,
|
|
52
|
-
keywords,
|
|
53
|
-
isLoggedIn,
|
|
54
|
-
setIsLoggedIn,
|
|
55
|
-
mobileBackButtonHref,
|
|
56
|
-
setMobileBackButtonHref,
|
|
57
|
-
loginUrl,
|
|
58
|
-
setLoginUrl,
|
|
59
|
-
}),
|
|
60
|
-
[
|
|
61
|
-
postTitle,
|
|
62
|
-
isMenuOpen,
|
|
63
|
-
openMenu,
|
|
64
|
-
closeMenu,
|
|
65
|
-
keywords,
|
|
66
|
-
isLoggedIn,
|
|
67
|
-
mobileBackButtonHref,
|
|
68
|
-
loginUrl,
|
|
69
|
-
]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<HeaderContext.Provider value={contextValue}>
|
|
74
|
-
{children}
|
|
75
|
-
</HeaderContext.Provider>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function useHeaderContext() {
|
|
80
|
-
const context = useContext(HeaderContext)
|
|
81
|
-
return context
|
|
82
|
-
}
|