Skip to content

Commit

Permalink
✨ feat: remove tag border in select and tree-select (ant-design#41480)
Browse files Browse the repository at this point in the history
* ✨ feat: new tag

* update demo

* update snap

* fix

* fix

* fix

* fix

* fix

* fix

* fix style

* update snap

* revert

* fix

* fix

* fix

* fix

* fix

* Update components/select/style/multiple.tsx

Co-authored-by: MadCcc <[email protected]>

---------

Co-authored-by: MadCcc <[email protected]>
  • Loading branch information
2 people authored and RedJue committed Apr 25, 2023
1 parent 94aec25 commit 12ad0d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions components/select/style/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { CSSObject } from '@ant-design/cssinjs';
import { resetComponent, resetIcon, textEllipsis } from '../../style';
import { genCompactItemStyle } from '../../style/compact-item';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
import genDropdownStyle from './dropdown';
import genMultipleStyle from './multiple';
import genSingleStyle from './single';
import { resetComponent, resetIcon, textEllipsis } from '../../style';
import { genCompactItemStyle } from '../../style/compact-item';

export interface ComponentToken {
zIndexPopup: number;
Expand Down
40 changes: 19 additions & 21 deletions components/select/style/multiple.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
import type { SelectToken } from '.';
import { mergeToken } from '../../theme/internal';
import { resetIcon } from '../../style';
import { mergeToken } from '../../theme/internal';

const FIXED_ITEM_MARGIN = 2;

function getSelectItemStyle({
const getSelectItemStyle = ({
controlHeightSM,
controlHeight,
lineWidth: borderWidth,
}: SelectToken) {
}: SelectToken): readonly [number, number] => {
const selectItemDist = (controlHeight - controlHeightSM) / 2 - borderWidth;
const selectItemMargin = Math.ceil(selectItemDist / 2);
return [selectItemDist, selectItemMargin];
}
return [selectItemDist, selectItemMargin] as const;
};

function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
const { componentCls, iconCls } = token;
Expand Down Expand Up @@ -95,7 +95,6 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
marginBottom: FIXED_ITEM_MARGIN,
lineHeight: `${selectItemHeight - token.lineWidth * 2}px`,
background: token.colorFillSecondary,
border: `${token.lineWidth}px solid ${token.colorSplit}`,
borderRadius: token.borderRadiusSM,
cursor: 'default',
transition: `font-size ${token.motionDurationSlow}, line-height ${token.motionDurationSlow}, height ${token.motionDurationSlow}`,
Expand All @@ -106,7 +105,6 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {

[`${componentCls}-disabled&`]: {
color: token.colorTextDisabled,
borderColor: token.colorBorder,
cursor: 'not-allowed',
},

Expand Down Expand Up @@ -191,7 +189,7 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
};
}

export default function genMultipleStyle(token: SelectToken): CSSInterpolation {
const genMultipleStyle = (token: SelectToken): CSSInterpolation => {
const { componentCls } = token;

const smallToken = mergeToken<SelectToken>(token, {
Expand All @@ -200,12 +198,20 @@ export default function genMultipleStyle(token: SelectToken): CSSInterpolation {
borderRadius: token.borderRadiusSM,
borderRadiusSM: token.borderRadiusXS,
});

const largeToken = mergeToken<SelectToken>(token, {
fontSize: token.fontSizeLG,
controlHeight: token.controlHeightLG,
controlHeightSM: token.controlHeight,
borderRadius: token.borderRadiusLG,
borderRadiusSM: token.borderRadius,
});

const [, smSelectItemMargin] = getSelectItemStyle(token);

return [
genSizeStyle(token),
// ======================== Small ========================
// Shared
genSizeStyle(smallToken, 'sm'),

// Padding
Expand All @@ -223,16 +229,8 @@ export default function genMultipleStyle(token: SelectToken): CSSInterpolation {
},

// ======================== Large ========================
// Shared
genSizeStyle(
mergeToken<any>(token, {
fontSize: token.fontSizeLG,
controlHeight: token.controlHeightLG,
controlHeightSM: token.controlHeight,
borderRadius: token.borderRadiusLG,
borderRadiusSM: token.borderRadius,
}),
'lg',
),
genSizeStyle(largeToken, 'lg'),
];
}
};

export default genMultipleStyle;
2 changes: 1 addition & 1 deletion components/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const InternalTreeSelect = <
}
treeLine={!!treeLine}
inputIcon={suffixIcon}
multiple={multiple}
multiple={isMultiple}
placement={memoizedPlacement}
removeIcon={removeIcon}
clearIcon={clearIcon}
Expand Down
4 changes: 1 addition & 3 deletions components/tree-select/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ const genBaseStyle: GenerateStyle<TreeSelectToken> = (token) => {
// ============================== Export ==============================
export default function useTreeSelectStyle(prefixCls: string, treePrefixCls: string) {
return genComponentStyleHook('TreeSelect', (token) => {
const treeSelectToken = mergeToken<TreeSelectToken>(token, {
treePrefixCls,
});
const treeSelectToken = mergeToken<TreeSelectToken>(token, { treePrefixCls });
return [genBaseStyle(treeSelectToken)];
})(prefixCls);
}

0 comments on commit 12ad0d7

Please sign in to comment.