Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Commit b3de267

Browse files
committed
feat: add typography token
1 parent 955a15d commit b3de267

File tree

2 files changed

+147
-17
lines changed

2 files changed

+147
-17
lines changed

apps/poc-tokens-plugin/src/app/app.component.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ export class AppComponent {
106106
tokenValue = 25;
107107
break;
108108
case 'shadow':
109-
tokenValue = [{
110-
color: '#123456',
111-
inset: 'false',
112-
offsetX: '6',
113-
offsetY: '6',
114-
spread: '0',
115-
blur: '4',
116-
}];
109+
tokenValue = [
110+
{
111+
color: '#123456',
112+
inset: 'false',
113+
offsetX: '6',
114+
offsetY: '6',
115+
spread: '0',
116+
blur: '4',
117+
},
118+
];
117119
break;
118120
case 'color':
119121
tokenValue = '#fabada';
@@ -159,12 +161,13 @@ export class AppComponent {
159161
break;
160162
case 'typography':
161163
tokenValue = {
162-
fontFamilies: 'Acme',
163-
fontSizes: 36,
164-
letterSpacing: 0.8,
165-
textCase: 'none',
164+
fontFamilies: ['Acme', 'Arial', 'Sans Serif'],
165+
fontSizes: '36',
166+
letterSpacing: '0.8',
167+
textCase: 'uppercase',
166168
textDecoration: 'none',
167-
fontWeights: 600,
169+
fontWeights: '600',
170+
lineHeight: '1.5',
168171
};
169172
break;
170173
}

libs/plugin-types/index.d.ts

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,7 +4595,8 @@ export interface TokenFontWeights extends TokenBase {
45954595
* The value calculated by finding all tokens with the same name in active sets
45964596
* and resolving the references.
45974597
*
4598-
* It's a weight string, or undefined if no value has been found in active sets.
4598+
* It's a weight string ("bold", "strong", etc.), or undefined if no value has
4599+
* been found in active sets.
45994600
*/
46004601
readonly resolvedValue: string | undefined;
46014602
}
@@ -4797,7 +4798,8 @@ export interface TokenTextCase extends TokenBase {
47974798
* The value calculated by finding all tokens with the same name in active sets
47984799
* and resolving the references.
47994800
*
4800-
* It's a case string, or undefined if no value has been found in active sets.
4801+
* It's a case string ("none", "uppercase", "lowercase", "capitalize"), or
4802+
* undefined if no value has been found in active sets.
48014803
*/
48024804
readonly resolvedValue: string | undefined;
48034805
}
@@ -4828,6 +4830,118 @@ export interface TokenTextDecoration extends TokenBase {
48284830
readonly resolvedValue: string | undefined;
48294831
}
48304832

4833+
/*
4834+
* The value of a TokenTypography in its composite form.
4835+
*/
4836+
export interface TokenTypographyValue {
4837+
/**
4838+
* The letter spacing, as a number.
4839+
*/
4840+
letterSpacing: number;
4841+
4842+
/**
4843+
* The list of font families.
4844+
*/
4845+
fontFamilies: string[];
4846+
4847+
/**
4848+
* The font size, as a positive number.
4849+
*/
4850+
fontSizes: number;
4851+
4852+
/**
4853+
* The font weight, as a weight string ("bold", "strong", etc.).
4854+
*/
4855+
fontWeights: string;
4856+
4857+
/**
4858+
* The line height, as a number.
4859+
*/
4860+
lineHeight: number;
4861+
4862+
/**
4863+
* The text case as a string ("none", "uppercase", "lowercase" "capitalize").
4864+
*/
4865+
textCase: string;
4866+
4867+
/**
4868+
* The text decoration as a string ("none", "underline", "strike-through").
4869+
*/
4870+
textDecoration: string;
4871+
}
4872+
4873+
/*
4874+
* The value of a TokenTypography in its composite of strings form.
4875+
*/
4876+
export interface TokenTypographyValueString {
4877+
/**
4878+
* The letter spacing, as a number, or a reference to a TokenLetterSpacing.
4879+
*/
4880+
letterSpacing: string;
4881+
4882+
/**
4883+
* The list of font families, or a reference to a TokenFontFamilies.
4884+
*/
4885+
fontFamilies: string | string[];
4886+
4887+
/**
4888+
* The font size, as a positive number, or a reference to a TokenFontSizes.
4889+
*/
4890+
fontSizes: string;
4891+
4892+
/**
4893+
* The font weight, as a weight string ("bold", "strong", etc.), or a
4894+
* reference to a TokenFontWeights.
4895+
*/
4896+
fontWeight: string;
4897+
4898+
/**
4899+
* The line height, as a number. Note that there not exists an individual
4900+
* token type line height, only part of a Typography token. If you need to
4901+
* put here a reference, use a NumberToken.
4902+
*/
4903+
lineHeight: string;
4904+
4905+
/**
4906+
* The text case as a string ("none", "uppercase", "lowercase" "capitalize"),
4907+
* or a reference to a TokenTextCase.
4908+
*/
4909+
textCase: string;
4910+
4911+
/**
4912+
* The text decoration as a string ("none", "underline", "strike-through"),
4913+
* or a reference to a TokenTextDecoration.
4914+
*/
4915+
textDecoration: string;
4916+
}
4917+
4918+
/**
4919+
* Represents a token of type Typography.
4920+
* This interface extends `TokenBase` and specifies the data type of the value.
4921+
*/
4922+
export interface TokenTypography extends TokenBase {
4923+
/**
4924+
* The type of the token.
4925+
*/
4926+
readonly type: 'typography';
4927+
4928+
/**
4929+
* The value as defined in the token itself.
4930+
* It may be a string with a reference to other token, or a
4931+
* TokenTypographyValueString.
4932+
*/
4933+
value: string | TokenTypographyValueString;
4934+
4935+
/**
4936+
* The value calculated by finding all tokens with the same name in active sets
4937+
* and resolving the references.
4938+
*
4939+
* It's a TokenTypographyValue, or undefined if no value has been found
4940+
* in active sets.
4941+
*/
4942+
readonly resolvedValue: TokenTypographyValue[] | undefined;
4943+
}
4944+
48314945
/**
48324946
* The supported Design Tokens in Penpot.
48334947
*/
@@ -4836,12 +4950,19 @@ export type Token =
48364950
| TokenShadow
48374951
| TokenColor
48384952
| TokenDimension
4953+
| TokenFontFamilies
48394954
| TokenFontSizes
4955+
| TokenFontWeights
4956+
| TokenLetterSpacing
4957+
| TokenNumber
48404958
| TokenOpacity
48414959
| TokenRotation
48424960
| TokenSizing
48434961
| TokenSpacing
4844-
| TokenBorderWidth;
4962+
| TokenBorderWidth
4963+
| TokenTextCase
4964+
| TokenTextDecoration
4965+
| TokenTypography;
48454966

48464967
/**
48474968
* The collection of all tokens in a Penpot file's library.
@@ -5143,6 +5264,11 @@ type TokenTextCaseProps = 'text-case';
51435264
*/
51445265
type TokenTextDecorationProps = 'text-decoration';
51455266

5267+
/**
5268+
* The properties that a Typography token can be applied to.
5269+
*/
5270+
type TokenTypographyProps = 'typography';
5271+
51465272
/**
51475273
* All the properties that a token can be applied to.
51485274
* Not always correspond to Shape properties. For example,
@@ -5166,7 +5292,8 @@ export type TokenProperty =
51665292
| TokenSpacingProps
51675293
| TokenBorderWidthProps
51685294
| TokenTextCaseProps
5169-
| TokenTextDecorationProps;
5295+
| TokenTextDecorationProps
5296+
| TokenTypographyProps;
51705297

51715298
/**
51725299
* The supported types of Design Tokens in Penpot.

0 commit comments

Comments
 (0)