@kids-reporter/routing-ui 0.1.0-alpha.4 → 0.1.0-alpha.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kids-reporter/routing-ui",
3
3
  "license": "MIT",
4
- "version": "0.1.0-alpha.4",
4
+ "version": "0.1.0-alpha.6",
5
5
  "description": "Routing UI for Kids Reporter",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -18,8 +18,7 @@
18
18
  "build": "./scripts/build.sh",
19
19
  "lint": "eslint . --config ./eslint.config.mjs",
20
20
  "lint:check": "eslint . --config ./eslint.config.mjs",
21
- "type-check": "tsc --noEmit",
22
- "postinstall": "yarn build"
21
+ "type-check": "tsc --noEmit"
23
22
  },
24
23
  "dependencies": {
25
24
  "@radix-ui/react-slot": "^1.2.3",
@@ -50,5 +49,8 @@
50
49
  "react": "18.3.1",
51
50
  "react-dom": "18.3.1",
52
51
  "tailwindcss": "^4.1.14"
53
- }
52
+ },
53
+ "files": [
54
+ "dist"
55
+ ]
54
56
  }
package/.prettierignore DELETED
@@ -1,17 +0,0 @@
1
- # Build outputs
2
- dist/
3
- lib/
4
- .next/
5
-
6
- # Generated files
7
- *.tsbuildinfo
8
-
9
- # Cache
10
- .eslintcache
11
-
12
- # OS
13
- .DS_Store
14
-
15
- # Environment
16
- .env*.local
17
- .env
package/babel.config.cjs DELETED
@@ -1,31 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- {
6
- targets: {
7
- node: '18',
8
- browsers: ['> 1%', 'last 2 versions', 'not dead'],
9
- },
10
- modules: 'commonjs', // Build CommonJS modules
11
- },
12
- ],
13
- [
14
- '@babel/preset-react',
15
- {
16
- runtime: 'automatic',
17
- development: process.env.NODE_ENV === 'development',
18
- pragma: undefined, // Use automatic runtime
19
- pragmaFrag: undefined, // Use automatic runtime
20
- },
21
- ],
22
- [
23
- '@babel/preset-typescript',
24
- {
25
- isTSX: true,
26
- allExtensions: true,
27
- },
28
- ],
29
- ],
30
- plugins: ['@babel/plugin-transform-runtime'],
31
- }
package/eslint.config.mjs DELETED
@@ -1,56 +0,0 @@
1
- import globals from 'globals'
2
-
3
- import baseConfig, {
4
- javascriptConfig,
5
- typescriptConfig,
6
- } from '../../eslint.base.config.mjs'
7
-
8
- export default [
9
- ...baseConfig,
10
- // Override for routing-ui package - React/TypeScript focused
11
- {
12
- ...typescriptConfig,
13
- files: ['src/**/*.{ts,tsx}'],
14
- rules: {
15
- ...typescriptConfig.rules,
16
- },
17
- },
18
- {
19
- ...javascriptConfig,
20
- files: ['src/**/*.{js,jsx}'],
21
- rules: {
22
- ...javascriptConfig.rules,
23
- // Tailwind CSS classname sorting rules
24
- 'no-restricted-syntax': [
25
- 'warn',
26
- {
27
- selector: 'JSXAttribute[name.name="className"]',
28
- message:
29
- 'Tailwind CSS classes should be sorted. Use prettier-plugin-tailwindcss for automatic sorting.',
30
- },
31
- {
32
- selector: 'JSXAttribute[name.name="class"]',
33
- message:
34
- 'CSS classes should be sorted. Consider using a class sorting tool.',
35
- },
36
- ],
37
- },
38
- },
39
- {
40
- files: ['**/*.config.{js,mjs,cjs}'],
41
- languageOptions: {
42
- ecmaVersion: 2022,
43
- sourceType: 'module',
44
- globals: {
45
- ...globals.node,
46
- ...globals.es2022,
47
- },
48
- },
49
- rules: {
50
- 'no-undef': 'error',
51
- },
52
- },
53
- {
54
- ignores: ['node_modules/**', 'dist/**', 'build/**'],
55
- },
56
- ]
@@ -1,13 +0,0 @@
1
- /** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
2
- export default {
3
- printWidth: 80,
4
- tabWidth: 2,
5
- semi: false,
6
- singleQuote: true,
7
- trailingComma: 'es5',
8
- bracketSpacing: true,
9
- arrowParens: 'always',
10
- plugins: ['prettier-plugin-tailwindcss'],
11
- tailwindStylesheet: './src/styles.css',
12
- tailwindFunctions: ['clsx', 'cn', 'cva'],
13
- }
package/scripts/build.sh DELETED
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- echo "Cleaning dist directory..."
6
- rm -rf ./dist
7
- mkdir -p ./dist
8
-
9
- echo "Building CJS version..."
10
- npx babel src --out-dir dist --extensions ".ts,.tsx" --source-maps
11
-
12
- echo "Copying CSS file..."
13
- cp ./src/styles.css ./dist/styles.css
14
-
15
- echo "Generating TypeScript declarations..."
16
- npx tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist
17
-
18
- echo "Build completed successfully!"
@@ -1,108 +0,0 @@
1
- 'use client'
2
-
3
- import { Slot } from '@radix-ui/react-slot'
4
- import { cva, type VariantProps } from 'class-variance-authority'
5
- import React from 'react'
6
-
7
- import { cn } from '../utils/cn'
8
-
9
- const buttonVariants = cva(
10
- // Base styles
11
- 'font-noto gap-2.5 font-bold inline-flex cursor-pointer items-center justify-center rounded-full transition-colors duration-200',
12
- {
13
- variants: {
14
- variant: {
15
- primary: [
16
- 'text-white border-0 bg-red-400',
17
- 'hover:bg-red-500',
18
- 'active:bg-red-600',
19
- 'disabled:text-white disabled:cursor-default disabled:bg-neutral-400',
20
- ],
21
- secondary: [
22
- 'bg-white text-gray-900 border-2 border-red-400',
23
- 'hover:text-white hover:border-red-500 hover:bg-red-500',
24
- 'active:text-white active:border-red-600 active:bg-red-600',
25
- 'disabled:bg-white disabled:cursor-default disabled:border-neutral-400 disabled:text-neutral-400',
26
- ],
27
- },
28
- size: {
29
- 44: 'h-11 px-5 py-2 text-base', // 44px height, 16px font size
30
- 36: 'h-9 px-4 py-2 text-sm', // 36px height, 14px font size
31
- 32: 'h-8 px-3 py-1 text-sm', // 32px height, 14px font size
32
- },
33
- },
34
- defaultVariants: {
35
- variant: 'primary',
36
- size: 44,
37
- },
38
- }
39
- )
40
-
41
- // Loading spinner icon component
42
- const LoadingSpinner = ({ size = 20 }: { size?: number }) => (
43
- <svg
44
- width={size}
45
- height={size}
46
- viewBox="0 0 25 24"
47
- fill="none"
48
- className="animate-spin"
49
- xmlns="http://www.w3.org/2000/svg"
50
- >
51
- <path
52
- opacity="0.5"
53
- d="M12.5 2C10.5222 2 8.58879 2.58649 6.9443 3.6853C5.29981 4.78412 4.01809 6.3459 3.26121 8.17317C2.50433 10.0004 2.3063 12.0111 2.69215 13.9509C3.078 15.8907 4.03041 17.6725 5.42894 19.0711C6.82746 20.4696 8.60929 21.422 10.5491 21.8079C12.4889 22.1937 14.4996 21.9957 16.3268 21.2388C18.1541 20.4819 19.7159 19.2002 20.8147 17.5557C21.9135 15.9112 22.5 13.9778 22.5 12C22.5 10.6868 22.2413 9.38642 21.7388 8.17317C21.2363 6.95991 20.4997 5.85752 19.5711 4.92893C18.6425 4.00035 17.5401 3.26375 16.3268 2.7612C15.1136 2.25866 13.8132 2 12.5 2ZM12.5 20C10.9178 20 9.37104 19.5308 8.05544 18.6518C6.73985 17.7727 5.71447 16.5233 5.10897 15.0615C4.50347 13.5997 4.34504 11.9911 4.65372 10.4393C4.9624 8.88743 5.72433 7.46197 6.84315 6.34315C7.96197 5.22433 9.38743 4.4624 10.9393 4.15372C12.4911 3.84504 14.0997 4.00346 15.5615 4.60896C17.0233 5.21447 18.2727 6.23984 19.1518 7.55544C20.0308 8.87103 20.5 10.4177 20.5 12C20.5 14.1217 19.6572 16.1566 18.1569 17.6569C16.6566 19.1571 14.6217 20 12.5 20Z"
54
- fill="currentColor"
55
- />
56
- <path
57
- d="M20.5 12H22.5C22.5 10.6868 22.2413 9.38642 21.7388 8.17317C21.2362 6.95991 20.4997 5.85752 19.5711 4.92893C18.6425 4.00035 17.5401 3.26375 16.3268 2.7612C15.1136 2.25866 13.8132 2 12.5 2V4C14.6217 4 16.6566 4.84285 18.1569 6.34315C19.6571 7.84344 20.5 9.87827 20.5 12Z"
58
- fill="currentColor"
59
- />
60
- </svg>
61
- )
62
-
63
- export type ButtonProps = {
64
- isLoading?: boolean
65
- disabled?: boolean
66
- asChild?: boolean
67
- children: React.ReactNode
68
- } & VariantProps<typeof buttonVariants> &
69
- React.ButtonHTMLAttributes<HTMLButtonElement>
70
-
71
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
72
- (
73
- {
74
- isLoading = false,
75
- disabled = false,
76
- asChild = false,
77
- size,
78
- variant,
79
- className,
80
- children,
81
- ...props
82
- },
83
- ref
84
- ) => {
85
- const isDisabled = disabled || isLoading
86
-
87
- const buttonClasses = cn(buttonVariants({ variant, size }), className)
88
-
89
- const Comp = asChild ? Slot : 'button'
90
-
91
- return (
92
- <Comp
93
- ref={ref}
94
- className={buttonClasses}
95
- disabled={isDisabled}
96
- {...props}
97
- >
98
- {isLoading ? (
99
- <LoadingSpinner size={size === 32 ? 16 : size === 36 ? 18 : 20} />
100
- ) : (
101
- children
102
- )}
103
- </Comp>
104
- )
105
- }
106
- )
107
-
108
- export default Button
@@ -1,2 +0,0 @@
1
- export { default as Button } from './button'
2
- export { default as Input } from './input'
@@ -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
- ]