Skip to content

Commit

Permalink
style update
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Comeau committed Sep 1, 2021
1 parent 1563c7d commit 7fb0932
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,17 @@ <h2>Multiple items, limit to 3</h2>
label="Select people"
></fast-picker>

<h2>Custom content templates</h2>
<fast-picker
id="customtemplatepicker"
default-selection=""
selection=""
options="apples,oranges,bananas,pears,pineapples,strawberries"
no-suggestions-text="No suggestions available"
suggestions-available-text="Suggestions available"
loading-text="Loading"
label="Select some things"
></fast-picker>

<div style="height: 400px; opacity: 0;"></div>
</fast-design-system-provider>
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,29 @@ export const pickerListItemStyles: (
:host([aria-selected="true"]) {
background: ${accentFillActive};
color: ${foregroundOnAccentActive};
}`.withBehaviors(forcedColorsStylesheetBehavior(css``));
}`.withBehaviors(
forcedColorsStylesheetBehavior(
css`
:host {
border-color: transparent;
forced-color-adjust: none;
color: ${SystemColors.ButtonText};
fill: currentcolor;
}
:host(:not([aria-selected="true"]):hover),
:host([aria-selected="true"]) {
background: ${SystemColors.Highlight};
color: ${SystemColors.HighlightText};
}
:host([disabled]),
:host([disabled]:not([aria-selected="true"]):hover) {
background: ${SystemColors.Canvas};
color: ${SystemColors.GrayText};
fill: currentcolor;
opacity: 1;
}
`
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ export const pickerListStyles: (
border-color: ${accentFillActive};
}
::focus-within[role="combobox"] {
:focus-within[role="combobox"] {
border-color: ${focusStrokeOuter};
box-shadow: 0 0 0 1px ${focusStrokeOuter} inset;
}
`.withBehaviors(
forcedColorsStylesheetBehavior(
css`
:hover[role="combobox"] {
[role="combobox"]:active {
background: ${SystemColors.Field};
border-color: ${SystemColors.Highlight};
}
:focus-within:enabled[role="combobox"] {
[role="combobox"]:focus-within {
border-color: ${SystemColors.Highlight};
box-shadow: 0 0 0 1px ${SystemColors.Highlight} inset;
}
input::placeholder {
input:placeholder {
color: ${SystemColors.GrayText};
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
forcedColorsStylesheetBehavior,
FoundationElementDefinition,
} from "@microsoft/fast-foundation";
import { SystemColors } from "@microsoft/fast-web-utilities";
import {
accentFillActive,
bodyFont,
Expand Down Expand Up @@ -66,4 +67,29 @@ export const pickerMenuOptionStyles: (
color: ${foregroundOnAccentActive};
}
`.withBehaviors(forcedColorsStylesheetBehavior(css``));
`.withBehaviors(
forcedColorsStylesheetBehavior(
css`
:host {
border-color: transparent;
forced-color-adjust: none;
color: ${SystemColors.ButtonText};
fill: currentcolor;
}
:host(:not([aria-selected="true"]):hover),
:host([aria-selected="true"]) {
background: ${SystemColors.Highlight};
color: ${SystemColors.HighlightText};
}
:host([disabled]),
:host([disabled]:not([aria-selected="true"]):hover) {
background: ${SystemColors.Canvas};
color: ${SystemColors.GrayText};
fill: currentcolor;
opacity: 1;
}
`
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const pickerMenuStyles: (
width: 100%;
max-height: 100%;
min-height: 58px;
box-sizing: border-box;
flex-direction: column;
overflow-y: auto;
overflow-x: hidden;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
import { html, ViewTemplate } from "@microsoft/fast-element";
import addons from "@storybook/addons";
import { STORY_RENDERED } from "@storybook/core-events";
import { Picker } from "@microsoft/fast-foundation";
import PickerTemplate from "./fixtures/picker.html";

const optionContentsTemplate: ViewTemplate = html`
<div style="background: blue">
${x => x.value}
</div>
`;

const itemContentsTemplate: ViewTemplate = html`
<div style="background: purple">
${x => x.value}
</div>
`;

addons.getChannel().addListener(STORY_RENDERED, (name: string) => {
if (name.toLowerCase().startsWith("picker")) {
const customTemplatePicker = document.getElementById(
"customtemplatepicker"
) as Picker;
customTemplatePicker.menuOptionContentsTemplate = optionContentsTemplate;
customTemplatePicker.listItemContentsTemplate = itemContentsTemplate;
}
});

export default {
title: "Picker",
};

export const Picker = () => PickerTemplate;
export const picker = () => PickerTemplate;
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export const pickerStyles: (
.top {
flex-direction: column-reverse;
}
`.withBehaviors(forcedColorsStylesheetBehavior(css``));
`;

0 comments on commit 7fb0932

Please sign in to comment.