Skip to content

Commit

Permalink
feat!: Tab should left aligned by default
Browse files Browse the repository at this point in the history
  • Loading branch information
honghui-qiao committed Feb 6, 2025
1 parent 5b307ad commit 37eb9b2
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 244 deletions.
5 changes: 0 additions & 5 deletions packages/bui-core/src/Tabs/Tab.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
--bui-tabs-color: var(--bui-color-fg-default);
}

&-center {
flex: 1 0 0;
margin: 0 auto;
}

&-miniapp-active {
line-height: 1.5;
font-weight: var(--bui-font-weight-medium);
Expand Down
3 changes: 1 addition & 2 deletions packages/bui-core/src/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ const Tab = React.forwardRef<HTMLDivElement, TabProps>((props, ref) => {
...props,
};
const tabsContext = React.useContext(TabsContext);
const { value, align, triggerChange } = tabsContext;
const { value, triggerChange } = tabsContext;

return (
<div
ref={ref}
className={clsx(
prefixCls,
align !== 'start' && `${prefixCls}-${align}`,
{
[`${prefixCls}-active`]: !isMini && index === value,
[`${prefixCls}-miniapp-active`]: isMini && index === value,
Expand Down
7 changes: 3 additions & 4 deletions packages/bui-core/src/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import './Tabs.less';

const prefixCls = 'bui-tabs';
const defaultProps = {
align: 'center',
tabs: [],
} satisfies Partial<TabsProps>;

const Tabs = React.forwardRef<HTMLDivElement, TabsProps>((props, ref) => {
const { children, className, value, tabs, align, onChange, ...others } = {
const { children, className, value, tabs, onChange, ...others } = {
...defaultProps,
...props,
};
Expand Down Expand Up @@ -172,8 +171,8 @@ const Tabs = React.forwardRef<HTMLDivElement, TabsProps>((props, ref) => {
};

const providerValue = useMemo(() => {
return { value, align, triggerChange: handleClick };
}, [value, align, children, handleClick]);
return { value, triggerChange: handleClick };
}, [value, children, handleClick]);

return (
<div ref={ref} className={clsx(prefixCls, className)} {...others}>
Expand Down
4 changes: 0 additions & 4 deletions packages/bui-core/src/Tabs/Tabs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export type TabsProps<
* 切换面板的数据
*/
tabs?: ITabItem[];
/**
* 对齐方式,默认为center
*/
align?: ITabAlign;
/**
* 切换面板的回调
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ exports[`Tabs test with TabPanel should be actived by \`value\` property 1`] = `
style="transform: translate3d(0px, 0px, 0px); transition: transform 0.3s ease-in-out;"
/>
<div
class="bui-tab bui-tab-center"
class="bui-tab"
>
水果
</div>
<div
class="bui-tab bui-tab-center bui-tab-active"
class="bui-tab bui-tab-active"
>
蔬菜
</div>
<div
class="bui-tab bui-tab-center"
class="bui-tab"
>
动物
</div>
Expand Down
Loading

0 comments on commit 37eb9b2

Please sign in to comment.