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

Add new Menu Component #2933

Merged
merged 138 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
7b79502
feat: add kirby-floating directive
NillerW Jan 23, 2023
0cae35b
chore: made floatingdirective accessible for programical use
NillerW Jan 24, 2023
808da47
chore: fix bad import
NillerW Jan 24, 2023
47b5a80
chore: seperate floatDirective into own PR
NillerW Jan 24, 2023
e0ac01d
feat: initial work for actionlist
NillerW Jan 26, 2023
10df911
chore: updated package-lock
NillerW Jan 26, 2023
0764ef5
chore: updated package-lock
NillerW Jan 26, 2023
c874f58
chore: updated package-lock
NillerW Jan 27, 2023
aac98a3
feat: add isDisabled input to floating directive
NillerW Jan 27, 2023
6805f01
chore: run install to properly symlink core package
RasmusKjeldgaard Jan 27, 2023
00fb04d
Merge branch 'develop' into component/2744-popup-component
RasmusKjeldgaard Jan 27, 2023
dc218ec
chore: sync package lock
RasmusKjeldgaard Jan 27, 2023
07c6a9b
chore: cherry pick package-lock from working branch
RasmusKjeldgaard Jan 27, 2023
6909f62
feat: add focus trigger. Add 'close on' functionality'
NillerW Feb 2, 2023
5bf9447
merge: component/2744-popup-component into branch
NillerW Feb 2, 2023
d916f48
feat: action list
NillerW Feb 9, 2023
756cbb8
chore: move init of placement variable
NillerW Feb 9, 2023
fa24ff5
chore: add strategy as an input
NillerW Feb 9, 2023
c5000c7
chore: change triggers to only allow for array
NillerW Feb 9, 2023
7532e3d
chore: add documentation for inputs
NillerW Feb 9, 2023
f2d8d8b
chore: merge develop into branch
NillerW Feb 21, 2023
cec22b2
chore: move location of action-list
NillerW Feb 21, 2023
147430b
chore: rename action-list to menu
NillerW Feb 22, 2023
dde9a32
feat: add option for user provided button
NillerW Feb 23, 2023
1e7700c
chore: update floating directive
NillerW Feb 27, 2023
f7e976d
chore: update floating directive
NillerW Feb 27, 2023
658e17c
chore: add tests for floating directive
NillerW Mar 6, 2023
2614ce3
chore: merge with develop
NillerW Mar 6, 2023
89b2537
chore: add floating and portal directives to path
NillerW Mar 6, 2023
7299273
chore: secondary entries
NillerW Mar 6, 2023
f9ce524
chore secondary entry
NillerW Mar 6, 2023
5ca32c5
chore: added handling for autoUpdate when reference changes
NillerW Mar 6, 2023
43c0ed9
Merge branch 'develop' into component/2744-popup-component
NillerW Mar 7, 2023
2d2bfe0
feat: add option for custom button for menu
NillerW Mar 7, 2023
093d392
Merge branch 'develop' into component/2744-popup-component
NillerW Mar 7, 2023
ba5365c
Merge branch 'component/2744-popup-component' of gh_basic:kirbydesign…
NillerW Mar 7, 2023
689b54f
chore: merge with floating directive branch
NillerW Mar 7, 2023
c4e9962
chore: merge with develop
NillerW Mar 7, 2023
192b42d
chore: merge with develop
NillerW Mar 8, 2023
8c0217c
chore: clean
NillerW Mar 8, 2023
a829f0f
chore: clean up
NillerW Mar 8, 2023
0c5ca11
chore: fix merge mistake
NillerW Mar 8, 2023
8471451
chore: add secondart entry
NillerW Mar 8, 2023
5f38ae0
chore: fix template issue
NillerW Mar 8, 2023
fc2345a
fix: import
NillerW Mar 8, 2023
2ac4396
fix: typo
NillerW Mar 8, 2023
a075c64
fix: template issue
NillerW Mar 8, 2023
7c7069e
fix: review comments
NillerW Mar 9, 2023
a5431da
chore: change default size of offset
NillerW Mar 9, 2023
45a9fcf
fix: limit document event listen to open menu. Fix document ref not b…
NillerW Mar 9, 2023
5eb0da4
Merge branch 'develop' into component/2744-action-list
NillerW Mar 9, 2023
4d7fcbf
chore: add example of menu with portal
NillerW Mar 9, 2023
8328e37
fix: add missing attribute description
NillerW Mar 9, 2023
2aefd66
Merge branch 'component/2744-action-list' of gh_basic:kirbydesign/des…
NillerW Mar 9, 2023
c4cc3d5
chore: add extra documentation for menu portal
NillerW Mar 10, 2023
ab84496
chore: remove example not relevant for menu
NillerW Mar 10, 2023
b6c66ff
Merge branch 'develop' into component/2744-action-list
NillerW Mar 13, 2023
905e029
fix: content not placed correctly in safari
NillerW Mar 14, 2023
458dc20
chore: add attentionLevel as input
NillerW Mar 20, 2023
f08a949
feat: add auto find of portal outlet
NillerW Mar 21, 2023
2d008d9
Merge branch 'component/2744-action-list' of gh_basic:kirbydesign/des…
NillerW Mar 21, 2023
1a010ad
Merge branch 'develop' into component/2744-action-list
NillerW Mar 21, 2023
cc2c841
chore: add attentionLevel to menu doc
NillerW Mar 21, 2023
6b5bc60
chore: change default closeOnSelect to false
NillerW Mar 21, 2023
0617fa5
chore: add link to item in menu doc
NillerW Mar 21, 2023
3a7bea6
chore: added documentation for menu
NillerW Mar 21, 2023
c5dc4a5
chore: fix tests
NillerW Mar 21, 2023
ef9bdcc
Merge branch 'component/2744-action-list' of gh_basic:kirbydesign/des…
NillerW Mar 21, 2023
b92d068
chore: merge
NillerW Mar 21, 2023
57ebf27
added example for portal
kodeaben Mar 22, 2023
5e1ba95
Write additional tests
mark-drastrup Mar 23, 2023
b20e419
Merge branch 'component/2744-action-list' of https://github.com/kirby…
mark-drastrup Mar 23, 2023
18c0447
added min-width
kodeaben Mar 23, 2023
6f45545
Write additional tests
mark-drastrup Mar 23, 2023
3dfaf20
Merge branch 'component/2744-action-list' of https://github.com/kirby…
mark-drastrup Mar 23, 2023
6c7ca7a
Fix wrong offset between button and menu
mark-drastrup Mar 23, 2023
65848d8
Remove the icon size input
mark-drastrup Mar 23, 2023
3b862a1
Remove the themeColor input
mark-drastrup Mar 23, 2023
7ec3ce6
fixed item default small
kodeaben Mar 23, 2023
1df8948
added tests for trigger
kodeaben Mar 23, 2023
09e3a13
feat: add kirby-floating directive
NillerW Jan 23, 2023
ab36ce4
chore: made floatingdirective accessible for programical use
NillerW Jan 24, 2023
6a21291
chore: fix bad import
NillerW Jan 24, 2023
14a208d
chore: seperate floatDirective into own PR
NillerW Jan 24, 2023
5be5de9
feat: initial work for actionlist
NillerW Jan 26, 2023
b48a5a3
feat: add isDisabled input to floating directive
NillerW Jan 27, 2023
be5b23e
Add inline styles for minWidth
mark-drastrup Mar 24, 2023
944e686
feat: add focus trigger. Add 'close on' functionality'
NillerW Feb 2, 2023
006564a
feat: action list
NillerW Feb 9, 2023
ffdd66b
Update cookbook documentation
mark-drastrup Mar 24, 2023
72a0fbe
chore: move location of action-list
NillerW Feb 21, 2023
e4326ab
chore: rename action-list to menu
NillerW Feb 22, 2023
0df3662
feat: add option for user provided button
NillerW Feb 23, 2023
c7fe87d
feat: add option for custom button for menu
NillerW Mar 7, 2023
18069dd
Update test for minWidth
mark-drastrup Mar 24, 2023
b95eb68
chore: change triggers to only allow for array
NillerW Feb 9, 2023
1d339f9
chore: add documentation for inputs
NillerW Feb 9, 2023
0c4ca12
chore: add tests for floating directive
NillerW Mar 6, 2023
9beadd4
chore: add floating and portal directives to path
NillerW Mar 6, 2023
e667430
chore: secondary entries
NillerW Mar 6, 2023
e7e2ca4
chore secondary entry
NillerW Mar 6, 2023
f4ca3c9
chore: added handling for autoUpdate when reference changes
NillerW Mar 6, 2023
db14dd7
chore: clean
NillerW Mar 8, 2023
acbe46d
chore: clean up
NillerW Mar 8, 2023
147edd2
chore: fix merge mistake
NillerW Mar 8, 2023
cf6229f
chore: add secondart entry
NillerW Mar 8, 2023
1e9e683
chore: fix template issue
NillerW Mar 8, 2023
a6574bd
fix: import
NillerW Mar 8, 2023
731c038
fix: typo
NillerW Mar 8, 2023
aa3d032
fix: template issue
NillerW Mar 8, 2023
c58a8ec
fix: review comments
NillerW Mar 9, 2023
e5ab2d4
chore: change default size of offset
NillerW Mar 9, 2023
1fe3fef
fix: limit document event listen to open menu. Fix document ref not b…
NillerW Mar 9, 2023
5ab0191
chore: add example of menu with portal
NillerW Mar 9, 2023
95a958c
fix: add missing attribute description
NillerW Mar 9, 2023
2fdd2aa
chore: add extra documentation for menu portal
NillerW Mar 10, 2023
898c008
chore: remove example not relevant for menu
NillerW Mar 10, 2023
ab6868a
fix: content not placed correctly in safari
NillerW Mar 14, 2023
8329654
chore: add attentionLevel as input
NillerW Mar 20, 2023
fa80b34
feat: add auto find of portal outlet
NillerW Mar 21, 2023
b81f907
chore: add attentionLevel to menu doc
NillerW Mar 21, 2023
baa1b5f
chore: change default closeOnSelect to false
NillerW Mar 21, 2023
f5bd2db
chore: add link to item in menu doc
NillerW Mar 21, 2023
54d7ff3
chore: added documentation for menu
NillerW Mar 21, 2023
8bf2aa4
chore: fix tests
NillerW Mar 21, 2023
2c78540
Write additional tests
mark-drastrup Mar 23, 2023
c499445
added example for portal
kodeaben Mar 22, 2023
569fbfd
Write additional tests
mark-drastrup Mar 23, 2023
b9e3137
added min-width
kodeaben Mar 23, 2023
88b6731
Fix wrong offset between button and menu
mark-drastrup Mar 23, 2023
fd721bc
Remove the icon size input
mark-drastrup Mar 23, 2023
d86512d
Remove the themeColor input
mark-drastrup Mar 23, 2023
6a4acd2
fixed item default small
kodeaben Mar 23, 2023
baec3a5
added tests for trigger
kodeaben Mar 23, 2023
925937a
rebased
kodeaben Mar 24, 2023
becc610
made public
kodeaben Mar 24, 2023
5c3a30f
Merge branch 'component/2744-action-list' of https://github.com/kirby…
mark-drastrup Mar 24, 2023
519913a
Update the cookbook
mark-drastrup Mar 27, 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
2 changes: 2 additions & 0 deletions apps/cookbook/src/app/examples/examples.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { PagePullToRefreshExampleComponent } from './page-example/pull-to-refres
import { DropdownExampleComponent } from './dropdown-example/dropdown-example.component';
import { DataTableExampleComponent } from './data-table-example/data-table-example.component';
import { LoadingOverlayServiceExampleComponent } from './loading-overlay-example/service/loading-overlay-service-example.component';
import { MenuExampleComponent } from './menu-example/menu-example.component';

