Skip to content

Sync Options

Confiure the sync in your theemo.config.js.

theemo.config.js
js
import { 
defineConfig
} from '@theemo/cli';
export default
defineConfig
({
sync
: {
// ... } });

sync.reader

sync.reader.sources

One or many sources to read tokens from.

sync.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:

theemo.config.js
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()

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:

theemo.config.js
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.

theemo.config.js
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

sync.writer.targets

One or many targets to write tokens to.