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: adds select and related styles #16021

Merged
merged 18 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8912d32
Merge pull request #1 from microsoft/master
eljefe223 Sep 17, 2020
7f2afc9
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 18, 2020
b97a477
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
1d450b7
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
abc1aac
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Sep 23, 2020
f40c04e
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 9, 2020
57d97a5
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 16, 2020
82b70f4
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 16, 2020
c67924a
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 17, 2020
937ab9e
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 20, 2020
204c744
Merge branch 'master' of https://github.com/microsoft/fluentui
eljefe223 Nov 20, 2020
1151272
feat: add select and related styles
eljefe223 Nov 20, 2020
2736677
Change files
eljefe223 Nov 20, 2020
2258783
fixed styles adds exports
eljefe223 Nov 20, 2020
7fd4dda
generated api report
eljefe223 Nov 20, 2020
ca95845
added styling improvements
eljefe223 Nov 20, 2020
5f24a7f
added updated HC styles
eljefe223 Nov 21, 2020
c03fef7
fixed HC work
eljefe223 Nov 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "feat: add select and related styles",
"packageName": "@fluentui/web-components",
"email": "jes@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-11-20T05:47:55.207Z"
}
24 changes: 24 additions & 0 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import { Direction } from '@microsoft/fast-web-utilities';
import { Divider } from '@microsoft/fast-foundation';
import { ElementStyles } from '@microsoft/fast-element';
import { Flipper } from '@microsoft/fast-foundation';
import { Listbox } from '@microsoft/fast-foundation';
import { ListboxOption } from '@microsoft/fast-foundation';
import { Menu } from '@microsoft/fast-foundation';
import { MenuItem } from '@microsoft/fast-foundation';
import { Radio } from '@microsoft/fast-foundation';
import { RadioGroup } from '@microsoft/fast-foundation';
import { Select } from '@microsoft/fast-foundation';
import { Skeleton } from '@microsoft/fast-foundation';
import { Slider } from '@microsoft/fast-foundation';
import { SliderLabel } from '@microsoft/fast-foundation';
Expand Down Expand Up @@ -363,6 +366,10 @@ export class FluentDivider extends Divider {
export class FluentFlipper extends Flipper {
}

// @public
export class FluentListbox extends Listbox {
}

// @public
export class FluentMenu extends Menu {
}
Expand All @@ -371,6 +378,10 @@ export class FluentMenu extends Menu {
export class FluentMenuItem extends MenuItem {
}

// @public
export class FluentOption extends ListboxOption {
}

// @public
export class FluentProgress extends BaseProgress {
}
Expand All @@ -387,6 +398,10 @@ export class FluentRadio extends Radio {
export class FluentRadioGroup extends RadioGroup {
}

// @public
export class FluentSelect extends Select {
}

// @public
export class FluentSkeleton extends Skeleton {
}
Expand Down Expand Up @@ -460,6 +475,9 @@ export const inlineStartBehavior: CSSCustomPropertyBehavior;
// @internal (undocumented)
export const LightweightButtonStyles: ElementStyles;

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

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

Expand Down Expand Up @@ -592,6 +610,9 @@ export const neutralOutlineHoverBehavior: CSSCustomPropertyBehavior;
// @public
export const neutralOutlineRestBehavior: CSSCustomPropertyBehavior;

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

// Warning: (ae-internal-missing-underscore) The name "OutlineButtonStyles" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
Expand All @@ -612,6 +633,9 @@ export const RadioGroupStyles: import("@microsoft/fast-element").ElementStyles;
// @public
export const RadioStyles: import("@microsoft/fast-element").ElementStyles;

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

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

Expand Down
3 changes: 3 additions & 0 deletions packages/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export * from './design-system-provider/';
export * from './dialog/';
export * from './divider/';
export * from './flipper/';
export * from './listbox';
export * from './listbox-option';
export * from './menu/';
export * from './menu-item/';
export * from './progress/';
export * from './radio/';
export * from './radio-group/';
export * from './select';
export * from './skeleton/';
export * from './slider/';
export * from './slider-label/';
Expand Down
35 changes: 35 additions & 0 deletions packages/web-components/src/listbox-option/fixtures/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<fluent-design-system-provider use-defaults>
<h1>Option</h1>

<h2>Defaults</h2>
<fluent-option>
Text content is the value when the value attribute is absent.
</fluent-option>

<fluent-option value="Value content loses">
Even when the value attribute and text are both present, this text should be displayed.
</fluent-option>

<fluent-option value="This option has no text content."></fluent-option>

<h2>Disabled</h2>
<fluent-option disabled>This option is disabled.</fluent-option>

<h2>Selected</h2>
<fluent-option selected>This option is selected by default.</fluent-option>

<h2>Slots</h2>
<fluent-option value="1">
<svg slot="start" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path
d="M6.5 7.7h-1v-1h1v1zm4.1 0h-1v-1h1v1zm4.1-1v2.1h-1v2.6l-.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luent-option>
</fluent-design-system-provider>
25 changes: 25 additions & 0 deletions packages/web-components/src/listbox-option/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { customElement } from '@microsoft/fast-element';
import { ListboxOption, ListboxOptionTemplate as template } from '@microsoft/fast-foundation';
import { OptionStyles as styles } from './listbox-option.styles';

/**
* The Fluent ListboxOption Element. Implements {@link @microsoft/fast-foundation#ListboxOption},
* {@link @microsoft/fast-foundation#ListboxOptionTemplate}
*
*
* @public
* @remarks
* HTML Element: \<fluent-option\>
*/
@customElement({
name: 'fluent-option',
template,
styles,
})
export class FluentOption extends ListboxOption {}

/**
* Styles for Option
* @public
*/
export const OptionStyles = styles;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FluentDesignSystemProvider } from '../design-system-provider';
import ListboxOptionTemplate from './fixtures/base.html';
import { FluentOption } from './';

FluentOption;
FluentDesignSystemProvider;

export default {
title: 'ListboxOption',
};

export const ListboxOption = (): string => ListboxOptionTemplate;
142 changes: 142 additions & 0 deletions packages/web-components/src/listbox-option/listbox-option.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { css } from '@microsoft/fast-element';
import { disabledCursor, display, focusVisible, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import { SystemColors } from '@microsoft/fast-web-utilities';
import {
accentFillActiveBehavior,
accentFillHoverBehavior,
accentFillSelectedBehavior,
accentForegroundCutRestBehavior,
neutralFillHoverBehavior,
neutralFillStealthHoverBehavior,
neutralFillStealthRestBehavior,
neutralFillStealthSelectedBehavior,
neutralFocusBehavior,
neutralFocusInnerAccentBehavior,
neutralForegroundHoverBehavior,
neutralForegroundRestBehavior,
neutralLayerL1Behavior,
} from '../styles';
import { heightNumber } from '../styles/size';

export const OptionStyles = css`
${display('inline-flex')} :host {
font-family: var(--body-font);
border-radius: calc(var(--corner-radius) * 1px);
border: calc(var(--focus-outline-width) * 1px) solid transparent;
box-sizing: border-box;
color: ${neutralForegroundRestBehavior.var};
cursor: pointer;
fill: currentcolor;
font-size: var(--type-ramp-base-font-size);
height: calc(${heightNumber} * 1px);
line-height: var(--type-ramp-base-line-height);
margin: 0 calc(var(--design-unit) * 1px);
outline: none;
overflow: hidden;
align-items: center;
padding: 0 calc(var(--design-unit) * 2.25px);
user-select: none;
white-space: nowrap;
}

:host(:${focusVisible}) {
box-shadow: 0 0 0 calc(var(--focus-outline-width) * 1px) inset ${neutralFocusInnerAccentBehavior.var};
border-color: ${neutralFocusBehavior.var};
background: ${accentFillHoverBehavior.var};
color: ${accentForegroundCutRestBehavior.var};
}

:host([aria-selected="true"]) {
background: ${accentFillHoverBehavior.var};
color: ${accentForegroundCutRestBehavior.var};
}

:host(:active) {
background: ${accentFillActiveBehavior.var};
color: ${accentForegroundCutRestBehavior.var};
}

:host(:not([aria-selected="true"]):hover) {
background: ${neutralFillHoverBehavior.var};
color: ${neutralForegroundHoverBehavior.var};
}

:host(:not([aria-selected="true"]):active) {
background: ${neutralFillHoverBehavior.var};
color: ${neutralForegroundHoverBehavior.var};
}

:host([disabled]) {
cursor: ${disabledCursor};
opacity: var(--disabled-opacity);
}

:host([disabled]:hover) {
background-color: inherit;
}

.content {
grid-column-start: 2;
justify-self: start;
overflow: hidden;
text-overflow: ellipsis;
}

.start,
.end,
::slotted(svg) {
display: flex;
}

::slotted(svg) {
${/* Glyph size and margin-left is temporary - replace when adaptive typography is figured out */ ''}
height: calc(var(--design-unit) * 4px);
width: calc(var(--design-unit) * 4px);
}

::slotted([slot="end"]) {
margin-inline-start: 1ch;
}

::slotted([slot="start"]) {
margin-inline-end: 1ch;
}

`.withBehaviors(
accentFillActiveBehavior,
accentFillHoverBehavior,
accentFillSelectedBehavior,
accentForegroundCutRestBehavior,
forcedColorsStylesheetBehavior(
css`
:host {
eljefe223 marked this conversation as resolved.
Show resolved Hide resolved
border-color: transparent;
color: ${SystemColors.ButtonText};
forced-color-adjust: none;
}

: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;
}
`,
),
neutralFillHoverBehavior,
neutralFillStealthHoverBehavior,
neutralFillStealthRestBehavior,
neutralFillStealthSelectedBehavior,
neutralFocusBehavior,
neutralFocusInnerAccentBehavior,
neutralForegroundHoverBehavior,
neutralForegroundRestBehavior,
neutralLayerL1Behavior,
);
64 changes: 64 additions & 0 deletions packages/web-components/src/listbox/fixtures/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<fluent-design-system-provider use-defaults>
<h1>Listbox</h1>
<h2>Default</h2>
<fluent-listbox>
<fluent-option>This option has no value</fluent-option>
<fluent-option disabled>This option is disabled</fluent-option>
<fluent-option value="hi">This option has a value</fluent-option>
<fluent-option selected>This option is selected by default</fluent-option>
</fluent-listbox>

<h2>Long list</h2>
<fluent-listbox>
<fluent-option value="AL">Alabama</fluent-option>
<fluent-option value="AK">Alaska</fluent-option>
<fluent-option value="AZ">Arizona</fluent-option>
<fluent-option value="AR">Arkansas</fluent-option>
<fluent-option value="CA">California</fluent-option>
<fluent-option value="CO">Colorado</fluent-option>
<fluent-option value="CT">Connecticut</fluent-option>
<fluent-option value="DE">Delaware</fluent-option>
<fluent-option value="FL">Florida</fluent-option>
<fluent-option value="GA">Georgia</fluent-option>
<fluent-option value="HI">Hawaii</fluent-option>
<fluent-option value="ID">Idaho</fluent-option>
<fluent-option value="IL">Illinois</fluent-option>
<fluent-option value="IN">Indiana</fluent-option>
<fluent-option value="IA">Iowa</fluent-option>
<fluent-option value="KS">Kansas</fluent-option>
<fluent-option value="KY">Kentucky</fluent-option>
<fluent-option value="LA">Louisiana</fluent-option>
<fluent-option value="ME">Maine</fluent-option>
<fluent-option value="MD">Maryland</fluent-option>
<fluent-option value="MA">Massachussets</fluent-option>
<fluent-option value="MI">Michigain</fluent-option>
<fluent-option value="MN">Minnesota</fluent-option>
<fluent-option value="MS">Mississippi</fluent-option>
<fluent-option value="MO">Missouri</fluent-option>
<fluent-option value="MT">Montana</fluent-option>
<fluent-option value="NE">Nebraska</fluent-option>
<fluent-option value="NV">Nevada</fluent-option>
<fluent-option value="NH">New Hampshire</fluent-option>
<fluent-option value="NJ">New Jersey</fluent-option>
<fluent-option value="NM">New Mexico</fluent-option>
<fluent-option value="NY">New York</fluent-option>
<fluent-option value="NC">North Carolina</fluent-option>
<fluent-option value="ND">North Dakota</fluent-option>
<fluent-option value="OH">Ohio</fluent-option>
<fluent-option value="OK">Oklahoma</fluent-option>
<fluent-option value="OR">Oregon</fluent-option>
<fluent-option value="PA">Pennsylvania</fluent-option>
<fluent-option value="RI">Rhode Island</fluent-option>
<fluent-option value="SC">South Carolina</fluent-option>
<fluent-option value="SD">South Dakota</fluent-option>
<fluent-option value="TX">Texas</fluent-option>
<fluent-option value="TN">Tennessee</fluent-option>
<fluent-option value="UT">Utah</fluent-option>
<fluent-option value="VT">Vermont</fluent-option>
<fluent-option value="VA">Virginia</fluent-option>
<fluent-option value="WA">Washington</fluent-option>
<fluent-option value="WI">Wisconsin</fluent-option>
<fluent-option value="WV">West Virginia</fluent-option>
<fluent-option value="WY">Wyoming</fluent-option>
</fluent-listbox>
</fluent-design-system-provider>
Loading