question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sharing theme tokens with the runtime

See original GitHub issue

Sometimes, a theme’s specific tokens may be required during runtime. E.g. for generating styles with theme-based breakpoints on the fly. I propose the following API for making values of a theme’s tokens importable from runtime:

// Component.treat.ts
import { getTokens } from 'treat';

export const sharedTokens = getTokens(
  // theme => tokens
  ({ breakpoints, shorthands, aliases }) => ({ breakpoints, shorthands, aliases })
);

Usage:

import { sharedTokens } from './Component.treat';

export default function Component() {
  return <div>{sharedTokens.breakpoints.join()}</div>;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maraisrcommented, Mar 23, 2020

Yeah! We have a custom provider too! It wraps the ThemeProvider from treat.

1reaction
kripodcommented, Mar 23, 2020

@maraisr Sounds viable, thanks! I’ve been doing something similar, but was wondering whether creating a custom provider could be avoided.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use DI Token to provide different services instance at ...
This container component has one method onEmployeeList() which decides which list of employee data to load inside component at runtime.
Read more >
using design tokens in your apps, and try dark theme in Jira ...
We've been busy incorporating design tokens in Jira Cloud in recent months, and building the new light/dark themes. We're thrilled to share ......
Read more >
Old and new ideas in React UI
Design Tokens; Modular Scales; Theme specification; ThemeProvider in React; Styles connected to theme; Element primitive; Classes, ...
Read more >
Styling Using Design Tokens - Lumo Theme - Vaadin
Learn how to use Lumo design tokens to style your application and components.
Read more >
CancellationTokenSource.CreateLinkedTokenSource Method
Runtime.dll ... An array that contains the cancellation token instances to observe. ... A CancellationTokenSource that is linked to the source tokens.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found