Skip to content

Commit 3b01ac7

Browse files
banobepascaleszkadev
authored andcommitted
Table Design: add custom table style SVG icons
- Custom table styles (those not matching Light/Medium/Dark naming) were using the light style SVG as a fallback. - Add a dedicated customTableStyleSvg generator that renders the style's actual element colors directly. Signed-off-by: Banobe Pascal <banobe.pascal@collabora.com> Change-Id: I86825e86088db3d2ec2345f6b65afe3e675e6ce4
1 parent 2cae3b4 commit 3b01ac7

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

browser/src/app/TableStylesService.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,13 @@ class TableStylesService {
325325
const headerRow = getElementColor(style, 'HeaderRow') || wholeTable;
326326
const firstRowStripe =
327327
getElementColor(style, 'FirstRowStripe') || wholeTable;
328+
const secondRowStripe =
329+
getElementColor(style, 'SecondRowStripe') || wholeTable;
328330

329331
const wt = '#' + wholeTable;
330332
const hr = '#' + headerRow;
331333
const frs = '#' + firstRowStripe;
334+
const srs = '#' + secondRowStripe;
332335

333336
const getStyleIndex = (variant: string) => {
334337
const match = style.Name.match(new RegExp(`${variant}(\\d+)$`));
@@ -358,11 +361,7 @@ class TableStylesService {
358361
: darkenColor(wt, 0.35);
359362
svg = darkTableStyleSvg(hr, wt, gridColor, darkStyleIndex);
360363
} else {
361-
svg = lightTableStyleSvg(
362-
wt,
363-
lightenColor(wt, 0.5),
364-
getStyleIndex('Light'),
365-
);
364+
svg = customTableStyleSvg(hr, frs, srs);
366365
}
367366

368367
return 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svg);

browser/src/control/jsdialog/Util.GenerateTableIcon.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,3 +647,55 @@ function darkTableStyleSvg(
647647
648648
</svg>`;
649649
}
650+
651+
function customTableStyleSvg(
652+
headerColor: string,
653+
firstRowStripe: string,
654+
secondRowStripe: string,
655+
): string {
656+
const lineColor = getBodyContrastStroke(firstRowStripe, secondRowStripe);
657+
658+
return `<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
659+
660+
<!-- Header -->
661+
<rect x="1.5" y="3" width="29" height="5.5" fill="${headerColor}"/>
662+
<line x1="25.5" y1="5.8" x2="29.7" y2="5.8" stroke="${getContrastStroke(headerColor)}" stroke-width="0.5"/>
663+
<line x1="19.7" y1="5.8" x2="23.9" y2="5.8" stroke="${getContrastStroke(headerColor)}" stroke-width="0.5"/>
664+
<line x1="13.9" y1="5.8" x2="18.1" y2="5.8" stroke="${getContrastStroke(headerColor)}" stroke-width="0.5"/>
665+
<line x1="8.1" y1="5.8" x2="12.3" y2="5.8" stroke="${getContrastStroke(headerColor)}" stroke-width="0.5"/>
666+
<line x1="2.3" y1="5.8" x2="6.5" y2="5.8" stroke="${getContrastStroke(headerColor)}" stroke-width="0.5"/>
667+
668+
<!-- Row 1 -->
669+
<rect x="1.5" y="8.7" width="29" height="5" fill="${firstRowStripe}"/>
670+
<line x1="25.5" y1="11.1" x2="29.7" y2="11.1" stroke="${lineColor}" stroke-width="0.5"/>
671+
<line x1="19.7" y1="11.1" x2="23.9" y2="11.1" stroke="${lineColor}" stroke-width="0.5"/>
672+
<line x1="13.9" y1="11.1" x2="18.1" y2="11.1" stroke="${lineColor}" stroke-width="0.5"/>
673+
<line x1="8.1" y1="11.1" x2="12.3" y2="11.1" stroke="${lineColor}" stroke-width="0.5"/>
674+
<line x1="2.3" y1="11.1" x2="6.5" y2="11.1" stroke="${lineColor}" stroke-width="0.5"/>
675+
676+
<!-- Row 2 -->
677+
<rect x="1.5" y="13.5" width="29" height="5" fill="${secondRowStripe}"/>
678+
<line x1="25.5" y1="15.9" x2="29.7" y2="15.9" stroke="${lineColor}" stroke-width="0.5"/>
679+
<line x1="19.7" y1="15.9" x2="23.9" y2="15.9" stroke="${lineColor}" stroke-width="0.5"/>
680+
<line x1="13.9" y1="15.9" x2="18.1" y2="15.9" stroke="${lineColor}" stroke-width="0.5"/>
681+
<line x1="8.1" y1="15.9" x2="12.3" y2="15.9" stroke="${lineColor}" stroke-width="0.5"/>
682+
<line x1="2.3" y1="15.9" x2="6.5" y2="15.9" stroke="${lineColor}" stroke-width="0.5"/>
683+
684+
<!-- Row 3 -->
685+
<rect x="1.5" y="18.4" width="29" height="5" fill="${firstRowStripe}"/>
686+
<line x1="25.5" y1="20.8" x2="29.7" y2="20.8" stroke="${lineColor}" stroke-width="0.5"/>
687+
<line x1="19.7" y1="20.8" x2="23.9" y2="20.8" stroke="${lineColor}" stroke-width="0.5"/>
688+
<line x1="13.9" y1="20.8" x2="18.1" y2="20.8" stroke="${lineColor}" stroke-width="0.5"/>
689+
<line x1="8.1" y1="20.8" x2="12.3" y2="20.8" stroke="${lineColor}" stroke-width="0.5"/>
690+
<line x1="2.3" y1="20.8" x2="6.5" y2="20.8" stroke="${lineColor}" stroke-width="0.5"/>
691+
692+
<!-- Row 4 -->
693+
<rect x="1.5" y="23.3" width="29" height="5" fill="${secondRowStripe}"/>
694+
<line x1="25.5" y1="25.8" x2="29.7" y2="25.8" stroke="${lineColor}" stroke-width="0.5"/>
695+
<line x1="19.7" y1="25.8" x2="23.9" y2="25.8" stroke="${lineColor}" stroke-width="0.5"/>
696+
<line x1="13.9" y1="25.8" x2="18.1" y2="25.8" stroke="${lineColor}" stroke-width="0.5"/>
697+
<line x1="8.1" y1="25.8" x2="12.3" y2="25.8" stroke="${lineColor}" stroke-width="0.5"/>
698+
<line x1="2.3" y1="25.8" x2="6.5" y2="25.8" stroke="${lineColor}" stroke-width="0.5"/>
699+
700+
</svg>`;
701+
}

0 commit comments

Comments
 (0)