diff --git a/package.json b/package.json index d4d0b3b..96fe87a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "react-i18next": "^17.0.2", "react-markdown": "^10.1.0", "react-router-dom": "^7.13.0", + "react-select": "^5.10.2", "remark-gfm": "^4.0.1", "typescript": "^5.9.3", "zustand": "^5.0.11" diff --git a/src/RailRound.jsx b/src/RailRound.jsx index 09b7571..96a2c57 100644 --- a/src/RailRound.jsx +++ b/src/RailRound.jsx @@ -17,6 +17,7 @@ import { LogOut, User, Github, Star, Folder, Globe, Lock, Eye, EyeOff } from 'lucide-react'; +import Select from 'react-select'; import { LoginModal } from './components/LoginModal'; import { DragProvider, DropZone } from './components/DragContext'; import Chest from './components/Chest'; @@ -33,6 +34,38 @@ import { useStore } from './store'; import toast from 'react-hot-toast'; import { ESLint } from 'eslint'; + +const getSelectStyles = (isSmall = false) => ({ + control: (base) => ({ + ...base, + minHeight: isSmall ? '28px' : '36px', + fontSize: isSmall ? '11px' : '14px', + borderRadius: '0.25rem', + borderColor: '#e5e7eb', + boxShadow: 'none', + '&:hover': { + borderColor: '#d1d5db' + } + }), + dropdownIndicator: (base) => ({ + ...base, + padding: isSmall ? '2px' : '4px' + }), + menu: (base) => ({ + ...base, + zIndex: 50, + fontSize: isSmall ? '11px' : '14px', + }), + option: (base) => ({ + ...base, + padding: isSmall ? '4px 8px' : '8px 12px' + }), + valueContainer: (base) => ({ + ...base, + padding: isSmall ? '0 4px' : '2px 8px' + }) +}); + const CURRENT_VERSION = meta["currentVersion"]; const LAST_MODIFIED = manifest.lastModified const LAST_UPDATED = meta["lastUpdated"]; @@ -788,7 +821,15 @@ const TripEditor = ({ }); } }}> - + updateSegment(idx, 'toId', e.target.value)}>{segment.lineKey && railwayData[segment.lineKey]?.stations.map(s => )} + setAutoForm({ ...autoForm, startStation: e.target.value })}>{autoForm.startLine && railwayData[autoForm.startLine].stations.map(s => )} +
+ setAutoForm({ ...autoForm, endStation: e.target.value })}>{autoForm.endLine && railwayData[autoForm.endLine].stations.map(s => )} +
+ setSource(e.target.value)} - > - - {publicFolders.map(f => ( - - ))} - + setSource(e.target.value)} - > - - {publicFolders.map(f => ( - - ))} - + updateSegment(idx, 'fromId', e.target.value)}> - - {segment.lineKey && railwayData[segment.lineKey]?.stations.map(s => )} - + updateSegment(idx, 'toId', e.target.value)}> - - {segment.lineKey && railwayData[segment.lineKey]?.stations.map(s => )} - + updateSegment(idx, 'loopVia', e.target.value)} - > - - - - +
+ setAutoForm({ ...autoForm, startStation: e.target.value })}>{autoForm.startLine && railwayData[autoForm.startLine]?.stations.map(s => )} +
+ setAutoForm({ ...autoForm, endStation: e.target.value })}>{autoForm.endLine && railwayData[autoForm.endLine]?.stations.map(s => )} +
+ { - const newSettings = { ...badgeSettings, language: e.target.value }; + + options={[ + { value: 'zh-CN', label: '简体中文' }, + { value: 'en', label: 'English' }, + { value: 'ja-JP', label: '日本語' }, + { value: 'zh-TW', label: '繁體中文' } + ]} + isSearchable={false} + styles={getSelectStyles()} + className="w-full" + />
@@ -226,24 +280,27 @@ export const StatsPage: React.FC = () => { {(!badgeSettings.defaultMapCenter || badgeSettings.defaultMapCenter.mode === 'fixed') && (
- Math.abs(c.lat - (badgeSettings.defaultMapCenter?.lat || 35.6812)) < 0.001 && Math.abs(c.lng - (badgeSettings.defaultMapCenter?.lng || 139.7671)) < 0.001)?.name || 'Custom' + }} + onChange={(option: any) => { + const [lat, lng] = option.value.split(',').map(Number); const newSettings = { ...badgeSettings, defaultMapCenter: { mode: 'fixed' as const, lat, lng } }; setBadgeSettings(newSettings); if (user) saveData(user.token, trips, pins, folders, newSettings).catch(console.error); }} - > - {Object.entries(CITIES).map(([country, cities]) => ( - - {cities.map(city => ( - - ))} - - ))} - + options={Object.entries(CITIES).map(([country, cities]) => ({ + label: country === 'China' ? t('setup.china', '中国') : t('setup.japan', '日本'), + options: cities.map(city => ({ + value: `${city.lat},${city.lng}`, + label: city.name + })) + }))} + styles={getSelectStyles()} + className="w-full" + />
)}