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: Menu component #333

Merged
merged 51 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b7701e2
feat: add menu branch
lycHub Sep 20, 2023
c20bdda
feat: 初始化菜单文档
lycHub Sep 21, 2023
386108b
feat: menu基本样式
lycHub Sep 23, 2023
4cd1a53
feat: 递归menu
lycHub Sep 23, 2023
c9c161f
feat: 折叠menu
lycHub Sep 24, 2023
3d22d1b
fix: button点击两次只触发一次的bug
lycHub Sep 24, 2023
bf8f4ba
feat: menu animation
lycHub Sep 24, 2023
26c08af
feat: 菜单自定义ui
lycHub Sep 25, 2023
77a524b
fix: menu 动画bug
lycHub Sep 26, 2023
2700a45
style: 整理menu代码
lycHub Sep 26, 2023
271af58
fix: 菜单状态bug
lycHub Sep 27, 2023
d0c24e0
feat: 完成菜单弹出交互
lycHub Sep 28, 2023
4d567a1
fix: 使用takeUntilDestroyed
lycHub Sep 28, 2023
dfeaf2a
docs: menu demos
lycHub Sep 28, 2023
e911809
docs: menu api docs
lycHub Sep 28, 2023
b82f2cb
fix: fix docs
lycHub Sep 29, 2023
a7ef300
fix: 嵌套menu bugs
lycHub Sep 29, 2023
c045dfd
fix: menu item click
lycHub Sep 29, 2023
5b986aa
feat: add menu branch
lycHub Sep 20, 2023
3cac755
feat: 初始化菜单文档
lycHub Sep 21, 2023
a836019
feat: menu基本样式
lycHub Sep 23, 2023
5420f66
feat: 递归menu
lycHub Sep 23, 2023
11ffc99
feat: 折叠menu
lycHub Sep 24, 2023
660a9ca
fix: button点击两次只触发一次的bug
lycHub Sep 24, 2023
8d0251d
feat: menu animation
lycHub Sep 24, 2023
b1558f4
feat: 菜单自定义ui
lycHub Sep 25, 2023
f3aaf8d
fix: menu 动画bug
lycHub Sep 26, 2023
1e8ae96
style: 整理menu代码
lycHub Sep 26, 2023
e7f26c8
fix: 菜单状态bug
lycHub Sep 27, 2023
00c144d
feat: 完成菜单弹出交互
lycHub Sep 28, 2023
ad0bea2
fix: 使用takeUntilDestroyed
lycHub Sep 28, 2023
7d989c2
docs: menu demos
lycHub Sep 28, 2023
b38ba49
docs: menu api docs
lycHub Sep 28, 2023
dfee41b
fix: fix docs
lycHub Sep 29, 2023
d53be22
fix: 嵌套menu bugs
lycHub Sep 29, 2023
39657a1
fix: menu item click
lycHub Sep 29, 2023
4693065
Merge branch 'menu-component' of https://github.com/lycHub/ng-devui i…
lycHub Sep 29, 2023
09ccd90
feat: 去掉icon动画,增加css var文档
lycHub Oct 8, 2023
0445da9
fix: 改文案
lycHub Oct 8, 2023
339718d
Merge branch 'master' into menu-component
lycHub Oct 9, 2023
bbfb54d
fix: menu 折叠保持展开
lycHub Oct 10, 2023
eb34441
feat: menu样式优化,还原button组件代码
lycHub Oct 11, 2023
4044ba4
feat: border-radius变量
lycHub Oct 11, 2023
53b7656
fix: menu细节优化
lycHub Oct 12, 2023
f5924d2
fix: menn优化
lycHub Oct 13, 2023
2f03e23
fix(menu): 优化样式,submenu加上[cdkConnectedOverlayPush]
lycHub Oct 14, 2023
e13388d
fix(menu): menu 调整 icon-gap
lycHub Oct 17, 2023
ee8a493
fix(menu): menu title 加省略号
lycHub Oct 19, 2023
96a6a8d
fix: 还原menu以外的代码,删掉log
lycHub Oct 27, 2023
3e9b9a8
fix(app.component.scss): 删掉.devui-menu的class
lycHub Oct 28, 2023
43f0fd7
fix(devui/package.json) 删掉 @ngrx/component
lycHub Oct 30, 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
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# registry=https://registry.npmmirror.com
15 changes: 5 additions & 10 deletions devui-commons/src/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<div class="sidebar-wrapper">
<d-search
class="sidebar-search-container"
[iconPosition]="'left'"
[styleType]="'gray'"
[isKeyupSearch]="true"
[placeholder]="searchPlaceholder"
(searchFn)="onSearch($event)"
></d-search>
<d-search class="sidebar-search-container" [iconPosition]="'left'" [styleType]="'gray'" [isKeyupSearch]="true"
[placeholder]="searchPlaceholder" (searchFn)="onSearch($event)"></d-search>
<ul class="sidebar-menu" [ngClass]="{'sidebar-menu-design': !sideMenuList.length}">
<li *ngFor="let item of sideMenuList" class="sidebar-menu-item" routerLinkActive="sidebar-menu-item-selected">
<a *ngIf="item.linkType === 'routerLink'" [routerLink]="item.path">
Expand All @@ -18,7 +12,8 @@
</li>
</ul>
<nav class="sidebar-nav">
<d-accordion [data]="componentsDataDisplay" [linkType]="linkType" [itemTemplate]="itemtemplate" (itemClick)="handleResetPage()" [linkDefaultTarget]="linkDefaultTarget"></d-accordion>
<d-accordion [data]="componentsDataDisplay" [linkType]="linkType" [itemTemplate]="itemtemplate"
(itemClick)="handleResetPage()" [linkDefaultTarget]="linkDefaultTarget"></d-accordion>
<ng-template #itemtemplate let-item="item">
{{ item.title }}
<d-tag *ngIf="item.newChange" [tag]="text.new" [labelStyle]="'update-custom'"></d-tag>
Expand All @@ -45,4 +40,4 @@
</a>
</div>
</div>
</div>
</div>
11 changes: 8 additions & 3 deletions devui/button/button.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<!--
fix bug: button click事件点两次只触发一次

移除下列属性
[class.mouseDown]="isMouseDown"
(mousedown)="isMouseDown = true"
(mouseup)="isMouseDown = false"
lycHub marked this conversation as resolved.
Show resolved Hide resolved
-->
<button
[attr.id]="id"
class="devui-btn devui-btn-{{ bsStyle }} devui-btn-{{ bsSize }} devui-btn-{{ bsPosition }}"
[class.devui-btn-circle]="shape === 'circle'"
[type]="type"
[disabled]="disabled"
[class.bordered]="bordered"
[class.mouseDown]="isMouseDown"
[backdrop]="true"
dLoading
[showLoading]="showLoading"
Expand All @@ -14,8 +21,6 @@
[dAutoFocus]="autofocus"
(click)="onClick($event)"
[ngClass]="{ 'd-btn-icon': !!icon && !hasContent(), 'd-btn-icon-wrap': !!icon }"
(mousedown)="isMouseDown = true"
(mouseup)="isMouseDown = false"
>
<span *ngIf="!!icon" class="devui-icon-fix icon {{ icon }}" [ngClass]="{ 'clear-right-4': hasContent() }"></span>
<!--
Expand Down
6 changes: 5 additions & 1 deletion devui/button/button.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,13 @@ $devui-btn-pseudo-config: (
}
}

&.mouseDown:not(:disabled) {
&:active:not(:disabled) {
transform: scale(0.95);
}

/* &.mouseDown:not(:disabled) {
transform: scale(0.95);
} */
}

