热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CSSbackgroundcolor,CSScolor,andlayerrecipesintheDesignSystemProvider

Problem:WhenusingtheDesignSystemProviderthereexistse


Problem:

When using the DesignSystemProvider there exist several disconnects that make the implementation difficult to use:

  1. The provider does not apply a CSS
    1
    background-color

    to the element aligning to the designSystem.backgroundColor property


  2. The provider does not apply a CSS
    1
    color

    to the element aligning to the designSystem.backgroundColor property


  3. The provider's
    1
    backgroundColor

    property cannot be assigned a recipe.


1 and 2 make the out-of-box experience bad because the color of non-FAST content will be inaccessible and obviously incorrect.

3 is more of an interop problem within the FAST system. The FAST system provides and encourages use of the "layer" recipes to be used as app-region background colors but this implementation of the DesignSystemProvider does not facilitate doing so.

Proposal


1. and 2. - CSS color & background-color

1 and 2 can be remedied rather simply. When the

1
backgroundColor

property of the provider is explicitly set, the provider should attach the following stylesheet:

1
2
3
4
5
6
7
8
9
jsx

css`

:host {

    background-color: var(--background-color);

    color: var(--neutral-foreground-rest);

}

`.attachBehavior(

    neutralForegroundRestBehavior

);

While generally desired, I can imagine cases where a user may not want this behavior so we would want a mechanism to disable attachment. This could be done with a boolean attribute:

1
2
3
jsx




or with a property:

1
2
jsx

FASTDesignSystemProvider.drawBackgroundDisabled = true;


3. - Recipe backgrounds

Another commonly desired cases is to set the value of the

1
DesignSystem.backgroundColor

to the product of a recipe. This often crops up in cases where the layer recipes are used -

1
neutralLayerL1

,

1
neutralLayerL2

, etc.

We could enable the following:

1
2
jsx

FASTDesignSystemProvider.backgroundColor = neutralLayerL1;

When assigned a recipe / fn, the provider would evaluate the recipe when setting

1
FASTDesignSystemProvider.designSystem.backgroundColor

and which would in turn assign the

1
--background-color

CSS Custom Property to the product of the recipe.

A question arises from the above of which

1
designSystem

object the above resolution function should be generated with. There are three viable options:

  1. The parent provider's design system
    1. The downside to this approach is that a user could not set the
      1
      baseLayerLuminosity

      and the background color on one provider to achieve a light/dark mode change. In fact, the recipe would not see any

      1
      designSystem

      changes on the element with the background change. I think this is a big enough miss that this option should not be selected but it is included for completeness.



  2. The local design system
    1. This option would invoke the recipe to resolve the background color with the local design system object. This facilitates cases like light/dark mode switching using a single node, because the recipe would see the designSystem changes applied to the node.

    2. The only reasonable down-side or disconnect I see to this is that it could create recursive behavior that would likely be undesirable. Because this recipe sets a property on the
      1
      designSystem

      (

      1
      designSystem.backgroundColor

      ), if the recipe uses

      1
      designSystem.backgroundColor

      in determining the color product then each invocation will be relying on the previous invocations product - recursive color resolution. This would likely be an unintuitive and undesired behavior.



  3. The hybrid design system
    1. To address the issue described by 2.2, we could supply the fn a hybrid design system, where every property besides the property being set is derived from the local designSystem object, and the property being set (
      1
      backgroundColor

      ) is derived from the parent design system.


    2. Another solution would be to omit the color from the invocation of the recipe so that it cannot be relied upon.


该提问来源于开源项目:microsoft/fast

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


推荐阅读
author-avatar
头都大了66
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有