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

feat: fast-provider #4010

Closed
wants to merge 41 commits into from
Closed

feat: fast-provider #4010

wants to merge 41 commits into from

Conversation

nicholasrice
Copy link
Contributor

@nicholasrice nicholasrice commented Oct 6, 2020

Description

This PR tracks the work to implement the new Provider system outlined in #3361.

This is a work in progress, so check back frequently to see progress, but please don't feel compelled to leave do a detailed review at this point.

Updates:

  1. The Provider concept has been replaced with a general-purpose dependency injection system

Feature checklist

  • Add FoundationElement
    • Method to resolve template for instance, resolving from self or provider
    • Method to resolve styles for instance, resolving from self or provider
    • Instance template and styles (provides opportunity to set styles and template for an element instance)
    • Mechanism to resolves nearest provider during connectedCallback()
  • Add Provider
    • Tracks parent provider, if any, otherwise null.
    • Can resolve templates for an element instance
    • Can resolve styles for an element instance
    • Arbitrary custom elements can be Provider instance
    • Can register design tokens that reflect to CSS custom properties
    • Can register CSS custom property resolvers that write CSS custom properties that are a product of the provider instance
    • How can this all hook into a general purpose provider mechanism that can be extensible?
  • Dependency-injection system
    • Resolution of DI containers through DOM hierarchy
    • Resolution of DI containers not through DOM hierarchy
  • DesignTokenLibrary for managing design tokens
    • Subscription to property changes
    • Can create token library hierarchies
    • Can assign "derived" properties, where the property getter returns the product of an evaluate fn. Can establish design token dependencies for a derived property. If a derived property depends on itself (setting a bg color to a product of bg color + others) then the upstream property will always be used during evaluation
    • Read-only token library (w/ decorator to connect to nearest provider library)
  • DesignTokenProvider
    • DI container to provide DesignTokenLibraries (read and read/write)
    • Writes design tokens set on instance to CSS Custom properties
    • Can hook up attributes and properties to Design Tokens, as configured by the Configuration This can be done per-provider pretty easily, and in ways that make sense for that provider. I'm not sure global configuration for this is necessary anymore
    • Provides mechanism to assign properties by component state.
  • Add Configuration
    • Can construct with a prefix option to be the custom element name prefix
    • Can register a default template for an element name
    • Can register a default stylesheet for an element name
    • Can register a custom element. This would define the element customElements.define()
    • Can register design tokens
      • Map token to a content property
      • Map token to an IDL property
      • Map token to a CSS custom property
      • Associate default value for token
    • Can define a Provider with defineProvider()
    • Can reflect design token CSS custom properties to the body element (optionally, facilitates scenario where authors don't want to wrap UI with a provider element)(investigate impacts of this).
    • Can update a Design Token value to change the default.
  • CSSCustomPropertyManager to manage creation of CSSStyleSheet instances for re-use across components.
    • Can get ElementStyles | HTMLStyleElement by custom property key / value
    • DI interface

Issue type checklist

  • Chore: A change that does not impact distributed packages.
  • Bug fix: A change that fixes an issue, link to the issue above.
  • New feature: A change that adds functionality.

Is this a breaking change?

  • This change causes current functionality to break.

Adding or modifying component(s) in @microsoft/fast-components checklist

Process & policy checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@nicholasrice nicholasrice marked this pull request as draft October 6, 2020 22:33
@nicholasrice nicholasrice changed the title adding provider index file feat: fast-provider Oct 6, 2020
@nicholasrice nicholasrice force-pushed the features/provider branch 4 times, most recently from 392c4df to 4305901 Compare November 13, 2020 20:01
@nicholasrice nicholasrice force-pushed the features/provider branch 3 times, most recently from 424ddee to 7b00305 Compare November 18, 2020 19:09
@nicholasrice nicholasrice self-assigned this Dec 16, 2020
@nicholasrice
Copy link
Contributor Author

Closing because this PR is no longer relevant. Some of this has been merged in a different form and the other work will be adapted or dropped as necessary.

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

Successfully merging this pull request may close these issues.

1 participant