Skip to content

Commit

Permalink
add neutral-contrast-fill recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
khamudom committed Feb 4, 2021
1 parent 8e6c3bb commit 218a3f4
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 1 deletion.
51 changes: 51 additions & 0 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Breadcrumb } from '@microsoft/fast-foundation';
import { BreadcrumbItem } from '@microsoft/fast-foundation';
import { Button } from '@microsoft/fast-foundation';
import { Checkbox } from '@microsoft/fast-foundation';
import { ColorRGBA64 } from '@microsoft/fast-colors';
import { CSSCustomPropertyBehavior } from '@microsoft/fast-foundation';
import { DesignSystemProvider } from '@microsoft/fast-foundation';
import { Dialog } from '@microsoft/fast-foundation';
Expand Down Expand Up @@ -284,6 +285,14 @@ export interface DesignSystem {
disabledOpacity: number;
elevatedCornerRadius?: number;
focusOutlineWidth: number;
// (undocumented)
neutralContrastFillActiveDelta: number;
// (undocumented)
neutralContrastFillFocusDelta: number;
// (undocumented)
neutralContrastFillHoverDelta: number;
// (undocumented)
neutralContrastFillRestDelta: number;
neutralDividerRestDelta: number;
// (undocumented)
neutralFillActiveDelta: number;
Expand Down Expand Up @@ -502,6 +511,10 @@ export class FluentDesignSystemProvider extends DesignSystemProvider implements
elevatedCornerRadius: number;
// (undocumented)
focusOutlineWidth: number;
neutralContrastFillActiveDelta: number;
neutralContrastFillFocusDelta: number;
neutralContrastFillHoverDelta: number;
neutralContrastFillRestDelta: number;
// (undocumented)
neutralDividerRestDelta: number;
// (undocumented)
Expand Down Expand Up @@ -732,6 +745,41 @@ export const MenuItemStyles: import("@microsoft/fast-element").ElementStyles;
// @public
export const MenuStyles: import("@microsoft/fast-element").ElementStyles;

// Warning: (ae-internal-missing-underscore) The name "neutralContrastFill" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const neutralContrastFill: SwatchFamilyResolver;

// Warning: (ae-internal-missing-underscore) The name "neutralContrastFillActive" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const neutralContrastFillActive: SwatchRecipe;

// @public
export const neutralContrastFillActiveBehavior: CSSCustomPropertyBehavior;

// @public
export const neutralContrastFillFocusBehavior: CSSCustomPropertyBehavior;

// Warning: (ae-internal-missing-underscore) The name "neutralContrastFillHover" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const neutralContrastFillHover: SwatchRecipe;

// @public
export const neutralContrastFillHoverBehavior: CSSCustomPropertyBehavior;

// Warning: (ae-internal-missing-underscore) The name "neutralContrastFillRest" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const neutralContrastFillRest: SwatchRecipe;

// @public
export const neutralContrastFillRestBehavior: CSSCustomPropertyBehavior;

// @public
export const neutralContrastForegroundRestBehavior: CSSCustomPropertyBehavior;

// Warning: (ae-internal-missing-underscore) The name "neutralDividerRest" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
Expand Down Expand Up @@ -1126,6 +1174,9 @@ export enum PaletteType {
neutral = "neutral"
}

// @public
export function parseColorString(color: string): ColorRGBA64;

// @public
export const ProgressRingStyles: import("@microsoft/fast-element").ElementStyles;

Expand Down
7 changes: 7 additions & 0 deletions packages/web-components/src/color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export {
accentFillLargeSelected,
} from './accent-fill';

export {
neutralContrastFill,
neutralContrastFillRest,
neutralContrastFillHover,
neutralContrastFillActive,
} from './neutral-contrast-fill';

export { neutralFillCard } from './neutral-fill-card';

/**
Expand Down
56 changes: 56 additions & 0 deletions packages/web-components/src/color/neutral-contrast-fill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
neutralContrastFillActiveDelta,
neutralContrastFillFocusDelta,
neutralContrastFillHoverDelta,
neutralPalette,
} from '../fluent-design-system';
import {
colorRecipeFactory,
SwatchFamilyResolver,
swatchFamilyToSwatchRecipeFactory,
SwatchFamilyType,
SwatchRecipe,
} from './common';
import { accessibleAlgorithm } from './accessible-recipe';

/**
* @internal
*/
export const neutralContrastFill: SwatchFamilyResolver = colorRecipeFactory(
accessibleAlgorithm(
neutralPalette,
14,
0,
neutralContrastFillHoverDelta,
neutralContrastFillActiveDelta,
neutralContrastFillFocusDelta,
),
);
/**
* @internal
*/
export const neutralContrastFillRest: SwatchRecipe = swatchFamilyToSwatchRecipeFactory(
SwatchFamilyType.rest,
neutralContrastFill,
);
/**
* @internal
*/
export const neutralContrastFillHover: SwatchRecipe = swatchFamilyToSwatchRecipeFactory(
SwatchFamilyType.hover,
neutralContrastFill,
);
/**
* @internal
*/
export const neutralContrastFillActive: SwatchRecipe = swatchFamilyToSwatchRecipeFactory(
SwatchFamilyType.active,
neutralContrastFill,
);
/**
* @internal
*/
export const neutralContrastFillFocus: SwatchRecipe = swatchFamilyToSwatchRecipeFactory(
SwatchFamilyType.focus,
neutralContrastFill,
);
64 changes: 64 additions & 0 deletions packages/web-components/src/design-system-provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,70 @@ export class FluentDesignSystemProvider extends DesignSystemProvider
default: DesignSystemDefaults.neutralOutlineFocusDelta,
})
public neutralOutlineFocusDelta: number;

