Sync Options
- Type:
SyncConfig
- Related: Sync
Confiure the sync
in your theemo.config.js
.
js
import { defineConfig } from '@theemo/cli';
export default defineConfig({
sync: {
// ...
}
});
sync.reader
- Type:
ReaderConfig
- Related: Reader
sync.reader.sources
- Type:
ReaderTool | ReaderTool[]
- Required
- Related: Figma Reader, Write your own Reader,
One or many sources to read tokens from.
sync.lexer
- Type:
LexerConfig
- Related: Lexer
sync.lexer.classifyToken()
Classifying tokens is to give them a meaning. Here you'll want to set token internals. What's the token tier or its visibility?
Here is a way to set visibility:
ts
import { defineConfig } from '@theemo/cli';
import type { Token } from '@theemo/tokens';
export default defineConfig({
sync: {
lexer: {
classifyToken(token: Token) {
// assuming you have set `figmaName` before
return {
...token,
visibility: token.figmaName.startsWith('.') ? 'internal' : 'public'
}
}
}
}
});
sync.lexer.filterToken()
- Type:
LexerConfig.filterToken
Finally, with structured information available on tokens, it's time to finally filter the output from Figma to our needs.
For example, you are not interested in internal
tokens - but all others, this is what your filter can look like:
ts
import { defineConfig } from '@theemo/cli';
import type { Token } from '@theemo/tokens';
export default defineConfig({
sync: {
lexer: {
filterToken(token: Token) {
return token.visibility !== 'internal';
}
}
}
});
sync.lexer.normalizeToken()
The purpose of normalization is to "tidy" up your token (names), such as cleaning up possible whitespace or when you are using contexts to extract that part into a structured property.
ts
import { defineConfig } from '@theemo/cli';
import type { Token } from '@theemo/tokens';
export default defineConfig({
sync: {
lexer: {
normalizeToken(token: Token) {
return {
...token,
name: token.name.trim()
};
}
}
}
});
sync.writer
- Type:
WriterConfig
- Related: Writer
sync.writer.targets
- Type:
WriterTool | WriterTool[]
- Required
- Related: Style Dictionary Writer, Write your own Writer
One or many targets to write tokens to.