Skip to content

Commit

Permalink
feat: card header support secondary size
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtianze committed May 11, 2022
1 parent e4efe38 commit 208b5aa
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-rats-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": patch
---

feat: card header support secondary size
7 changes: 6 additions & 1 deletion src/card/card.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ $b: aui-card;
@include card-shadow;

&__header {
display: flex;
align-items: center;
padding: 0;
font-weight: use-var(font-weight-bold);
@include text-set(xxl, main);

font-weight: use-var(font-weight-bold);
&--secondary {
@include text-set(xl);
}

+ .#{$b}__content {
margin-top: use-var(spacing-xl);
Expand Down
8 changes: 6 additions & 2 deletions src/card/helper-directives.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Directive } from '@angular/core';
import { Directive, Input } from '@angular/core';

@Directive({
selector: '[auiCardHeader]',
host: {
'[class.aui-card__header]': 'true',
'[class.aui-card__header--secondary]': 'size === "secondary"',
},
})
export class CardHeaderDirective {}
export class CardHeaderDirective {
@Input()
size: 'default' | 'secondary' = 'default';
}

@Directive({
selector: '[auiCardFooter]',
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ export * from './time-picker';
export * from './tooltip';
export * from './tree-select';
export * from './types';
export * from './utils';
42 changes: 31 additions & 11 deletions src/utils/operators.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { pipe, publishReplay, refCount } from 'rxjs';
import { ReplaySubject, share, TimestampProvider } from 'rxjs';

/**
* @see https://rxjs.dev/deprecations/multicasting#publishreplay
*
* FIXME:
* The recommended replacement is breaking our apps for watching resources,
* revert it back temporarily. see also https://github.com/ReactiveX/rxjs/discussions/6438
*/
export const publishRef = <T>(bufferSize = 1, windowTime?: number) =>
// eslint-disable-next-line sonar/deprecation
pipe(publishReplay<T>(bufferSize, windowTime), refCount());
export type PublishRefConfig<T> =
| number
| (import('rxjs/internal/operators/share').ShareConfig<T> & {
bufferSize?: number;
windowTime?: number;
timestampProvider?: TimestampProvider;
});

export const publishRef = <T>(bufferSizeOrConfig: PublishRefConfig<T> = {}) => {
const {
bufferSize = 1,
windowTime,
timestampProvider,
connector = () =>
new ReplaySubject(bufferSize, windowTime, timestampProvider),
resetOnError = false,
resetOnComplete = false,
resetOnRefCountZero = true,
} = typeof bufferSizeOrConfig === 'number'
? ({
bufferSize: bufferSizeOrConfig,
} as Exclude<PublishRefConfig<T>, number>)
: bufferSizeOrConfig;
return share<T>({
connector,
resetOnError,
resetOnComplete,
resetOnRefCountZero,
});
};
12 changes: 12 additions & 0 deletions stories/card/card.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ import { CardModule } from '@alauda/ui';
</div>
<div auiCardFooter>footer</div>
</aui-card>
<aui-card [divider]="false">
<div
auiCardHeader
size="secondary"
>
secondary header
</div>
<div style="line-height: 64px; background-color: #ededed;">
content
</div>
<div auiCardFooter>footer</div>
</aui-card>
`,
}}
</Story>
Expand Down

0 comments on commit 208b5aa

Please sign in to comment.