/**
* The distance from the resolved neutral contrast fill color for the rest state of the neutral-contrast-fill recipe. See {@link @microsoft/fast-components#neutralContrastFillRestBehavior} for usage in CSS.
*
* @remarks
* HTML attribute: neutral-contrast-fill-rest-delta
*
* CSS custom property: N/A
*/
@designSystemProperty({
attribute: 'neutral-contrast-fill-rest-delta',
converter: nullableNumberConverter,
cssCustomProperty: false,
default: DesignSystemDefaults.neutralContrastFillRestDelta,
})
public neutralContrastFillRestDelta: number;

/**
* The distance from the resolved neutral contrast fill color for the rest state of the neutral-contrast-fillrecipe. See {@link @microsoft/fast-components#neutralContrastFillHoverBehavior} for usage in CSS.
*
* @remarks
* HTML attribute: neutral-contrast-fill-hover-delta
*
* CSS custom property: N/A
*/
@designSystemProperty({
attribute: 'neutral-contrast-fill-hover-delta',
converter: nullableNumberConverter,
cssCustomProperty: false,
default: DesignSystemDefaults.neutralContrastFillHoverDelta,
})
public neutralContrastFillHoverDelta: number;

/**
* The distance from the resolved neutral contrast fill color for the rest state of the neutral-contrast-fill recipe. See {@link @microsoft/fast-components#neutralContrastFillActiveBehavior} for usage in CSS.
*
* @remarks
* HTML attribute: neutral-contrast-fill-active-delta
*
* CSS custom property: N/A
*/
@designSystemProperty({
attribute: 'neutral-contrast-fill-active-delta',
converter: nullableNumberConverter,
cssCustomProperty: false,
default: DesignSystemDefaults.neutralContrastFillActiveDelta,
})
public neutralContrastFillActiveDelta: number;

/**
* The distance from the resolved neutral contrast fill color for the rest state of the neutral-contrast-fill recipe. See {@link @microsoft/fast-components#neutralContrastFillFocusBehavior} for usage in CSS.
*
* @remarks
* HTML attribute: neutral-contrast-fill-focus-delta
*
* CSS custom property: N/A
*/
@designSystemProperty({
attribute: 'neutral-contrast-fill-focus-delta',
converter: nullableNumberConverter,
cssCustomProperty: false,
default: DesignSystemDefaults.neutralContrastFillFocusDelta,
})
public neutralContrastFillFocusDelta: number;
}

/**
Expand Down
26 changes: 26 additions & 0 deletions packages/web-components/src/fluent-design-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ export interface DesignSystem {
neutralOutlineHoverDelta: number;
neutralOutlineActiveDelta: number;
neutralOutlineFocusDelta: number;

/*
* Color swatch deltas for the neutral-contrast-fill recipe.
*/
neutralContrastFillRestDelta: number;
neutralContrastFillHoverDelta: number;
neutralContrastFillActiveDelta: number;
neutralContrastFillFocusDelta: number;
}

