Closed danieldelcore closed 3 years ago
Exploring some of the different options relating to dynamic interpolations...
Base case:
import { css } from './macro'; const foo = () => 'bar'; css('Button', { color: foo() });
Option 1: Passing interpolations to the style tag
/** @jsx jsx */ import { css, jsx } from '@trousers/macro/runtime'; const foo = () => 'bar'; const styles = css('Button', { '.Button-2561700995': 'color: var(--interpolation1);', }) <button css={styles} styles={{ interpolation1: foo() }} />
Option 2: Passing interpolations via the collector
This would require that we attach interpolations to the inner element via the style attribute
/** @jsx jsx */ import { css, jsx } from '@trousers/macro/runtime'; const foo = () => 'bar'; css('Button', { '.Button-2561700995': 'color: var(--interpolation1);' }) .interpolations({ interpolation1: foo() }); <button css={styles} />
Inside the jsx pragma we would need to:
Exploring some of the different options relating to dynamic interpolations...
Base case:
Option 1: Passing interpolations to the style tag
Option 2: Passing interpolations via the collector
This would require that we attach interpolations to the inner element via the style attribute
Inside the jsx pragma we would need to: