本文档提供了 Tech Interview Handbook 门户应用程序中使用的可重用共享组件的技术文档。这些组件是简历审查系统、优惠系统和问题库系统的构建块,可确保一致性并减少代码重复。有关系统特定组件的信息,请参阅简历审查系统、优惠系统和问题库系统的文档。
此代码库中的共享组件分为几个类别:
下图显示了这些共享组件与门户应用程序中主要系统的关系。
来源:apps/portal/src/components/global/AppShell.tsx apps/portal/src/components/shared/CompaniesTypeahead.tsx apps/portal/src/components/shared/CountriesTypeahead.tsx apps/portal/src/components/shared/CitiesTypeahead.tsx apps/portal/src/components/shared/JobTitlesTypeahead.tsx apps/portal/src/components/global/GoogleAnalytics.tsx
AppShell 组件是整个门户应用程序的主布局包装器。它提供了:
来源:apps/portal/src/components/global/AppShell.tsx133-250 apps/portal/src/components/global/ProductNavigation.tsx apps/portal/src/components/global/MobileNavigation.tsx apps/portal/src/components/global/GlobalNavigation.ts
AppShell 根据当前路由路径确定显示哪个产品导航,加载简历、优惠、问题或主页的相应导航项。对于优惠部分已登录用户,它还会检查用户是否具有管理员权限,并显示管理员特定的导航项。
ProductNavigation 组件在标题中渲染特定于产品的导航项。它同时处理简单的导航链接和带有子项的导航项的下拉菜单。
主要功能
来源:apps/portal/src/components/global/ProductNavigation.tsx25-117 apps/portal/src/components/global/MobileNavigation.tsx apps/portal/src/components/global/GlobalNavigation.ts
MobileNavigation 组件为移动设备提供响应式导航抽屉。它包含全局导航项和特定于产品的导航项。
来源:apps/portal/src/components/global/MobileNavigation.tsx20-136
每个产品区域(简历、优惠、问题)都定义了自己的导航配置对象,该对象指定:
例如,优惠导航配置
来源:apps/portal/src/components/offers/OffersNavigation.tsx1-48 apps/portal/src/components/global/HomeNavigation.ts
门户应用程序包含多个可重用的类型ahead 组件,用于选择公司、国家、城市和职位名称等实体。这些组件遵循一致的实现模式,并在简历、优惠和问题系统中使用。
来源:apps/portal/src/components/shared/CompaniesTypeahead.tsx apps/portal/src/components/shared/CountriesTypeahead.tsx apps/portal/src/components/shared/CitiesTypeahead.tsx apps/portal/src/components/shared/JobTitlesTypeahead.tsx
CompaniesTypeahead 组件允许用户搜索和选择公司。它利用 useCompanyOptions hook 来根据用户输入获取公司数据。
主要功能
使用示例
来源:apps/portal/src/components/shared/CompaniesTypeahead.tsx24-46 apps/portal/src/pages/test__.tsx42-45
CountriesTypeahead 组件允许用户搜索和选择国家。它使用 useCountryOptions hook 来获取国家数据。
主要功能
使用示例
来源:apps/portal/src/components/shared/CountriesTypeahead.tsx26-51 apps/portal/src/pages/test__.tsx52-55
CitiesTypeahead 组件允许用户搜索和选择城市。它使用 useCityOptions 函数,该函数利用 tRPC API 来获取城市数据。
主要功能
使用示例
来源:apps/portal/src/components/shared/CitiesTypeahead.tsx44-68 apps/portal/src/pages/test__.tsx57-58
JobTitlesTypeahead 组件允许用户从预定义列表中搜索和选择职位名称。它使用 useJobTitleOptions hook 根据用户输入过滤职位名称。
主要功能
使用示例
该组件也用于特定场景,例如问题系统中的 RoleTypeahead 和优惠系统中的 FormJobTitlesTypeahead。
来源: apps/portal/src/components/shared/JobTitlesTypeahead.tsx27-53 apps/portal/src/components/shared/JobTitles.ts9-82 apps/portal/src/pages/test__.tsx47-50 apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx apps/portal/src/components/offers/forms/FormJobTitlesTypeahead.tsx
除了通用的 Typeahead 组件外,在“问题”和“职位”系统中还有针对特定用例的专用版本
来源: apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx apps/portal/src/components/questions/typeahead/LocationTypeahead.tsx apps/portal/src/components/questions/typeahead/CompanyTypeahead.tsx
来源: apps/portal/src/components/offers/forms/FormJobTitlesTypeahead.tsx
GoogleAnalytics 组件为门户应用程序提供了 Google Analytics 集成。它
用途
该组件配置为仅在生产模式下发送分析数据,而在开发环境中不发送。
来源: apps/portal/src/components/global/GoogleAnalytics.tsx59-99 apps/portal/src/components/global/AppShell.tsx170
在“简历”、“职位”或“问题”系统内构建新功能时,请利用这些共享组件来保持一致性
此代码库中的共享组件遵循一致的模式
Typeahead 组件:
导航组件:
遵循这些模式可确保整个应用程序的一致性,并使其更易于维护和扩展代码库。