Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: FixedNav 的图标支持 React.ReactNode 类型 #1783

Closed
whinc opened this issue Dec 12, 2023 · 0 comments
Closed

[FR]: FixedNav 的图标支持 React.ReactNode 类型 #1783

whinc opened this issue Dec 12, 2023 · 0 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@whinc
Copy link

whinc commented Dec 12, 2023

这个功能解决了什么问题?

FixedNav 目前只能接收 string 类型的图片链接,无法复用已有的 Icon 组件,也无法自由定制 icon 的显示,增加该特性后可以增加其灵活性和适用面

https://github.com/jdf2e/nutui-react/blob/next/src/packages/fixednav/fixednav.taro.tsx#L111

你期望的组件设计是怎样的?

import React, { useState } from "react";
import { FixedNav } from '@nutui/nutui-react-taro';
import { Home } from "@nutui/icons-react-taro";

const App = () => {
  const list = [
    {
      id: 1,
      text: '首页',
     // 这是当前行为,只能传入有效的图片链接
      icon: 'https://img14.360buyimg.com/imagetools/jfs/t1/130725/4/3157/1704/5ef83e95Eb976644f/b36c6cfc1cc1a99d.png'
    },
    {
      id: 2,
      text: '分类',
     // 期望这里支持 React.ReactNode,例如 Icon 组件
      icon: <Home/>
    },
    {
      id: 3,
      text: '购物车',
      num: 2,
      // 期望这里支持 React.ReactNode,例如自定义组件
      icon: <div style={{width: 20, height: 20, borderRadius: 10, background: 'red'}} />
    },
  ];
  const [visible, setVisible] = useState(false);
  const change = (value: boolean) => {
    setVisible(value);
  };
  const selected = (item: any, event: MouseEvent) => {
    console.log(item, event);
  };
  return (
    <>
      <FixedNav
        list={list}
        activeText="基础用法"
        overlay
        position={{ top: '70px' }}
        onChange={change}
        visible={visible}
        onSelect={selected}
       />
    </>
  )
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants