Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make combineStyleStreams accept streams of arbitrary CSS #250

Open
appsforartists opened this issue Nov 26, 2018 · 1 comment
Open

Make combineStyleStreams accept streams of arbitrary CSS #250

appsforartists opened this issue Nov 26, 2018 · 1 comment

Comments

@appsforartists
Copy link
Member

StyleStreams is currently a whitelist of values that combineStyleStreams can transform into CSS rules. Thus, even though combineStyleStreams will pass through streams of standard CSS rules, TypeScript will reject them:

pointerEvents$ does not exist in type "Partial<StyleStreams>"

Fixing this probably involves falling back to csstype, and either removing the $ suffices from stream arguments, or writing a script that generates rule$: Observable<typeof rule> for every rule in csstype.

@appsforartists
Copy link
Member Author

combineStyleStreams was using csstype in its internals, which caused a conflict for transformOrigin. I worked around it using Exclude, but that's not until TS2.8, and there are other changes that needs to happen before we can upgrade.

Archiving what I had here:

/**
 * The types that `combineStyleStreams` can convert to CSS rules.
 */
export type PrimitiveStyleDict = {
  opacity: number,
  translate: Partial<Point2D>,
  rotate: number,
  scale: number,
  transformOrigin: Partial<Point2D>,
  dimensions: Partial<Dimensions>,
};

/**
 * The CSS rules that aren't explicitly handled by `combineStyleStreams`.  They
 * will be passed through unchanged.
 */
export type PropertiesFallback = {
  [K in Exclude<keyof CSS.Properties, keyof PrimitiveStyleDict>]: CSS.Properties[K]
}

export type StyleDict = Partial<PrimitiveStyleDict> & PropertiesFallback;

appsforartists added a commit that referenced this issue Nov 27, 2018
Summary: There's a bunch more work to be done on the types here (#250), but this gets us building cleanly.

Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion

Tags: #material_motion

Differential Revision: http://codereview.cc/D3469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant