@zeplin/extension-model
Version:
Models exposed to Zeplin extensions
199 lines (198 loc) • 8.2 kB
TypeScript
import { Color } from "./color.js";
import { TextStyle } from "./textStyle.js";
import { Styleguide } from "./styleguide.js";
import { SpacingSection } from "./spacingSection.js";
import { Barrel, RemPreferences } from "./utils/barrel.js";
import { VariableCollection } from "./variableCollection.js";
import { Component } from "./component.js";
import { SpacingToken } from "./spacingToken.js";
/**
* Enum for project types
*/
export declare enum ProjectType {
ANDROID = "android",
IOS = "ios",
MACOS = "osx",
WEB = "web"
}
/**
* Interface for project data
*/
export interface ProjectData {
type: ProjectType;
name: string;
textStyles: any[];
colors: any[];
density: string;
componentSections: any[];
spacingSections: any[];
styleguide?: any;
remPreferences?: RemPreferences;
variableCollections?: any[];
}
/**
* An interface to represent a Zeplin project.
*/
export declare class Project extends Barrel {
/**
* Type of the project, one of "web", "android", "ios", "macos"
*/
type: ProjectType;
/**
* Name of the project.
*/
name: string;
/**
* Text styles in the project's styleguide.
*/
textStyles: TextStyle[];
/**
* Colors in the project's styleguide.
*/
colors: Color[];
/**
* Pixel density used in project's designs.
*/
density: string;
/**
* This value is used to obtain actual length from the unit length for a density.
*/
densityDivisor: number;
/**
* The unit of length specific to the project's type. e.g., "px" for web projects.
*/
lengthUnit: string;
/**
* The unit of font sizes.
*/
textLengthUnit: string;
/**
* Components in the project's styleguide.
*/
components: Component[];
/**
* Linked styleguide of the project.
*/
linkedStyleguide?: Styleguide;
/**
* Spacing sections (with spacing tokens) defined in the project.
*/
spacingSections: SpacingSection[];
/**
* Preferences to specify rem usage in the project (web projects only).
*/
remPreferences?: RemPreferences;
/**
* Variable collections in the project's styleguide.
*/
variableCollections: VariableCollection[];
static get TYPE(): typeof ProjectType;
static get ALLOWED_FIELDS(): string[];
constructor(projectData: ProjectData);
/**
* Creates a Project instance from a JSON string
*
* @param json JSON string representing a project
* @returns A new Project instance
*/
static fromJSON(json: string): Project;
/**
* Finds any text style in the project or in the linked styleguides (if useLinkedStyleguides is true) whose name is equal to `name`
*
* @param name Name of the text style to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found text style or undefined if not found
*/
findTextStyleByName(name: string, useLinkedStyleguides?: boolean): TextStyle | undefined;
/**
* Finds any text style in the project or in the linked styleguides (if useLinkedStyleguides is true) which is equal to `textStyle`
*
* @param textStyle Text style to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found text style or undefined if not found
*/
findTextStyleEqual(textStyle: TextStyle, useLinkedStyleguides?: boolean): TextStyle | undefined;
/**
* Finds the best match for a text style in the project or in the linked styleguides (if useLinkedStyleguides is true)
*
* @param textStyle Text style to find a match for
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found text style or undefined if not found
*/
findBestConformingTextStyle(textStyle: TextStyle, useLinkedStyleguides?: boolean): TextStyle | undefined;
/**
* Finds any color in the project or in the linked styleguides (if useLinkedStyleguides is true) whose name is equal to `name`
*
* @param name Name of the color to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found color or undefined if not found
*/
findColorByName(name: string, useLinkedStyleguides?: boolean): Color | undefined;
/**
* Finds any color in the project or in the linked styleguides (if useLinkedStyleguides is true) whose sourceId equals to `sourceId`
*
* @param sourceId Source ID of the color to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found color or undefined if not found
*/
findColorBySourceId(sourceId: string, useLinkedStyleguides?: boolean): Color | undefined;
/**
* Finds any color in the project or in the linked styleguides (if useLinkedStyleguides is true) which is equal to `color`
*
* @param color Color to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found color or undefined if not found
*/
findColorEqual(color: Color, useLinkedStyleguides?: boolean): Color | undefined;
/**
* Finds any color variable in the project or in the linked styleguides (if useLinkedStyleguides is true) which is equal to `color`
*
* @param color Color to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found color or undefined if not found
*/
findLinkedColorVariableEqual(color: Color, useLinkedStyleguides?: boolean): Color | undefined;
/**
* Finds any color in the project or in the linked styleguides (if useLinkedStyleguides is true) whose hex and alpha values are equal to `values`
*
* @param values Object containing hex and alpha values
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found color or undefined if not found
*/
findColorByHexAndAlpha(values: {
hex?: string;
alpha?: number;
}, useLinkedStyleguides?: boolean): Color | undefined;
/**
* Finds any spacing token in the project or in the parent styleguides (if useLinkedStyleguides is true) whose value is equal to `value`
*
* @param value Value of the spacing token to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found spacing token or undefined if not found
*/
findSpacingTokenByValue(value: number, useLinkedStyleguides?: boolean): SpacingToken | undefined;
/**
* Finds any spacing token in the project or in the parent styleguides (if useLinkedStyleguides is true) whose name is equal to `name`
*
* @param name Name of the spacing token to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found spacing token or undefined if not found
*/
findSpacingTokenByName(name: string, useLinkedStyleguides?: boolean): SpacingToken | undefined;
/**
* Finds any component in the project or in the parent styleguides (if useLinkedStyleguides is true) whose name equals to `name`
*
* @param name Name of the component to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found component or undefined if not found
*/
findComponentByName(name: string, useLinkedStyleguides?: boolean): Component | undefined;
/**
* Finds any component in the project or in the parent styleguides (if useLinkedStyleguides is true) whose sourceId equals to `sourceId`
*
* @param sourceId Source ID of the component to find
* @param useLinkedStyleguides Whether to search in linked styleguides (defaults to true)
* @returns The found component or undefined if not found
*/
findComponentBySourceId(sourceId: string, useLinkedStyleguides?: boolean): Component | undefined;
}