-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* structure for fills * structure for fills in text and improvements * fixes * improvements
- Loading branch information
Showing
15 changed files
with
145 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export * from './transformBlend'; | ||
export * from './transformChildren'; | ||
export * from './transformDimensionAndPosition'; | ||
export * from './transformFills'; | ||
export * from './transformSceneNode'; | ||
export * from './transformStrokes'; | ||
export * from './transformTextStyle'; | ||
export * from './transformVectorPaths'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { translateFills } from '@plugin/translators'; | ||
|
||
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; | ||
|
||
export const transformFills = ( | ||
node: MinimalFillsMixin & DimensionAndPositionMixin | ||
): Partial<ShapeAttributes> => { | ||
return { | ||
fills: translateFills(node.fills, node.width, node.height) | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { translateTextDecoration, translateTextTransform } from '@plugin/translators'; | ||
|
||
import { TextStyle } from '@ui/lib/types/text/textContent'; | ||
|
||
export const transformTextStyle = ( | ||
node: Pick< | ||
StyledTextSegment, | ||
| 'characters' | ||
| 'start' | ||
| 'end' | ||
| 'fontName' | ||
| 'fontSize' | ||
| 'fontWeight' | ||
| 'lineHeight' | ||
| 'letterSpacing' | ||
| 'textCase' | ||
| 'textDecoration' | ||
| 'fills' | ||
> | ||
): Partial<TextStyle> => { | ||
return { | ||
fontFamily: node.fontName.family, | ||
fontSize: node.fontSize.toString(), | ||
fontStyle: node.fontName.style, | ||
fontWeight: node.fontWeight.toString(), | ||
textDecoration: translateTextDecoration(node), | ||
textTransform: translateTextTransform(node) | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
export * from './translateBlendMode'; | ||
export * from './translateFills'; | ||
export * from './translateGradientLinearFill'; | ||
export * from './translateSolidFill'; | ||
export * from './translateStrokes'; | ||
export * from './translateStyledTextSegments'; | ||
export * from './translateTextDecoration'; | ||
export * from './translateTextTransform'; | ||
export * from './translateVectorPaths'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { transformTextStyle } from '@plugin/transformers/partials'; | ||
import { translateFills } from '@plugin/translators/translateFills'; | ||
|
||
import { TextNode } from '@ui/lib/types/text/textContent'; | ||
|
||
export const translateStyledTextSegments = ( | ||
segments: Pick< | ||
StyledTextSegment, | ||
| 'characters' | ||
| 'start' | ||
| 'end' | ||
| 'fontName' | ||
| 'fontSize' | ||
| 'fontWeight' | ||
| 'lineHeight' | ||
| 'letterSpacing' | ||
| 'textCase' | ||
| 'textDecoration' | ||
| 'fills' | ||
>[], | ||
width: number, | ||
height: number | ||
): TextNode[] => { | ||
return segments.map(segment => { | ||
figma.ui.postMessage({ type: 'FONT_NAME', data: segment.fontName.family }); | ||
|
||
return { | ||
fills: translateFills(segment.fills, width, height), | ||
text: segment.characters, | ||
...transformTextStyle(segment) | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.