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

feat(Tabs): 支持className 和 style 组件参数 #357

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React, { FC, useEffect, useRef, useState } from 'react';
import React, { FC, HTMLAttributes, useEffect, useRef, useState } from 'react';
import classnames from 'classnames';
import useConfig from '../_util/useConfig';
import { TdTabsProps } from './type';
import TabPanel from './TabPanel';
import TabContext from './context';

const Tabs: FC<TdTabsProps> = (props) => {
type TabsHTMLAttrs = Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'style'>;
export interface TabsProps extends TdTabsProps, TabsHTMLAttrs {}

const Tabs: FC<TabsProps> = (props) => {
const {
className = '',
style,
children,
content,
defaultValue = '',
Expand Down Expand Up @@ -104,11 +109,12 @@ const Tabs: FC<TdTabsProps> = (props) => {
return (
<div
className={classnames(
`${tabPrefix}-tabs`,
[`${tabPrefix}-tabs`, className],
size === 'large' && `${tabPrefix}-size-l`,
size === 'small' && `${tabPrefix}-size-s`,
placement && `${tabPrefix}-is-${placement}`,
)}
style={style}
>
<div ref={wrapRef} className={classnames(`${tabPrefix}-tabs__nav `, `${tabPrefix}-is-scrollable `)}>
<div className={classnames(`${tabPrefix}-tabs__nav-wrap`, `${tabPrefix}-tabs__nav-container`)}>
Expand Down
2 changes: 2 additions & 0 deletions src/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
list | Array | - | 选项卡列表 | N
animation | Object | - | 动画效果设置{transition-timing-function, transition-duration}。 | N
placement | String | top | 选项卡位置,可选值'left'\|'right'\|'top'\|'bottom' | N
Expand Down