UNPKG

@zeplin/extension-model

Version:

Models exposed to Zeplin extensions

130 lines (129 loc) 4.86 kB
import { Component } from "../component.js"; import { Color } from "../color.js"; import { TextStyle } from "../textStyle.js"; import { SpacingToken } from "../spacingToken.js"; import { SpacingSection } from "../spacingSection.js"; import { VariableCollection } from "../variableCollection.js"; import { Variable } from "../variable.js"; import { Styleguide } from "../styleguide.js"; export interface RemPreferences { useForFontSizes: boolean; useForMeasurements: boolean; rootFontSize: number; } export interface ComponentSection { variant: any; components?: Component[]; componentSections?: ComponentSection[]; } export interface DimensionSuffixes { textDimensionSuffix: string; dimensionSuffix: string; } export declare abstract class Barrel { colors: Color[]; textStyles: TextStyle[]; spacingSections: SpacingSection[]; components: Component[]; variableCollections: VariableCollection[]; density: string; densityDivisor: number; remPreferences?: RemPreferences; linkedStyleguide?: Styleguide; parent?: Styleguide; /** * Find resource in barrel */ findResource<T>(searchFn: (b: Barrel) => T | undefined, useLinkedStyleguides: boolean): T | undefined; /** * Find text style by name */ findTextStyleByName(name: string, useLinkedStyleguides: boolean): TextStyle | undefined; /** * Find text style equal to the given text style */ findTextStyleEqual(textStyle: TextStyle, useLinkedStyleguides: boolean): TextStyle | undefined; /** * Find best conforming text style */ findBestConformingTextStyle(textStyle: TextStyle, useLinkedStyleguides: boolean): TextStyle | undefined; /** * Find color by name */ findColorByName(name: string, useLinkedStyleguides: boolean): Color | undefined; /** * Find color by source ID */ findColorBySourceId(sourceId: string, useLinkedStyleguides: boolean): Color | undefined; /** * Find color by variable color */ findColorByVariableColor(variableColor: Color, useLinkedStyleguides: boolean, useLinkedVariableSourceId: boolean): Color | undefined; /** * Find linked color variable equal to the given color */ findLinkedColorVariableEqual(color: Color, useLinkedStyleguides: boolean): Color | undefined; /** * Find color equal to the given color */ findColorEqual(color: Color, useLinkedStyleguides: boolean): Color | undefined; /** * Find color by hex and alpha */ findColorByHexAndAlpha(values: { hex?: string; alpha?: number; }, useLinkedStyleguides: boolean): Color | undefined; /** * Find spacing token by name */ findSpacingTokenByName(name: string, useLinkedStyleguides: boolean): SpacingToken | undefined; /** * Find spacing token by value */ findSpacingTokenByValue(value: number, useLinkedStyleguides: boolean): SpacingToken | undefined; /** * Find component by name */ findComponentByName(name: string, useLinkedStyleguides: boolean): Component | undefined; /** * Find component by source ID */ findComponentBySourceId(sourceId: string, useLinkedStyleguides: boolean): Component | undefined; /** * Sort function for text styles */ protected static fontSort(prev: TextStyle, cur: TextStyle): number; /** * Get dimension suffix based on density and project type */ protected static getDimensionSuffix(density: string, projectType: string): DimensionSuffixes; /** * Get density divisor based on density */ protected static getDensityDivisor(density: string): number; /** * Set scaled font size for text styles */ protected static setScaledFontSize(textStyles: TextStyle[], densityDivisor: number): void; /** * Get variable color */ protected static getVariableColor(variable: Variable | undefined, variableName: string, variableSourceId: string, variableBySourceId: Record<string, Variable>, projectType: string): Color | undefined; /** * Convert variable collections to colors */ protected static variableCollectionsToColors(variableCollections: VariableCollection[] | undefined, projectType: string): Color[] | undefined; /** * Convert component section to components */ protected static componentSectionToComponents(componentSection: ComponentSection): Component[]; /** * Convert component sections to components */ protected static componentSectionsToComponents(componentSections: ComponentSection[] | undefined): Component[]; /** * Find spacing token by field sections */ protected static findSpacingTokenByFieldSections(spacingSections: SpacingSection[], fieldName: string, value: any): SpacingToken | undefined; }