Skip to content

Commit

Permalink
fix: disable cellInnerBorder when no frame border
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Oct 22, 2024
1 parent 691f646 commit 4ceedb2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: disable cellInnerBorder when no frame border ",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import type { IThemeSpec } from '@visactor/vrender-core';
import type { BaseTableAPI } from '../../ts-types/base-table';
import { style as utilStyle } from '../../tools/helper';
import { isValid } from '@visactor/vutils';
import { isValidStyle, isZeroStyle } from '../../tools/style';

export function getCellBorderStrokeWidth(col: number, row: number, cellTheme: IThemeSpec, table: BaseTableAPI) {
// const frameBorderLineWidths = utilStyle.toBoxArray(table.internalProps.theme.frameStyle?.borderLineWidth ?? [null]);
let strokeArrayWidth = (cellTheme?.group as any)?.strokeArrayWidth ?? undefined;
if (table.theme.cellInnerBorder) {
if (
table.theme.cellInnerBorder ||
!isValidStyle(table.theme.frameStyle.borderLineWidth) ||
isZeroStyle(table.theme.frameStyle.borderLineWidth)
) {
return strokeArrayWidth;
}
if (col === 0) {
Expand Down
16 changes: 16 additions & 0 deletions packages/vtable/src/tools/style.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isArray, isValid } from '@visactor/vutils';
import type { ScrollStyle } from '../ts-types';

export function getHorizontalScrollBarSize(scrollStyle?: ScrollStyle): number {
Expand All @@ -21,3 +22,18 @@ export function getVerticalScrollBarSize(scrollStyle?: ScrollStyle): number {
}
return scrollStyle?.width ?? 7;
}

export function isValidStyle(style: (string | number) | (string | number)[]) {
if (!isValid(style)) {
return false;
}
if (isArray(style)) {
return style.some(s => isValid(s));
}

return true;
}

export function isZeroStyle(style: number | number[]) {
return style === 0 || (isArray(style) && style.every(s => s === 0));
}

0 comments on commit 4ceedb2

Please sign in to comment.