export const COMPONENT_DECLARATIONS: any[] = [
ExamplesComponent,
Expand Down Expand Up @@ -107,4 +108,5 @@ export const COMPONENT_DECLARATIONS: any[] = [
SectionHeaderExampleComponent,
ListExperimentalExampleComponent,
DataTableExampleComponent,
MenuExampleComponent,
];
2 changes: 2 additions & 0 deletions apps/cookbook/src/app/examples/examples.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { SectionHeaderExampleModule } from './section-header-example/section-hea
import { SegmentedControlExampleModule } from './segmented-control-example/segmented-control-example.module';
import { ToggleButtonExampleModule } from './toggle-button-example/toggle-button-example.module';
import { VirtualScrollExampleModule } from './virtual-scroll-example/virtual-scroll-example.module';
import { MenuExampleModule } from './menu-example/menu-example.module';

const IMPORTS = [
CodeViewerModule,
Expand Down Expand Up @@ -72,6 +73,7 @@ const IMPORTS = [
VirtualScrollExampleModule,
ExperimentalExamplesModule,
DataTableExampleModule,
MenuExampleModule,
SlideModule,
HeaderExampleModule,
AlertExperimentalModule,
Expand Down
10 changes: 9 additions & 1 deletion apps/cookbook/src/app/examples/examples.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ import { DropdownExampleComponent } from './dropdown-example/dropdown-example.co
import { DataTableExampleComponent } from './data-table-example/data-table-example.component';
import { HeaderExampleComponent } from './header-example/header-example.component';
import { NestedModalsV2ExampleComponent } from './modal-v2-example/nested-modals/nested-modals-v2-example.component';
import { MenuExampleComponent } from './menu-example/menu-example.component';

VirtualScrollListExampleComponent;
export const routes: Routes = [
{
path: '',
Expand Down Expand Up @@ -522,8 +522,16 @@ export const routes: Routes = [
path: 'data-table',
component: DataTableExampleComponent,
},
{
path: 'menu',
component: MenuExampleComponent,
},
{
path: 'header',
component: HeaderExampleComponent,
},
{
path: 'menu',
component: MenuExampleComponent,
},
];
28 changes: 28 additions & 0 deletions apps/cookbook/src/app/examples/menu-example/examples/advanced.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-menu-advanced-example',
template: `<kirby-menu>
<kirby-item (click)="actionClicked()">
<kirby-icon name="notification" slot="start"></kirby-icon>
<h3>Title</h3>
<kirby-toggle slot="end" checked="true" (checkedChange)="toggled()"></kirby-toggle>
</kirby-item>
</kirby-menu>`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuAdvancedExampleComponent {
template: string = config.template;

public actionClicked(): void {
console.log('Action clicked');
}

public toggled(): void {
console.log('Toggle changed');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-menu-custom-button-example',
template: `<kirby-menu>
<button
kirby-button
type="button"
[attentionLevel]="'3'"
>
<kirby-icon [name]="'menu-outline'"></kirby-icon>
</button>
<kirby-item>
<h3>Action 1</h3>
</kirby-item>
</kirby-menu>`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuCustomButtonExampleComponent {
template: string = config.template;

public actionClicked(): void {
console.log('Action clicked');
}

public toggled(): void {
console.log('Toggle changed');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-menu-custom-placement-example',
template: `<kirby-menu [placement]="'bottom-end'">
<kirby-item>
<h3>Action 1</h3>
</kirby-item>
...
</kirby-menu>`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuCustomPlacementExampleComponent {
template: string = config.template;
}
19 changes: 19 additions & 0 deletions apps/cookbook/src/app/examples/menu-example/examples/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-menu-default-example',
template: `<kirby-menu>
<kirby-item>
<h3>Action 1</h3>
</kirby-item>
</kirby-menu>
`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuDefaultExampleComponent {
template: string = config.template;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from '@angular/core';

@Component({
selector: 'cookbook-menu-portal-in-list-wrapper-example',
template: `
<kirby-list [items]="[{}, {}]">
<kirby-list-header *kirbyListHeader>
<ng-content select="[header]"></ng-content>
</kirby-list-header>
<kirby-list-item>
<kirby-item *kirbyListItemTemplate="let item">
<ng-content select="[body]"></ng-content>
</kirby-item>
</kirby-list-item>
</kirby-list>
`,
})
export class PortalInListWrapperComponent {}
54 changes: 54 additions & 0 deletions apps/cookbook/src/app/examples/menu-example/examples/portal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ChangeDetectorRef, Component, Input } from '@angular/core';

const config = {
selector: 'cookbook-menu-portal-example',
template: `<kirby-menu
[DOMPortalOutlet]="_outlet"
>
<kirby-item [selectable]="true">
<h3>Action 1</h3>
</kirby-item>
<kirby-item [selectable]="true">
<h3>Action 2</h3>
</kirby-item>
</kirby-menu>
`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuPortalExampleComponent {
template: string = config.template;
public _outlet: HTMLElement;

/**
*
*/
constructor(private cd: ChangeDetectorRef) {}

@Input() set isOutletElementSet(isSet: boolean) {
this._outlet = isSet ? this.outletElement : null;
}
private outletTag: string = 'cookbook-root';

public outletElement: HTMLElement = this.getOutletElement();

private getOutletElement(): HTMLElement {
const elements: HTMLCollectionOf<Element> = document.getElementsByTagName(this.outletTag);

if (!elements || elements.length === 0) {
throw Error(`Could not locate HTMLElement for ${this.outletTag}. Did you misspell it?`);
}

if (elements.length > 1) {
throw Error(
`Multiple HTMLElements found for ${this.outletTag}.
This can lead to unintended behaviours. Provide an unique outlet`
);
}

return elements[0] as HTMLElement;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component } from '@angular/core';
import { OutletSelector, PortalOutletConfig } from '@kirbydesign/designsystem/shared/floating';

const config = {
selector: 'cookbook-menu-portal-config-example',
template: `<kirby-menu [portalOutletConfig]="outletConfig">
<kirby-item [selectable]="true">
<h3>Action 1</h3>
</kirby-item>
<kirby-item [selectable]="true">
<h3>Action 2</h3>
</kirby-item>
</kirby-menu>`,
codeSnippet: `public outletConfig: PortalOutletConfig = {
selector: OutletSelector.tag,
value: 'cookbook-root',
};`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuPortalConfigExampleComponent {
template: string = config.template;

public outletConfig: PortalOutletConfig = {
selector: OutletSelector.tag,
value: 'cookbook-root',
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const portalOutletConfigExampleHTML = `<!-- This is the target outlet --->
<div id="target-div"></div>
`;

export const portalOutletConfigExampleTS = `const outletConfig: PortalOutletConfig = {
selector: 'id',
value: 'target-div'
}
`;
19 changes: 19 additions & 0 deletions apps/cookbook/src/app/examples/menu-example/examples/selectable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';

const config = {
selector: 'cookbook-menu-selectable-example',
template: `<kirby-menu [closeOnSelect]="true">
<kirby-item [selectable]="true">
<h3>Action 1</h3>
</kirby-item>
...
</kirby-menu>`,
};

@Component({
selector: config.selector,
template: config.template,
})
export class MenuSelectableExampleComponent {
template: string = config.template;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>Menu</h1>
<h2>Simple</h2>
<cookbook-menu-default-example></cookbook-menu-default-example>
<h2>Selectable items</h2>
<cookbook-menu-selectable-example></cookbook-menu-selectable-example>
<h2>Advanced item</h2>
<cookbook-menu-advanced-example></cookbook-menu-advanced-example>
<h2>Custom button</h2>
<cookbook-menu-custom-button-example></cookbook-menu-custom-button-example>
<h2>Portal</h2>
<cookbook-menu-portal-example></cookbook-menu-portal-example>
<h2>Portal config</h2>
<cookbook-menu-portal-config-example></cookbook-menu-portal-config-example>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Component } from '@angular/core';

@Component({
selector: 'cookbook-action-list-example',
templateUrl: './menu-example.component.html',
})
export class MenuExampleComponent {}
30 changes: 30 additions & 0 deletions apps/cookbook/src/app/examples/menu-example/menu-example.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { KirbyModule, ListHeaderDirective } from '@kirbydesign/designsystem';
import { MenuDefaultExampleComponent } from './examples/default';
import { MenuAdvancedExampleComponent } from './examples/advanced';
import { MenuSelectableExampleComponent } from './examples/selectable';
import { PortalInListWrapperComponent as MenuPortalInListWrapperComponent } from './examples/portal-in-list-wrapper';
import { MenuCustomButtonExampleComponent } from '~/app/examples/menu-example/examples/customButton';
import { MenuPortalExampleComponent } from '~/app/examples/menu-example/examples/portal';
import { MenuCustomPlacementExampleComponent } from '~/app/examples/menu-example/examples/customPlacement';
import { MenuPortalConfigExampleComponent } from '~/app/examples/menu-example/examples/portalConfig';

const COMPONENT_DECLARATIONS = [
MenuPortalInListWrapperComponent,
MenuDefaultExampleComponent,
MenuAdvancedExampleComponent,
MenuSelectableExampleComponent,
MenuCustomButtonExampleComponent,
MenuPortalExampleComponent,
MenuPortalConfigExampleComponent,
MenuCustomPlacementExampleComponent,
];

@NgModule({
imports: [CommonModule, KirbyModule],
declarations: COMPONENT_DECLARATIONS,
exports: COMPONENT_DECLARATIONS,
})
export class MenuExampleModule {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<ng-content></ng-content>
<button kirby-button size="sm" attentionLevel="3" (click)="expanded = !expanded">
<button
*ngIf="html || ts || css"
kirby-button
size="sm"
attentionLevel="3"
(click)="expanded = !expanded"
>
{{ expanded ? 'Hide Code' : 'View Code' }}
</button>
<cookbook-code-viewer *ngIf="expanded && html" [html]="html"></cookbook-code-viewer>
Expand Down
Loading