Giter Site home page Giter Site logo

tab-group's People

Contributors

liujinxing avatar superstaring avatar tianyanqiu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

tab-group's Issues

bug: 在 TabContent 中使用 position: fixed,没有达到预期效果

现象:

在 TabGroup 中使用 react-beautiful-dnd ,发现拖拽时拖拽元素不见或者错位了。

原因:

TabContent 使用 transform: translate3d() 切换内容页的。transform 会创建新的层叠上下文,这样 position:fxied 就会相对于 TabContent 定位,而不是相对于视口定位。

参考: https://developer.mozilla.org/zh-CN/docs/Web/CSS/position

从 MDN 上摘选的:

position: fixed

不为元素预留空间,而是通过指定元素相对于屏幕视口(viewport)的位置来指定元素位置。元素的位置在屏幕滚动时不会改变。打印时,元素会出现在的每页的固定位置。fixed 属性会创建新的层叠上下文。当元素祖先的 transform 属性非 none 时,容器由视口改为该祖先。

feat: 定制标签条颜色

TabGroupTabHeader 组件新增 textColorinkBarColor 两个属性,分别设置标签文本颜色和指示条颜色。

textColor 属性选项:

  • primary (默认)
  • secondary
  • inherit (从父DOM中继承颜色)
  • 其他颜色设定(如 success、warning 等)

inkBarColor 属性选项:

  • primary (默认)
  • secondary
  • 其他颜色设定(如 success、warning 等)

有了这两个颜色属性,就可以将 TabHeader 用于类似 AppBar 中。在文档中需要有这个场景的示例。

feat: 页签切换按钮

提供 useTabState,从 Tab 组件的上下文中获取标签状态。

示例:

import { useTabState } from '@sinouiincubator/tab-group';

function PrevTabButton() {
  const { isFirst, prev } = useTabState();

  return isFirst ? null : <Button onClick={prev}>上一页</Button>;
}

function NextTabButton() {
  const { isLast, next } = useTabState();

  return isLast ? null : <Button onClick={next}>下一页</Button>;
}

function Demo() {
  return (
    <TabGroup>
      <Tab title="标签1">
        标签内容1
        <PrevTabButton />
        <NextTabButton />
      </Tab>
      <Tab title="标签2">
        标签内容2
        <PrevTabButton />
        <NextTabButton />
      </Tab>
      <Tab title="标签3">
        标签内容3
        <PrevTabButton />
        <NextTabButton />
      </Tab>
      <Tab title="标签4">
        标签内容4
        <PrevTabButton />
        <NextTabButton />
      </Tab>
    </TabGroup>
  );
}

feat: TabGroup 可以直接与 TabHeader、 TabContent 组合使用

方案一:

<TabGroup simple>
  <TabHeader>
     <TabHeaderItem title="标签1" />
     <TabHeaderItem title="标签2" />
  </TabHeader>
   <TabContent>
     <TabPanel>内容1</TabPanel>
     <TabPanel>内容2</TabPanel>
   </TabContent>
</TabGroup>

方案二:

<Tabs>
  <TabHeader>
     <TabHeaderItem title="标签1" />
     <TabHeaderItem title="标签2" />
  </TabHeader>
   <TabContent>
     <TabPanel>内容1</TabPanel>
     <TabPanel>内容2</TabPanel>
   </TabContent>
</Tabs>

之所以要有这样的处理,是因为这样更容易实现 TabHeader 与其他组件的组合使用,如AppBar

<Tabs>
  <AppBar>
    <TabHeader>
       <TabHeaderItem title="标签1" />
       <TabHeaderItem title="标签2" />
    </TabHeader>
  </AppBar>
  <TabContent>
     <TabPanel>内容1</TabPanel>
     <TabPanel>内容2</TabPanel>
  </TabContent>
</Tabs>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.