gristlabs_grist-core/app/client/models/Styles.ts
Jarosław Sadziński 34708cd348 (core) Adding font options to the style picker
Summary:
Redesigning color picker:
- Single color palette (no light/dark switch)
- Ability to remove color (new empty button)

New font options in the color picker.
Font options are available on:
- Default cell style
- Conditional rules styles
- Choice/ChoiceList editor and token field
- Filters for Choice/ChoiceList columns

Design document:
https://www.figma.com/file/bRTsb47VIOVBfJPj0qF3C9/Grist-Updates?node-id=415%3A8135

Test Plan: new and updated tests

Reviewers: georgegevoian, alexmojaki

Reviewed By: georgegevoian, alexmojaki

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3335
2022-04-07 20:35:03 +02:00

36 lines
1.3 KiB
TypeScript

export interface Style {
textColor?: string;
fillColor?: string;
fontBold?: boolean;
fontUnderline?: boolean;
fontItalic?: boolean;
fontStrikethrough?: boolean;
}
export class CombinedStyle implements Style {
public readonly textColor?: string;
public readonly fillColor?: string;
public readonly fontBold?: boolean;
public readonly fontUnderline?: boolean;
public readonly fontItalic?: boolean;
public readonly fontStrikethrough?: boolean;
constructor(rules: (Style|undefined|null)[], flags: any[]) {
for (let i = 0; i < rules.length; i++) {
if (flags[i]) {
const textColor = rules[i]?.textColor;
const fillColor = rules[i]?.fillColor;
const fontBold = rules[i]?.fontBold;
const fontUnderline = rules[i]?.fontUnderline;
const fontItalic = rules[i]?.fontItalic;
const fontStrikethrough = rules[i]?.fontStrikethrough;
this.textColor = textColor || this.textColor;
this.fillColor = fillColor || this.fillColor;
this.fontBold = fontBold || this.fontBold;
this.fontUnderline = fontUnderline || this.fontUnderline;
this.fontItalic = fontItalic || this.fontItalic;
this.fontStrikethrough = fontStrikethrough || this.fontStrikethrough;
}
}
}
}