Skip to content

Commit 14fa979

Browse files
committed
Improve types
1 parent 23f3f35 commit 14fa979

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

packages/backend/src/common/color.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GradientPaint } from "../api_types";
12
import { numberToFixedString } from "./numToAutoFixed";
23

34
// ---- Color Format Conversion ----

packages/backend/src/tailwind/builderImpl/tailwindBlend.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Paint } from "../../api_types";
12
import { numberToFixedString } from "../../common/numToAutoFixed";
2-
import { exactValue, nearestOpacity, nearestValue } from "../conversionTables";
3+
import { exactValue, nearestOpacity } from "../conversionTables";
34

45
/**
56
* https://tailwindcss.com/docs/opacity/

packages/backend/src/tailwind/builderImpl/tailwindColor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
htmlAngularGradient,
1313
htmlRadialGradient,
1414
} from "../../html/builderImpl/htmlColor";
15-
import { Paint } from "../../api_types";
15+
import { GradientPaint, Paint } from "../../api_types";
1616

1717
/**
1818
* Get a tailwind color value object

packages/backend/src/tailwind/tailwindDefaultBuilder.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
getClassLabel,
3131
} from "../common/commonFormatAttributes";
3232
import { TailwindColorType, TailwindSettings } from "types";
33+
import { MinimalFillsTrait, Paint } from "../api_types";
3334

3435
const isNotEmpty = (s: string) => s !== "" && s !== null && s !== undefined;
3536
const dropEmptyStrings = (strings: string[]) => strings.filter(isNotEmpty);
@@ -92,7 +93,7 @@ export class TailwindDefaultBuilder {
9293
}
9394

9495
commonShapeStyles(): this {
95-
this.customColor((this.node as MinimalFillsMixin).fills, "bg");
96+
this.customColor((this.node as MinimalFillsTrait).fills, "bg");
9697
this.radius();
9798
this.shadow();
9899
this.border();
@@ -113,7 +114,10 @@ export class TailwindDefaultBuilder {
113114
if ("strokes" in this.node) {
114115
const { isOutline, property } = tailwindBorderWidth(this.node);
115116
this.addAttributes(property);
116-
this.customColor(this.node.strokes, isOutline ? "outline" : "border");
117+
this.customColor(
118+
this.node.strokes as MinimalStrokesTrait,
119+
isOutline ? "outline" : "border",
120+
);
117121
}
118122

119123
return this;
@@ -150,21 +154,16 @@ export class TailwindDefaultBuilder {
150154
* example: text-opacity-25
151155
* example: bg-blue-500
152156
*/
153-
customColor(
154-
paint: ReadonlyArray<Paint> | PluginAPI["mixed"],
155-
kind: TailwindColorType,
156-
): this {
157+
customColor(paint: ReadonlyArray<Paint>, kind: TailwindColorType): this {
157158
if (this.visible) {
158159
let gradient = "";
159160
if (kind === "bg") {
160161
gradient = tailwindGradientFromFills(paint);
161162

162163
// Add background blend mode class if applicable
163-
if (paint !== figma.mixed) {
164-
const blendModeClass = tailwindBackgroundBlendMode(paint);
165-
if (blendModeClass) {
166-
this.addAttributes(blendModeClass);
167-
}
164+
const blendModeClass = tailwindBackgroundBlendMode(paint);
165+
if (blendModeClass) {
166+
this.addAttributes(blendModeClass);
168167
}
169168
}
170169
if (gradient) {

0 commit comments

Comments
 (0)