Skip to content

Commit 78ec628

Browse files
banobepascaleszkadev
authored andcommitted
Table Design: improve table style icon rendering
- Shorten cell content lines and center them within columns. - Use explicit white/black line colors for dark style icons instead of contrast-based computation. Signed-off-by: Banobe Pascal <banobe.pascal@collabora.com> Change-Id: I10acadfd16c51aa735602283d41b9ba66232327a
1 parent 3b01ac7 commit 78ec628

File tree

2 files changed

+262
-281
lines changed

2 files changed

+262
-281
lines changed

browser/src/app/TableStylesService.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ function toHex(r: number, g: number, b: number): string {
7272
);
7373
}
7474

75-
function lightenColor(hex: string, factor: number): string {
76-
const [r, g, b] = parseHexToRgb(hex);
77-
return toHex(
78-
r + (255 - r) * factor,
79-
g + (255 - g) * factor,
80-
b + (255 - b) * factor,
81-
);
82-
}
83-
8475
function darkenColor(hex: string, factor: number): string {
8576
const [r, g, b] = parseHexToRgb(hex);
8677
return toHex(r * (1 - factor), g * (1 - factor), b * (1 - factor));
@@ -321,7 +312,7 @@ class TableStylesService {
321312
}
322313

323314
public generateIcon(style: TableStyleEntry): string {
324-
const wholeTable = getElementColor(style, 'WholeTable') || '000000';
315+
const wholeTable = getElementColor(style, 'WholeTable') || 'FFFF';
325316
const headerRow = getElementColor(style, 'HeaderRow') || wholeTable;
326317
const firstRowStripe =
327318
getElementColor(style, 'FirstRowStripe') || wholeTable;
@@ -341,25 +332,11 @@ class TableStylesService {
341332
let svg: string;
342333

343334
if (style.Name.indexOf('Light') >= 0) {
344-
svg = lightTableStyleSvg(
345-
hr,
346-
lightenColor(frs, 0.5),
347-
getStyleIndex('Light'),
348-
);
335+
svg = lightTableStyleSvg(hr, wt, frs, getStyleIndex('Light'));
349336
} else if (style.Name.indexOf('Medium') >= 0) {
350-
svg = mediumTableStyleSvg(
351-
hr,
352-
frs,
353-
lightenColor(frs, 0.55),
354-
getStyleIndex('Medium'),
355-
);
337+
svg = mediumTableStyleSvg(hr, wt, frs, getStyleIndex('Medium'));
356338
} else if (style.Name.indexOf('Dark') >= 0) {
357-
const darkStyleIndex = getStyleIndex('Dark');
358-
const gridColor =
359-
darkStyleIndex >= 8 && darkStyleIndex <= 11
360-
? strengthenColor(wt, 0.75)
361-
: darkenColor(wt, 0.35);
362-
svg = darkTableStyleSvg(hr, wt, gridColor, darkStyleIndex);
339+
svg = darkTableStyleSvg(hr, wt, frs, getStyleIndex('Dark'));
363340
} else {
364341
svg = customTableStyleSvg(hr, frs, srs);
365342
}

0 commit comments

Comments
 (0)