Skip to content

Commit 6e3ed85

Browse files
committed
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 06efa6a commit 6e3ed85

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));
@@ -309,7 +300,7 @@ class TableStylesService {
309300
}
310301

311302
public generateIcon(style: TableStyleEntry): string {
312-
const wholeTable = getElementColor(style, 'WholeTable') || '000000';
303+
const wholeTable = getElementColor(style, 'WholeTable') || 'FFFF';
313304
const headerRow = getElementColor(style, 'HeaderRow') || wholeTable;
314305
const firstRowStripe =
315306
getElementColor(style, 'FirstRowStripe') || wholeTable;
@@ -329,25 +320,11 @@ class TableStylesService {
329320
let svg: string;
330321

331322
if (style.Name.indexOf('Light') >= 0) {
332-
svg = lightTableStyleSvg(
333-
hr,
334-
lightenColor(frs, 0.5),
335-
getStyleIndex('Light'),
336-
);
323+
svg = lightTableStyleSvg(hr, wt, frs, getStyleIndex('Light'));
337324
} else if (style.Name.indexOf('Medium') >= 0) {
338-
svg = mediumTableStyleSvg(
339-
hr,
340-
frs,
341-
lightenColor(frs, 0.55),
342-
getStyleIndex('Medium'),
343-
);
325+
svg = mediumTableStyleSvg(hr, wt, frs, getStyleIndex('Medium'));
344326
} else if (style.Name.indexOf('Dark') >= 0) {
345-
const darkStyleIndex = getStyleIndex('Dark');
346-
const gridColor =
347-
darkStyleIndex >= 8 && darkStyleIndex <= 11
348-
? strengthenColor(wt, 0.75)
349-
: darkenColor(wt, 0.35);
350-
svg = darkTableStyleSvg(hr, wt, gridColor, darkStyleIndex);
327+
svg = darkTableStyleSvg(hr, wt, frs, getStyleIndex('Dark'));
351328
} else {
352329
svg = customTableStyleSvg(hr, frs, srs);
353330
}

0 commit comments

Comments
 (0)