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: drawer add divider #260

Merged
merged 2 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/thick-scissors-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alauda/ui': patch
---

drawer add divider
1 change: 1 addition & 0 deletions src/drawer/component/drawer-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export abstract class DrawerRef<T = ComponentType<any>, R = any> {
abstract mask?: boolean;
abstract maskClosable?: boolean;
abstract width?: number;
abstract divider?: boolean;
}
18 changes: 13 additions & 5 deletions src/drawer/component/drawer.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@import '../../theme/var';
@import '../../theme/mixin';

.aui-drawer-mask {
$drawer: aui-drawer;

.#{$drawer}-mask {
position: absolute;
top: 0;
left: 0;
Expand All @@ -15,7 +17,7 @@
}
}

.aui-drawer {
.#{$drawer} {
position: fixed;
top: 0;
bottom: 0;
Expand All @@ -37,11 +39,17 @@
}

&__header {
margin: 20px 20px -4px 20px;
padding-bottom: 16px;
margin: 20px 20px 0 20px;
display: flex;
justify-content: space-between;
border-bottom: 1px solid get-color(n-8);
}

&.hasDivider {
.#{$drawer}__header {
margin: 20px 20px -4px 20px;
padding-bottom: 16px;
border-bottom: 1px solid get-color(n-8);
}
}

&__title {
Expand Down
4 changes: 4 additions & 0 deletions src/drawer/component/drawer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ export class DrawerComponent<
@Input()
maskClosable: boolean;

@Input()
divider = true;
zChanges marked this conversation as resolved.
Show resolved Hide resolved

private _value = SIZE_MAPPER[DrawerSize.Medium];
@Input()
set width(value: number) {
Expand All @@ -111,6 +114,7 @@ export class DrawerComponent<
get drawerClasses(): Record<string, boolean> {
return {
'aui-drawer': true,
hasDivider: this.divider,
...(!this.drawerClass ? null : { [this.drawerClass]: true }),
};
}
Expand Down
13 changes: 11 additions & 2 deletions src/drawer/drawer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { DrawerComponent } from './component/drawer.component';
import { DrawerSize } from './public-api';

interface DrawerOptions<T = any, D = any> {
export interface DrawerOptions<T = any, D = any> {
title?: string | TemplateRef<unknown>;
width?: number;
content?: ComponentType<T> | TemplateRef<T>;
contentParams?: D;
footer?: string | TemplateRef<unknown>;
offsetY?: number;
offsetY?: string;
divider?: boolean;
zChanges marked this conversation as resolved.
Show resolved Hide resolved
drawerClass?: string;
size?: DrawerSize;
visible?: boolean;
hideOnClickOutside?: boolean;
showClose?: boolean;
mask?: boolean;
maskClosable?: boolean;
}
@Injectable()
export class DrawerService {
Expand Down
21 changes: 19 additions & 2 deletions stories/drawer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DrawerRef,
DrawerService,
InputModule,
SwitchModule,
} from '@alauda/ui';
import { Component, Input, TemplateRef } from '@angular/core';
import { FormsModule } from '@angular/forms';
Expand All @@ -12,7 +13,13 @@ import { storiesOf } from '@storybook/angular';
storiesOf('Drawer', module)
.add('drawer', () => ({
moduleMetadata: {
imports: [ButtonModule, DrawerModule, InputModule, FormsModule],
imports: [
ButtonModule,
DrawerModule,
InputModule,
FormsModule,
SwitchModule,
],
declarations: [DemoComponent],
},
component: DemoComponent,
Expand Down Expand Up @@ -52,7 +59,16 @@ storiesOf('Drawer', module)
offsetY:
<aui-number-input [step]="20" [(ngModel)]="offsetY"></aui-number-input>
</div>
<aui-drawer [offsetY]="offsetY" [visible]="visible" (close)="close()">
<div>
divider:
<aui-switch [(ngModel)]="divider"></aui-switch>
</div>
<aui-drawer
[divider]="divider"
[offsetY]="offsetY + 'px'"
[visible]="visible"
(close)="close()"
>
<div *auiDrawerHeader>header</div>
<ng-container *auiDrawerContent> content </ng-container>
<div *auiDrawerFooter>footer</div>
Expand All @@ -62,6 +78,7 @@ storiesOf('Drawer', module)
class DemoComponent {
offsetY = 0;
visible = false;
divider = true;
open() {
this.visible = true;
}
Expand Down