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

Adds Menu and MenuItem as new web components #26765

Merged
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
495ebcd
menu init
brianchristopherbrady Feb 2, 2023
584ff04
updates docs
brianchristopherbrady Feb 2, 2023
052a5c4
menu init
brianchristopherbrady Feb 3, 2023
b238618
menu item init
brianchristopherbrady Feb 3, 2023
f15b09e
registers menu-item
brianchristopherbrady Feb 3, 2023
05feee7
adds some menu styles
brianchristopherbrady Feb 3, 2023
39930bd
adds default menu item icons
brianchristopherbrady Feb 6, 2023
37a69ce
adds menu stories
brianchristopherbrady Feb 8, 2023
485d8dd
updates default menu icons
brianchristopherbrady Feb 8, 2023
15d29c4
styles menu and menu item
brianchristopherbrady Feb 8, 2023
29090b3
updates readme
brianchristopherbrady Feb 8, 2023
2465f7b
swaps part for class css
brianchristopherbrady Feb 8, 2023
d9725ea
removes dead code
brianchristopherbrady Feb 8, 2023
6ee366e
adds menu and menu item to package.json
brianchristopherbrady Feb 8, 2023
5b98085
removes dead code
brianchristopherbrady Feb 8, 2023
811da97
updates menu styles
brianchristopherbrady Feb 8, 2023
5348418
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Feb 8, 2023
dbfd608
yarn change
brianchristopherbrady Feb 8, 2023
534141e
adds menu header
brianchristopherbrady Feb 9, 2023
9c1bb70
updates jsdocs
brianchristopherbrady Feb 9, 2023
ab5f353
removes dead file
brianchristopherbrady Feb 9, 2023
3d5cded
removes dead code
brianchristopherbrady Feb 10, 2023
208ba81
removes split button styling
brianchristopherbrady Feb 10, 2023
b860811
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Feb 10, 2023
9488f79
adds display helper
brianchristopherbrady Feb 13, 2023
ff3f62c
api report
brianchristopherbrady Feb 14, 2023
81638aa
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Feb 14, 2023
2f3e908
merge web-components-v3
brianchristopherbrady Feb 14, 2023
eaae97d
flattens menu and menu item directories
brianchristopherbrady Feb 14, 2023
c4121a3
removes element specification from slotted selector
brianchristopherbrady Feb 14, 2023
9da003b
formatting
brianchristopherbrady Feb 14, 2023
177f05d
optimizes styles
brianchristopherbrady Feb 15, 2023
13ee51d
optmizes styles
brianchristopherbrady Feb 15, 2023
cd59148
updates disabled css selector to bool
brianchristopherbrady Feb 15, 2023
0638b67
removes dead code
brianchristopherbrady Feb 15, 2023
493a906
consolidates menu docs into one story
brianchristopherbrady Feb 15, 2023
3199788
updates menu storybook content
brianchristopherbrady Feb 15, 2023
dceaa87
optimizes styling
brianchristopherbrady Feb 15, 2023
825a324
revert api-report
brianchristopherbrady Feb 15, 2023
3f95049
updates disabled pseudo selector
brianchristopherbrady Feb 15, 2023
ac429a1
fixes disabled state
brianchristopherbrady Feb 15, 2023
97f3d97
fixes css syntax error
brianchristopherbrady Feb 15, 2023
704575b
updates storybook content
brianchristopherbrady Feb 15, 2023
17be9d9
updates storybook copy for consistency
brianchristopherbrady Feb 15, 2023
cc71898
merge master
brianchristopherbrady Feb 21, 2023
5d04627
revert api report
brianchristopherbrady Feb 21, 2023
1a69838
updates yarn change message
brianchristopherbrady Feb 21, 2023
87125ec
maps component to MenuList rather than Menu
brianchristopherbrady Feb 21, 2023
b050a6a
fixes focus state
brianchristopherbrady Feb 21, 2023
de54feb
updates styles
brianchristopherbrady Feb 21, 2023
fe5c09c
divides accordion and accordion item readme
brianchristopherbrady Feb 21, 2023
0b4d5ef
removes dead imports
brianchristopherbrady Feb 22, 2023
08de7d1
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Feb 23, 2023
929597f
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Feb 23, 2023
7d3aaa4
fixes submenu positioning
brianchristopherbrady Feb 23, 2023
4eebbf5
adds styles for icon alignment
brianchristopherbrady Feb 25, 2023
3a63ee4
reverts Menu component name
brianchristopherbrady Feb 25, 2023
b13f6bd
cleans up storybook
brianchristopherbrady Feb 25, 2023
8255212
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Feb 27, 2023
2d8796e
merge
brianchristopherbrady Feb 27, 2023
24d7895
dynamically set the menu item icon attribute when icons is true for m…
chrisdholt Feb 27, 2023
f6a0d93
updates Menu styles
brianchristopherbrady Feb 27, 2023
1c8998d
updates icon alignment styles and docs
brianchristopherbrady Feb 27, 2023
56282af
updates menu docs
brianchristopherbrady Feb 27, 2023
3a5370e
adds checkmarks attribute and styles menu items
brianchristopherbrady Mar 1, 2023
90ff4d7
adds conditional styling for when icons are present
brianchristopherbrady Mar 2, 2023
a0ae4c7
updates Menu and MenuItem docs
brianchristopherbrady Mar 2, 2023
1ae068c
updates deltas in docs
brianchristopherbrady Mar 2, 2023
5a07e7c
updates docs
brianchristopherbrady Mar 2, 2023
7c54b52
merge
brianchristopherbrady Mar 2, 2023
65eb87c
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Mar 2, 2023
8c5a1d1
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Mar 7, 2023
b24f657
optimizes styles
brianchristopherbrady Mar 10, 2023
57d11c5
optimizes css
brianchristopherbrady Mar 10, 2023
49952b6
Merge branch 'user/brianbrady/web-component-menu' of https://github.c…
brianchristopherbrady Mar 10, 2023
fd1bccb
optimizes css
brianchristopherbrady Mar 10, 2023
88b06a8
optimizes css
brianchristopherbrady Mar 10, 2023
d79fab8
reverts json export
brianchristopherbrady Mar 14, 2023
5844949
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Mar 21, 2023
c34ad00
working (#27293)
eljefe223 Mar 22, 2023
92eceb9
optimizes styles
brianchristopherbrady Mar 22, 2023
22009f7
adds docs to menu.ts
brianchristopherbrady Mar 22, 2023
e8ad6b6
updates menu logic for readability
brianchristopherbrady Mar 24, 2023
2c9bfc1
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Mar 27, 2023
a5b9fd3
merge
brianchristopherbrady Mar 27, 2023
956eee8
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Mar 28, 2023
2946183
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Mar 29, 2023
550d1ab
menu: fixes style syntax error
brianchristopherbrady Mar 30, 2023
bd5fb72
menu: consolidates styles
brianchristopherbrady Mar 31, 2023
e7b2c10
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Mar 31, 2023
e5238d7
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Apr 4, 2023
cd2d9b7
menu: updates styling
brianchristopherbrady Apr 5, 2023
9048956
menu: updates styling
brianchristopherbrady Apr 5, 2023
559127a
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Apr 5, 2023
e8d63a1
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Apr 6, 2023
84d5738
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Apr 6, 2023
543453a
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Apr 6, 2023
464e97d
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Apr 7, 2023
e683381
Merge branch 'web-components-v3' into user/brianbrady/web-component-menu
brianchristopherbrady Apr 13, 2023
b84e6e9
Merge branch 'web-components-v3' of https://github.com/microsoft/flue…
brianchristopherbrady Apr 13, 2023
ab5b7ca
menu: merge wc3
brianchristopherbrady Apr 13, 2023
e31be49
yarn change
brianchristopherbrady Apr 18, 2023
96e4870
Merge branch 'user/brianbrady/web-component-menu' of https://github.c…
brianchristopherbrady Apr 18, 2023
1e1621e
menulist, menuitem: changes component name to MenuList
brianchristopherbrady Apr 18, 2023
abebe36
menulist, menuitem, updates readme
brianchristopherbrady Apr 18, 2023
d7f4122
menu, menuitem: fixes circular dep
brianchristopherbrady Apr 18, 2023
d9b27cf
menu, menuitem: alphabetize index.js
brianchristopherbrady Apr 18, 2023
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,7 @@
{
"type": "prerelease",
"comment": "feat(menu): Add menu and menu-item web components",
"packageName": "@fluentui/web-components",
"email": "brianbrady@microsoft.com",
"dependentChangeType": "patch"
}
14 changes: 11 additions & 3 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@
"types": "./dist/esm/image/define.d.ts",
"default": "./dist/esm/image/define.js"
},
"./text": {
"types": "./dist/esm/text/define.d.ts",
"default": "./dist/esm/text/define.js"
"./menu": {
"types": "./dist/esm/menu/define.d.ts",
"default": "./dist/esm/menu/define.js"
},
"./menu-item": {
"types": "./dist/esm/menu-item/define.d.ts",
"default": "./dist/esm/menu-item/define.js"
},
"./progress-bar": {
"types": "./dist/esm/progress-bar/define.d.ts",
Expand All @@ -71,6 +75,10 @@
"./switch": {
"types": "./dist/esm/switch/define.d.ts",
"default": "./dist/esm/switch/define.js"
},
"./text": {
"types": "./dist/esm/text/define.d.ts",
"default": "./dist/esm/text/define.js"
}
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions packages/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export * from './badge/index.js';
export * from './counter-badge/index.js';
export * from './divider/index.js';
export * from './image/index.js';
export * from './menu/index.js';
export * from './menu-item/index.js';
export * from './progress-bar/index.js';
export * from './slider/index.js';
export * from './spinner/index.js';
Expand Down
126 changes: 126 additions & 0 deletions packages/web-components/src/menu-item/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Menu Item

Menu list item options displayed in a Menu component. They are invoked when users interact with a button, action, or other control.

<hr />

<br />

**Remaining work items**

1. Ensure divider component is styled appropriately in the context of a Menu
2. Create support for menu item "grouping"
3. Split button variation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are still valid, create tracking issues, with Fluent UI WC (v3) tag.

fwiw, FAST already supports grouping by using a divider item between groups. Do we want to achieve parity with FUIR9 which uses name for the groups or are we OK with the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 (divider). This has been confirmed the divider is being used in the storybook

Issue #27042: Menu Closing Behavior and Support for Menu Grouping, Header, and Split Button to MenuItem Component


<br />
<hr />
<br />

## Design Spec

[Link to Menu Item Design Spec in Figma](https://www.figma.com/file/jFWrkFq61GDdOhPlsz6AtX/Menu?node-id=1528%3A5102&t=XtW4laeEzgVFIl1E-0)

<br />
<hr />
<br />

## Engineering Spec

Fluent WC3 Menu extends from the FAST Menu [FAST Menu Item](https://explore.fast.design/components/fast-menu) and is intended to be as close to the Fluent UI React 9 Menu implementation as possible. However, due to the nature of web components there will not be 100% parity between the two.

<br />

### Inputs

- `role` - an enum representing the menu items' role
- `menuitem`
- `menuitemcheckbox`
- `menuitemradio`
- `disabled` - the menu item is disabled
- `checked` - sets the checked value for menuitemcheckbox or menuitemradio items

### Outputs

- none

### Events

- `click` (event) - event for when the item has been clicked or invoked via keyboard
- `change` (event) - event for when the item has been clicked or invoked via keyboard, and will be prevented if the menu item is disabled
- `expanded-change` (event) - event for when the item has been expanded or collapsed

### Slots

- `before` - slot which precedes content
- `default` - slot for the content (the default slot for the item)
- `after` - slot which comes after content
- `submenu` - the slot used to generate a submenu
- `radio-indicator` - slot for radio item selection indicator
- `checkbox-indicator` - slot for the checkbox selection indicator
- `expand-collapse-glyph` - slot for the expand/collapse glyph for nested menus

### CSS Variables

- `borderRadiusMedium`
- `colorCompoundBrandForeground1Hover`
- `colorCompoundBrandForeground1Pressed`
- `colorNeutralBackground1`
- `colorNeutralBackground1Hover`
- `colorNeutralBackground1Pressed`
- `colorNeutralBackgroundDisabled`
- `colorNeutralForeground2`
- `colorNeutralForeground2Hover`
- `colorNeutralForeground2Pressed`
- `colorNeutralForeground3`
- `colorNeutralForegroundDisabled`
- `colorNeutralStrokeDisabled`
- `fontFamilyBase`
- `fontSizeBase200`
- `fontSizeBase300`
- `fontWeightRegular`
- `fontWeightSemibold`
- `lineHeightBase200`
- `lineHeightBase300`

<br />
<hr />
<br />

## Accessibility

<br />

**ARIA Attributes**

| Attribute | Options | Description |
| ------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| aria-checked | boolean |
| aria-disabled | boolean | indicates that the element is perceivable but disabled, so it is not editable or otherwise operable |
| role | `menuitem` \| `menuitemcheckbox` \| `menuitemradio` | an enum representing the menu items' role |

<hr />
<br />

## Preparation

<br />

### **Fluent Web Component v3 v.s Fluent React 9**

Due to the nature of Web Components there will not be 100% parity between component implementation in Fluent UI React v9 and Fluent Web Components v3.

<br />

**Component, Slot, and Attribute Mapping**
Component, Slot, or Attribute | Fluent React v9 | Fluent Web Components v3 |
---------------------------------| ---------------------| ---------------------------|
Menu | `<Menu>` | `<fluent-menu>` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fluent-menu matches MenuList not Menu.
TBH, I still would rather see this being named fluent-menu-list.

Menu item |`<MenuItem>` | `<fluent-menu-item>` |
Menu item with radio | `<MenuItemRadio>` | `<fluent-menu-item role="menuitemcheckbox">..` |
Menu item with checkbox | `<MenuItemCheckbox>` | `<fluent-menu-item role="menuitemcheckbox">..` |
Icons | `<MenuItem icon={<MyIcon />}>` | `<slot name ="start">..` <br /> `<slot name="end">..`|
Menu group header | `<MenuGroupHeader>` | `<fluent-menu-item class="header">`|

**Additional Deltas**

In order for icons to render with appropriate styles the `icons` attribute must be present on the Menu.
4 changes: 4 additions & 0 deletions packages/web-components/src/menu-item/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './menu-item.definition.js';

definition.define(FluentDesignSystem.registry);
4 changes: 4 additions & 0 deletions packages/web-components/src/menu-item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './menu-item.js';
export { template as MenuItemTemplate } from './menu-item.template.js';
export { styles as MenuItemStyles } from './menu-item.styles.js';
export { definition as MenuItemDefinition } from './menu-item.definition.js';
19 changes: 19 additions & 0 deletions packages/web-components/src/menu-item/menu-item.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { MenuItem } from './menu-item.js';
import { styles } from './menu-item.styles.js';
import { template } from './menu-item.template.js';

/**
* The Fluent Menu Item Element. Implements {@link @microsoft/fast-foundation#MenuItem },
* {@link @microsoft/fast-foundation#menuItemTemplate}
*
*
* @public
* @remarks
* HTML Element: <fluent-menu-item>
*/
export const definition = MenuItem.compose({
name: `${FluentDesignSystem.prefix}-menu-item`,
template,
styles,
});
Loading