feat: update project structure and add new pages
- Changed the clone URL in README to point to the new webpack-taro-template. - Added 'mine' page to app configuration. - Enhanced index page styles and structure. - Created BottomNav component for navigation. - Added configuration and styles for the new 'mine' page. - Introduced navItems configuration for navigation. - Added AGENTS.md for project overview and development guidelines.
This commit is contained in:
42
src/components/BottomNav/index.tsx
Normal file
42
src/components/BottomNav/index.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { View, Text } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import type { NavItem, NavKey } from "../../config";
|
||||
import "./index.css";
|
||||
|
||||
const ACTIVE_COLOR = "#1976d2";
|
||||
const DEFAULT_COLOR = "#9e9e9e";
|
||||
const ICON_SIZE = 24;
|
||||
|
||||
interface BottomNavProps {
|
||||
active: NavKey;
|
||||
navItems: NavItem[];
|
||||
}
|
||||
|
||||
export default function BottomNav({ active, navItems }: BottomNavProps) {
|
||||
const handleNavigate = (item: NavItem) => {
|
||||
if (item.key === active) return;
|
||||
Taro.redirectTo({ url: item.path });
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="bottom-nav">
|
||||
{navItems.map((item) => {
|
||||
const isActive = active === item.key;
|
||||
const IconComp = item.icon;
|
||||
return (
|
||||
<View
|
||||
key={item.key}
|
||||
className={`bottom-nav-item${isActive ? " active" : ""}`}
|
||||
onClick={() => handleNavigate(item)}
|
||||
>
|
||||
<IconComp
|
||||
size={ICON_SIZE}
|
||||
color={isActive ? ACTIVE_COLOR : DEFAULT_COLOR}
|
||||
/>
|
||||
<Text className="bottom-nav-label">{item.label}</Text>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user