Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/generator/styleProps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import textCaseFigmaToCss from 'lib/utils/textCaseFigmaToCss';

export const fontList = [];

// TODO: shouldn't this use our stringify function?
Expand All @@ -24,7 +26,7 @@ export const styles = (segment: StyledTextSegment) => {
'font-weight': segment.fontWeight,
'font-size': segment.fontSize + 'px',
'text-decoration': segment.textDecoration.toLowerCase(),
'text-transform': segment.textCase === 'ORIGINAL' ? 'none' : segment.textCase.toLowerCase(),
'text-transform': textCaseFigmaToCss(segment.textCase),
'line-height':
segment.lineHeight.unit === 'AUTO'
? 'normal'
Expand Down
18 changes: 18 additions & 0 deletions src/lib/utils/textCaseFigmaToCss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Converts [Figma's TextCase][figma] values to [CSS text-transform][css]
* values.
*
* [figma]: https://www.figma.com/plugin-docs/api/TextCase/
* [css]: https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform
*/
export default (textCase: TextCase) => {
const textCaseMapping = {
ORIGINAL: 'none',
UPPER: 'uppercase',
LOWER: 'lowercase',
TITLE: 'capitalize',
SMALL_CAPS: 'uppercase',
SMALL_CAPS_FORCED: 'uppercase'
} as Record<TextCase, string>;
return textCaseMapping[textCase];
};