UNPKG

react-pdf-builder

Version:
56 lines (55 loc) 2.94 kB
import { PartialTheme, Theme } from './Theme'; import { ColorScheme, PartialColorScheme, SwatchColor } from './ColorScheme'; import { ClassNames } from './classnames/ClassNames'; import { Style } from '../components/Style'; export declare abstract class ThemeBuilder { colorScheme: ColorScheme; constructor(colorScheme: ColorScheme); /** * Builds the theme based on the scale and color scheme provided. */ abstract doBuild(scale: number, colorScheme: ColorScheme): Theme; /** * Creates the theme for the provided scale relative to the A4 page size (8.5 x 11", 595.28 by 841.89pt). * @param config Contains a scale multiplier for the theme, with a value of `1` being relative to a standard 8.5 x 11" A4 page, or 595.28 x 841.89pt, a value of `2` being relative to A2 at 1190.55 x 1683.78pt, etc. All scalable values for the theme (such as padding, margin, and font sizes) are multiplied by this value. Can also contain an override theme to customize the theme further. * @returns The scaled theme. */ build(config?: ThemeBuilderConfig): Theme; static overrideTheme(theme: PartialTheme, override?: PartialTheme): Theme; static overrideColorScheme(colorScheme: PartialColorScheme, overrides?: PartialColorScheme): ColorScheme; static getSwatchColor(swatch: SwatchColor, colorScheme?: ColorScheme): string | undefined; static getContrastColor(swatch: SwatchColor, colorScheme?: ColorScheme): string | undefined; /** * Mixes white with the color provided by the specified ratio amount (value from 0 to 1). * @param color The color to lighten. * @param ratio Ratio from 0 to 1. * @returns The lightened color as a hex string. */ static lighten(color: string, ratio: number): string; /** * Mixes black with the color provided by the specified ratio amount (value from 0 to 1). * @param color The color to darken. * @param ratio Ratio from 0 to 1. * @returns The darkened color as a hex string. */ static darken(color: string, ratio: number): string; /** * Converts a decimal from 0-255 to a two character long hexadecimal string. * @param decimal The value from 0 to 255. * @returns A two character long hex string. */ static decimalToHex(decimal: number): string; /** * Returns a Style object containing all styles for the class name string. Class name string can contain * one or more class names, separated by spaces. * * @param className The class name to get the Style object for. * @param classNames The style definitions for all available class names. * @returns A merged Style object containing styles for all classes in the class name string. */ static getStylesForClassName(className: string | undefined, classNames: ClassNames): Style; } export interface ThemeBuilderConfig { scale?: number; override?: PartialTheme; }