.devui-loading {
Expand Down
4 changes: 2 additions & 2 deletions devui/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type IButtonSize = 'lg' | 'md' | 'sm' | 'xs';
styleUrls: ['./button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
})
})
export class ButtonComponent implements AfterContentChecked {
@Input() id: string;
@Input() type: IButtonType = 'button';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class ButtonComponent implements AfterContentChecked {
waveLeft = 0;
waveTop = 0;
showWave = false;
isMouseDown = false;
// isMouseDown = false;

constructor(private cd: ChangeDetectorRef) {
}
Expand Down
134 changes: 68 additions & 66 deletions devui/devui.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { LoadingModule } from 'ng-devui/loading';
import { MentionModule } from 'ng-devui/mention';
import { ModalModule } from 'ng-devui/modal';
import { MultiAutoCompleteModule } from 'ng-devui/multi-auto-complete';
import { MenuModule } from 'ng-devui/menu';
import { NavSpriteModule } from 'ng-devui/nav-sprite';
import { PaginationModule } from 'ng-devui/pagination';
import { PanelModule } from 'ng-devui/panel';
Expand Down Expand Up @@ -134,74 +135,75 @@ export * from './version';
@NgModule({
imports: [],
exports: [
AccordionModule,
AlertModule,
AnchorModule,
AutoCompleteModule,
AvatarModule,
DCommonModule,
BadgeModule,
BackTopModule,
ButtonModule,
BreadcrumbModule,
CardModule,
CarouselModule,
CheckBoxModule,
DataTableModule,
DatepickerModule,
DragDropModule,
DrawerModule,
DropDownModule,
EditableSelectModule,
FormModule,
FullscreenModule,
ImagePreviewModule,
LoadingModule,
LayoutModule,
IconModule,
ModalModule,
MultiAutoCompleteModule,
PaginationModule,
PanelModule,
PopoverModule,
ProgressModule,
RadioModule,
RateModule,
SearchModule,
SelectModule,
StatusModule,
StickyModule,
TabsModule,
TagsModule,
TagsInputModule,
ToastModule,
ToggleModule,
TooltipModule,
TimeAxisModule,
TreeModule,
UploadModule,
UserGuideModule,
InputNumberModule,
SliderModule,
SplitterModule,
TreeSelectModule,
TransferModule,
TextInputModule,
TextareaModule,
WindowRefModule,
StepsGuideModule,
GanttModule,
QuadrantDiagramModule,
TimePickerModule,
CascaderModule,
CategorySearchModule,
DatepickerProModule,
MentionModule,
NavSpriteModule,
ReadTipModule
AccordionModule,
AlertModule,
AnchorModule,
AutoCompleteModule,
AvatarModule,
DCommonModule,
BadgeModule,
BackTopModule,
ButtonModule,
BreadcrumbModule,
CardModule,
CarouselModule,
CheckBoxModule,
DataTableModule,
DatepickerModule,
DragDropModule,
DrawerModule,
DropDownModule,
EditableSelectModule,
FormModule,
FullscreenModule,
ImagePreviewModule,
LoadingModule,
LayoutModule,
IconModule,
ModalModule,
MultiAutoCompleteModule,
MenuModule,
PaginationModule,
PanelModule,
PopoverModule,
ProgressModule,
RadioModule,
RateModule,
SearchModule,
SelectModule,
StatusModule,
StickyModule,
TabsModule,
TagsModule,
TagsInputModule,
ToastModule,
ToggleModule,
TooltipModule,
TimeAxisModule,
TreeModule,
UploadModule,
UserGuideModule,
InputNumberModule,
SliderModule,
SplitterModule,
TreeSelectModule,
TransferModule,
TextInputModule,
TextareaModule,
WindowRefModule,
StepsGuideModule,
GanttModule,
QuadrantDiagramModule,
TimePickerModule,
CascaderModule,
CategorySearchModule,
DatepickerProModule,
MentionModule,
NavSpriteModule,
ReadTipModule
],
declarations: [],
})
})
export class DevUIModule {
static forRoot(): ModuleWithProviders<DevUIModule> {
return {
Expand Down
30 changes: 30 additions & 0 deletions devui/menu/demo/auto-expand/auto-expand.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="demo-menu">
<div d-menu>
<ng-container *ngFor="let m of menus; trackBy: trackByMenu">
<div
d-sub-menu
[title]="m.name"
[icon]="m.icon"
[open]="openKeys.includes(m.key)"
(openChange)="openChange($event, m.key)"
*ngIf="m.children?.length; else leafTpl"
>
<div
d-menu-item
(itemClick)="itemClick(item.key)"
[active]="item.key === activeKey"
*ngFor="let item of m.children; trackBy: trackByMenu"
>
<d-icon class="devui-menu-item-icon" icon="icon-op-list" />
<span class="devui-menu-item-name">{{ item.name }}</span>
</div>
</div>
<ng-template #leafTpl>
<div d-menu-item (itemClick)="itemClick(m.key)" [active]="m.key === activeKey">
<d-icon class="devui-menu-item-icon" icon="icon-op-list" />
<span class="devui-menu-item-name over-flow-ellipsis">{{ m.name }}</span>
</div>
</ng-template>
</ng-container>
</div>
</div>
108 changes: 108 additions & 0 deletions devui/menu/demo/auto-expand/auto-expand.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { MenuItemType } from 'ng-devui/menu';

const MENUS: MenuItemType[] = [
{
key: 'c-1',
icon: 'icon-more-func',
name: 'Content 1 (as a leaf menu)'
},
{
key: 'c-2',
name: 'Content 2 (as a parent menu, has children)',
icon: 'icon-more-func',
children: [
{
key: 'c-2-1',
name: 'Content 2 Child 1'
},
{
key: 'c-2-2',
name: 'Content 2 Child 2'
},
{
key: 'c-2-3',
name: 'Content 2 Child 3'
},
]
}, {
key: 'c-3',
name: 'Content 3 (as a parent menu, has children)',
icon: 'icon-more-func',
children: [
{
key: 'c-3-1',
name: 'Content 3 Child 1'
},
{
key: 'c-3-2',
name: 'Content 3 Child 2',
},
{
key: 'c-3-3',
name: 'Content 3 Child 3',
},
{
key: 'c-3-4',
name: 'Content 3 Child 4',
},
]
},
{
key: 'c-4',
icon: 'icon-more-func',
name: 'Content 4 (as a leaf menu)',
}
];

function findAllParent(source: MenuItemType[], key: string) {
const result: string[] = [];
const loop = (list: MenuItemType[]) => {
for (const item of list) {
if (item.key === key) {
// parentKeys.unshift(key);
return true;
}
if (item.children?.length) {
const t = loop(item.children);
if (t) {
result.unshift(item.key);
return true;
}
}
}
};
loop(source);
return result;
}


@Component({
selector: 'd-auto-expand',
templateUrl: './auto-expand.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AutoExpandComponent implements OnInit {
menus = MENUS;
openKeys: string[] = [];
activeKey = 'c-3-2';

openChange(open: boolean, key: string) {
if (open) {
this.openKeys.push(key);
} else {
this.openKeys = this.openKeys.filter(item => item !== key);
}
}

ngOnInit() {
this.openKeys = findAllParent(this.menus, this.activeKey);
}
itemClick(key: string) {
this.activeKey = key;
}

trackByMenu(_: number, item: MenuItemType) {
return item.key;
}
}
Loading