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

refactor(components): menu item migrate to fast #636

Merged
merged 52 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8bf1d69
refactor(components): menu migrate to fast
yinonov Aug 29, 2022
6bcd7aa
progress
yinonov Sep 2, 2022
9256450
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 2, 2022
59b38bd
works
yinonov Sep 3, 2022
5dbd327
progressed
yinonov Sep 4, 2022
1a26820
mixed menu
yinonov Sep 4, 2022
e11b581
Change files
yinonov Sep 4, 2022
a9e365b
Update libs/components/src/lib/menu-item/index.ts
yinonov Sep 9, 2022
33bb08a
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 11, 2022
de02d09
Merge branch 'menu-migration-to-fast' of https://github.com/Vonage/vi…
yinonov Sep 11, 2022
8da4653
typo
yinonov Sep 11, 2022
1d38e94
exports
yinonov Sep 11, 2022
2146f78
info
yinonov Sep 11, 2022
99f1433
progress
yinonov Sep 11, 2022
00623fa
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 11, 2022
5c37e38
focus issue
yinonov Sep 11, 2022
67e7c37
ok
yinonov Sep 11, 2022
0e77add
need it
yinonov Sep 11, 2022
5d56cc9
grammer
yinonov Sep 13, 2022
a5fbb03
update
yinonov Sep 15, 2022
f8acf65
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 16, 2022
8fd1bb0
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 16, 2022
957e030
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 17, 2022
fd7ec18
done
yinonov Sep 18, 2022
39213af
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 18, 2022
4ad8235
snaps
yinonov Sep 18, 2022
8a95427
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 18, 2022
a802112
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 18, 2022
ef4c40a
resolve comments
yinonov Sep 18, 2022
ce0d5c9
ui tests
yinonov Sep 18, 2022
5a568fe
snapshots
yinonov Sep 18, 2022
4e41346
Merge branch 'main' into menu-migration-to-fast
yinonov Sep 18, 2022
0b4708d
stylelint
yinonov Sep 18, 2022
91e0d07
add coverage
yinonov Sep 18, 2022
806f891
icon unit test
yinonov Sep 19, 2022
500ae1a
increase coverage
yinonov Sep 19, 2022
fd40296
simple
yinonov Sep 19, 2022
0dfcbff
resolve comments
yinonov Sep 20, 2022
3e888f1
text test
yinonov Sep 20, 2022
315c1f1
done
yinonov Sep 20, 2022
44655d0
Merge branch 'main' into menu-migration-to-fast
yinonov Sep 20, 2022
e814449
update
yinonov Sep 20, 2022
05a30ec
1 line item
yinonov Sep 21, 2022
bea663a
snaps
yinonov Sep 21, 2022
2a1df33
max min
yinonov Sep 21, 2022
7ea7451
Merge remote-tracking branch 'origin/main' into menu-migration-to-fast
yinonov Sep 21, 2022
5ca1c42
stylelint
yinonov Sep 21, 2022
fade37a
typo
yinonov Sep 21, 2022
42eb9c2
@testing-library/dom
yinonov Sep 22, 2022
7ef7a8a
Merge branch 'main' into menu-migration-to-fast
yinonov Sep 22, 2022
9beb6f1
maybe now
yinonov Sep 22, 2022
9db0478
remove
yinonov Sep 22, 2022
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
524 changes: 267 additions & 257 deletions apps/docs/_data/components.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "menu migration to fast",
"packageName": "@vonage/vivid",
"email": "[email protected]",
"dependentChangeType": "patch"
}
21 changes: 11 additions & 10 deletions libs/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"./accordion": "./accordion",
"./accordion-item": "./accordion-item",
"./action-group": "./action-group",
"./avatar": "./avatar",
"./badge": "./badge",
"./banner": "./banner",
"./breadcrumb": "./breadcrumb",
Expand All @@ -26,25 +27,25 @@
"./calendar": "./calendar",
"./calendar-event": "./calendar-event",
"./card": "./card",
"./checkbox": "./checkbox",
"./elevation": "./elevation",
"./dialog": "./dialog",
"./divider": "./divider",
"./fab": "./fab",
"./icon": "./icon",
"./layout": "./layout",
"./menu": "./menu",
"./menu-item": "./menu-item",
"./nav": "./nav",
"./nav-disclosure": "./nav-disclosure",
"./nav-item": "./nav-item",
"./note": "./note",
"./popup": "./popup",
"./progress": "./progress",
"./progress-ring": "./progress-ring",
"./side-drawer": "./side-drawer",
"./nav": "./nav",
"./nav-item": "./nav-item",
"./nav-disclosure": "./nav-disclosure",
"./text-field": "./text-field",
"./tooltip": "./tooltip",
"./checkbox": "./checkbox",
"./dialog": "./dialog",
"./divider": "./divider",
"./menu": "./menu",
"./avatar": "./avatar",
"./text-area": "./text-area"
"./text-area": "./text-area",
"./tooltip": "./tooltip"
}
}
16 changes: 9 additions & 7 deletions libs/components/src/lib/components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './accordion';
export * from './accordion-item';
export * from './action-group';
export * from './avatar';
export * from './badge';
export * from './banner';
export * from './breadcrumb';
Expand All @@ -9,22 +10,23 @@ export * from './button';
export * from './calendar';
export * from './calendar-event';
export * from './card';
export * from './checkbox';
export * from './elevation';
export * from './dialog';
export * from './divider';
export * from './fab';
// export * from './focus';
export * from './icon';
export * from './layout';
export * from './menu';
export * from './menu-item';
export * from './nav';
export * from './nav-disclosure';
export * from './nav-item';
export * from './note';
export * from './popup';
export * from './progress';
export * from './progress-ring';
export * from './side-drawer';
export * from './nav';
export * from './nav-item';
export * from './nav-disclosure';
export * from './text-field';
// export * from './text-anchor';
export * from './text-area';
export * from './tooltip';
export * from './checkbox';
export * from './header';
106 changes: 106 additions & 0 deletions libs/components/src/lib/menu-item/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Menu Item

