Skip to content

Commit

Permalink
Fix naming convention and export
Browse files Browse the repository at this point in the history
  • Loading branch information
bheston committed Sep 16, 2022
1 parent 6fbbc55 commit 618d27e
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 46 deletions.
6 changes: 6 additions & 0 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@ export const focusStrokeOuterRecipe: DesignToken<ColorRecipe>;
// @public (undocumented)
export const focusStrokeWidth: CSSDesignToken<number>;

// @public
export const focusTreatmentBase: CSSDirective;

// @public
export const focusTreatmentTight: CSSDirective;

// @public (undocumented)
export const fontWeight: CSSDesignToken<number>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
neutralStrokeLayerRest,
strokeWidth,
} from '../../design-tokens';
import { insetFocusTreatment } from '../../styles/patterns/focus';
import { focusTreatmentBase } from '../../styles/focus';
import { typeRampBase } from '../../styles/patterns/type-ramp';
import { heightNumber } from '../../styles/size';

Expand Down Expand Up @@ -103,7 +103,7 @@ export const accordionItemStyles: (
}
.button:${focusVisible}::before {
${insetFocusTreatment}
${focusTreatmentBase}
border-radius: calc(${layerCornerRadius} * 1px);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { heightNumber } from '../styles/index';
import { offsetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentTight } from '../styles/focus';

export const breadcrumbItemStyles: (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -61,7 +61,7 @@ export const breadcrumbItemStyles: (
}
.control:${focusVisible} {
${offsetFocusTreatment}
${focusTreatmentTight}
}
:host(:not([href])),
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/checkbox/checkbox.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { offsetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentTight } from '../styles/focus';

export const checkboxStyles: (context: ElementDefinitionContext, definition: CheckboxOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -106,7 +106,7 @@ export const checkboxStyles: (context: ElementDefinitionContext, definition: Che
:host(:${focusVisible}) .control {
background: ${neutralFillInputAltFocus};
${offsetFocusTreatment}
${focusTreatmentTight}
}
:host(.checked) .control {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const dataGridCellStyles: (
context: ElementDefinitionContext,
Expand All @@ -37,7 +37,7 @@ export const dataGridCellStyles: (
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
`.withBehaviors(
forcedColorsStylesheetBehavior(
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/flipper/flipper.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
neutralStrokeControlRest,
strokeWidth,
} from '../design-tokens';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const flipperStyles: (context: ElementDefinitionContext, definition: FlipperOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -65,7 +65,7 @@ export const flipperStyles: (context: ElementDefinitionContext, definition: Flip
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
:host::-moz-focus-inner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const optionStyles: (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -81,7 +81,7 @@ export const optionStyles: (
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
background: ${neutralFillStealthFocus};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/listbox/listbox.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
neutralStrokeRest,
strokeWidth,
} from '../design-tokens';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const listboxStyles: (
context: ElementDefinitionContext,
Expand All @@ -31,6 +31,6 @@ export const listboxStyles: (
}
:host(:focus-within:not([disabled])) {
${insetFocusTreatment}
${focusTreatmentBase}
}
`
4 changes: 2 additions & 2 deletions packages/web-components/src/menu-item/menu-item.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const menuItemStyles: (context: ElementDefinitionContext, definition: MenuItemOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -84,7 +84,7 @@ export const menuItemStyles: (context: ElementDefinitionContext, definition: Men
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
:host(:not([disabled]):hover) {
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/radio/radio.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { offsetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentTight } from '../styles/focus';

export const radioStyles: (context: ElementDefinitionContext, definition: RadioOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -106,7 +106,7 @@ export const radioStyles: (context: ElementDefinitionContext, definition: RadioO
}
:host(:${focusVisible}) .control {
${offsetFocusTreatment}
${focusTreatmentTight}
background: ${neutralFillInputAltFocus};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/select/select.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const selectFilledStyles: (context: ElementDefinitionContext, definition: SelectOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -150,7 +150,7 @@ export const selectStyles = (context, definition) =>
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
:host([disabled]) {
Expand Down
23 changes: 23 additions & 0 deletions packages/web-components/src/styles/focus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { cssPartial } from '@microsoft/fast-element';
import { focusStrokeOuter, focusStrokeWidth, strokeWidth } from '../design-tokens';

/**
* Partial CSS for the focus treatment for most typical sized components like Button, Menu Item, etc.
*
* @public
*/
export const focusTreatmentBase = cssPartial`
outline: calc(${focusStrokeWidth} * 1px) solid ${focusStrokeOuter};
outline-offset: calc(${focusStrokeWidth} * -1px);
`;

/**
* Partial CSS for the focus treatment for tighter components with spacing constraints, like Checkbox
* and Radio, or plain text like Hypertext appearance Anchor or Breadcrumb Item.
*
* @public
*/
export const focusTreatmentTight = cssPartial`
outline: calc(${focusStrokeWidth} * 1px) solid ${focusStrokeOuter};
outline-offset: calc(${strokeWidth} * 1px);
`;
1 change: 1 addition & 0 deletions packages/web-components/src/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './direction';
export * from './elevation';
export * from './focus';
export * from './patterns/';
export * from './size';
8 changes: 4 additions & 4 deletions packages/web-components/src/styles/patterns/button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
strokeWidth,
} from '../../design-tokens';
import { typeRampBase } from '../../styles/patterns/type-ramp';
import { insetFocusTreatment, offsetFocusTreatment } from './focus';
import { focusTreatmentBase, focusTreatmentTight } from '../focus';

/**
* @internal
Expand Down Expand Up @@ -108,7 +108,7 @@ export const baseButtonStyles = (
}
:host .control:${focusVisible} {
${insetFocusTreatment}
${focusTreatmentBase}
}
:host .control${nonInteractivitySelector} {
Expand Down Expand Up @@ -209,7 +209,7 @@ export const AccentButtonStyles = (
}
:host .control:${focusVisible} {
${insetFocusTreatment}
${focusTreatmentBase}
box-shadow: 0 0 0 calc(((${focusStrokeWidth} + ${strokeWidth}) - ${strokeWidth}) * 1px) ${focusStrokeInner} inset !important;
}
Expand Down Expand Up @@ -306,7 +306,7 @@ export const HypertextStyles = (
}
:host .control:${focusVisible} {
${offsetFocusTreatment}
${focusTreatmentTight}
}
:host .control${nonInteractivitySelector} {
Expand Down
14 changes: 0 additions & 14 deletions packages/web-components/src/styles/patterns/focus.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/web-components/src/switch/switch.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
strokeWidth,
} from '../design-tokens';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { offsetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentTight } from '../styles/focus';

export const switchStyles: (context: ElementDefinitionContext, definition: SwitchOptions) => ElementStyles = (
context: ElementDefinitionContext,
Expand Down Expand Up @@ -88,7 +88,7 @@ export const switchStyles: (context: ElementDefinitionContext, definition: Switc
}
:host(:${focusVisible}) .switch {
${offsetFocusTreatment}
${focusTreatmentTight}
background: ${neutralFillInputAltFocus};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/tabs/tab/tab.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
strokeWidth,
} from '../../design-tokens';
import { typeRampBase } from '../../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../../styles/patterns/focus';
import { focusTreatmentBase } from '../../styles/focus';

export const tabStyles: (context: ElementDefinitionContext, definition: FoundationElementDefinition) => ElementStyles =
(context: ElementDefinitionContext, definition: FoundationElementDefinition) =>
Expand Down Expand Up @@ -45,7 +45,7 @@ export const tabStyles: (context: ElementDefinitionContext, definition: Foundati
}
:host(:${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
:host(.vertical) {
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/toolbar/toolbar.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@microsoft/fast-foundation';
import { SystemColors } from '@microsoft/fast-web-utilities';
import { designUnit, fillColor } from '../design-tokens';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

export const toolbarStyles: (
context: ElementDefinitionContext,
Expand All @@ -25,7 +25,7 @@ export const toolbarStyles: (
}
:host(${focusVisible}) {
${insetFocusTreatment}
${focusTreatmentBase}
}
.positioning-region {
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/src/tree-item/tree-item.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../design-tokens';
import { Swatch } from '../color/swatch';
import { typeRampBase } from '../styles/patterns/type-ramp';
import { insetFocusTreatment } from '../styles/patterns/focus';
import { focusTreatmentBase } from '../styles/focus';

const ltr = css`
.expand-collapse-button svg {
Expand Down Expand Up @@ -107,7 +107,7 @@ export const treeItemStyles: (context: ElementDefinitionContext, definition: Tre
}
:host(:${focusVisible}) .positioning-region {
${insetFocusTreatment}
${focusTreatmentBase}
}
.positioning-region::before {
Expand Down

0 comments on commit 618d27e

Please sign in to comment.