/**
Expand Down Expand Up @@ -280,6 +288,11 @@ export const DesignSystemDefaults: DesignSystem = {
neutralOutlineHoverDelta: 40,
neutralOutlineActiveDelta: 16,
neutralOutlineFocusDelta: 25,

neutralContrastFillRestDelta: 0,
neutralContrastFillHoverDelta: -3,
neutralContrastFillActiveDelta: 7,
neutralContrastFillFocusDelta: 0,
};

/**
Expand Down Expand Up @@ -451,3 +464,16 @@ export const neutralOutlineActiveDelta: DesignSystemResolver<number> = getDesign
);

export const neutralOutlineFocusDelta: DesignSystemResolver<number> = getDesignSystemValue('neutralOutlineFocusDelta');

export const neutralContrastFillRestDelta: DesignSystemResolver<number> = getDesignSystemValue(
'neutralContrastFillRestDelta',
);
export const neutralContrastFillHoverDelta: DesignSystemResolver<number> = getDesignSystemValue(
'neutralContrastFillHoverDelta',
);
export const neutralContrastFillActiveDelta: DesignSystemResolver<number> = getDesignSystemValue(
'neutralContrastFillActiveDelta',
);
export const neutralContrastFillFocusDelta: DesignSystemResolver<number> = getDesignSystemValue(
'neutralContrastFillFocusDelta',
);
49 changes: 48 additions & 1 deletion packages/web-components/src/styles/behaviors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
accentForegroundCut,
accentForegroundLarge,
neutralDividerRest,
neutralContrastFill,
neutralContrastFillRest,
neutralFill,
neutralFillCard,
neutralFillInput,
Expand All @@ -17,6 +19,7 @@ import {
neutralForeground,
neutralForegroundHint,
neutralForegroundHintLarge,
neutralForegroundRest,
neutralForegroundToggle,
neutralForegroundToggleLarge,
neutralLayerCard,
Expand Down Expand Up @@ -581,7 +584,51 @@ export const neutralFocusInnerAccentBehavior: CSSCustomPropertyBehavior = cssCus
neutralFocusInnerAccent(accentBaseColor),
FluentDesignSystemProvider.findProvider,
);

/**
* Behavior to resolve and make available the neutral-contrast-foreground-rest CSS custom property.
* @public
*/
export const neutralContrastForegroundRestBehavior = cssCustomPropertyBehaviorFactory(
'neutral-contrast-foreground-rest',
x => neutralForegroundRest(neutralContrastFillRest)(x),
FluentDesignSystemProvider.findProvider,
);
/**
* Behavior to resolve and make available the neutral-contrast-fill-rest CSS custom property.
* @public
*/
export const neutralContrastFillRestBehavior = cssCustomPropertyBehaviorFactory(
'neutral-contrast-fill-rest',
x => neutralContrastFill(x).rest,
FluentDesignSystemProvider.findProvider,
);
/**
* Behavior to resolve and make available the neutral-contrast-fill-hover CSS custom property.
* @public
*/
export const neutralContrastFillHoverBehavior = cssCustomPropertyBehaviorFactory(
'neutral-contrast-fill-hover',
x => neutralContrastFill(x).hover,
FluentDesignSystemProvider.findProvider,
);
/**
* Behavior to resolve and make available the neutral-contrast-fill-active CSS custom property.
* @public
*/
export const neutralContrastFillActiveBehavior = cssCustomPropertyBehaviorFactory(
'neutral-contrast-fill-active',
x => neutralContrastFill(x).active,
FluentDesignSystemProvider.findProvider,
);
/**
* Behavior to resolve and make available the neutral-contrast-fill-focus CSS custom property.
* @public
*/
export const neutralContrastFillFocusBehavior = cssCustomPropertyBehaviorFactory(
'neutral-contrast-fill-focus',
x => neutralContrastFill(x).focus,
FluentDesignSystemProvider.findProvider,
);
/**
* Behavior to resolve and make available the inline-start CSS custom property.
*
Expand Down

0 comments on commit 218a3f4

Please sign in to comment.