Represents a menu-item custom element.

```js
<script type="module">
import '@vonage/vivid/menu-item';
</script>
```

```html preview

<vwc-menu open>
<vwc-menu-item text="Menu item"></vwc-menu-item>
</vwc-menu>
```

## Members

### Role

set `role` to change the role of the menu item

- Type: `'menuitem'` | `'menuitemcheckbox'` | `'menuitemradio'`
- Default: `'menuitem'`

```html preview
<style>
html {
block-size: 360px;
}
</style>

<vwc-menu open>
<vwc-menu-item role="menuitem" text="Menu item 1"></vwc-menu-item>
<vwc-menu-item role="menuitem" text="Menu item 2"></vwc-menu-item>
<vwc-divider></vwc-divider>
<vwc-menu-item role="menuitemcheckbox" text="Checkbox 1"></vwc-menu-item>
<vwc-menu-item role="menuitemcheckbox" text="Checkbox 2"></vwc-menu-item>
<vwc-divider></vwc-divider>
<vwc-menu-item role="menuitemradio" text="Radio 1.1"></vwc-menu-item>
<vwc-menu-item role="menuitemradio" text="Radio 1.2"></vwc-menu-item>
<vwc-divider></vwc-divider>
<vwc-menu-item role="menuitemradio" text="Radio 2.1"></vwc-menu-item>
<vwc-menu-item role="menuitemradio" text="Radio 2.2"></vwc-menu-item>
</vwc-menu>
```

### Icon

Use `icon` to set an icon to the nav item.
View list of available icon at the [vivid icons gallery](https://icons.vivid.vonage.com).

Note: Icon, by its own, doesn't make a discernible text. An `aria-label`, `aria-labelledby` or `title` must be provided to ensure that the user can understand the nav item's purpose.

- Type: `string`
- Default: `undefined`

```html preview
<vwc-menu open>
<vwc-menu-item icon="file-pdf-line" text="Export to PDF"></vwc-menu-item>
</vwc-menu>
```

### Checked

The checked value of the element (if role is set to `'menuitemcheckbox'`).

- Type: `boolean`
- Default: `false`

```html preview
<vwc-menu open>
<vwc-menu-item role="menuitemcheckbox" checked text="Checked Menu item"></vwc-menu-item>
</vwc-menu>
```

### Disabled

The disabled state of the element

- Type: `boolean`
- Default: `false`

```html preview
<vwc-menu open>
<vwc-menu-item disabled text="Disabled Menu item"></vwc-menu-item>
</vwc-menu>
```

<!-- ### Expanded

The expanded state of the element

- Type: `boolean`
- Default: `false` -->

## Events

### Expanded Change

Fires a custom 'expanded-change' event when the expanded state changes

### Change

Fires a custom 'change' event when a non-submenu item with a role of `menuitemcheckbox`, `menuitemradio`, or `menuitem` is invoked
16 changes: 16 additions & 0 deletions libs/components/src/lib/menu-item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import '../icon';

import type { MenuItemOptions } from '@microsoft/fast-foundation';
import { designSystem } from '../../shared/design-system';
import styles from './menu-item.scss';

import { MenuItem } from './menu-item';
import { MenuItemTemplate as template } from './menu-item.template';

export const vividMenuItem = MenuItem.compose<MenuItemOptions>({
baseName: 'menu-item',
template: template as any,
styles
});

designSystem.register(vividMenuItem());
75 changes: 75 additions & 0 deletions libs/components/src/lib/menu-item/menu-item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@use '../../../../../dist/libs/tokens/scss/constants' as constants;

@use '../../../../shared/src/lib/sass/mixins/connotation/config' with (
$connotations: accent,
$shades: primary faint soft,
$default: accent,
);
@use '../../../../shared/src/lib/sass/mixins/connotation' as connotation;

@use '../../../../shared/src/lib/sass/mixins/appearance/config' as appearance-config with (
$appearances: ghost,
$states: idle hover active selected disabled,
$default: ghost,
);
@use '../../../../shared/src/lib/sass/mixins/appearance' as appearance;

@supports selector(:focus-visible) {
:host(:focus) {
outline: none;
}
}

.base {
$min-block-size: 40px;
$gap: 8px;

@include appearance.appearance;
@include connotation.connotation;

position: relative;
display: flex;
box-sizing: border-box;
align-items: center;
background-color: var(#{appearance.get-appearance-token(fill)});
block-size: $min-block-size;
Copy link
Contributor

Choose a reason for hiding this comment

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

if there's break-word than we cant have a block-size. maybe min-block-size?
image

in vivid-2 we do not break lines, but have ellipses

box-shadow: inset 0 0 0 1px var(#{appearance.get-appearance-token(outline)});
color: var(#{appearance.get-appearance-token(text)});
font: var(#{constants.$vvd-font-base});
gap: $gap;
inline-size: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is great - but doesn't get the width that is set on menu....
The menu width + line break is not working well :(

padding-inline: $gap;

@supports(user-select: none) {
user-select: none;
}

&:not(.disabled) {
cursor: pointer;
}

&.disabled {
cursor: not-allowed;
}
}

.focus-indicator {
border-radius: 6px;
:host(:not(:focus-visible)) & {
display: none;
}
}

.icon {
font-size: 20px;

.base:not(.item-checkbox, .item-radio) & {
color: var(#{constants.$vvd-color-neutral-600});
}
}

.text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Loading