Skip to content

Commit

Permalink
Merge pull request #2287 from kirbydesign/main
Browse files Browse the repository at this point in the history
Release version 5.4
  • Loading branch information
RasmusKjeldgaard authored May 24, 2022
2 parents d2857a1 + f8ef8dc commit b6881eb
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 112 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.scss @jkaltoft
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@ export class SegmentedControlShowcaseComponent {
defaultValue: 'undefined',
type: ['number'],
},
{
name: 'disableChangeOnSwipe',
description:
'Sets the `scrollable` attribute on ion-segment. Note that this will not make the segmented-control scrollable but it will prevent segmentChange from emitting on swipe, when set to true',
defaultValue: 'false',
type: ['boolean'],
},
];
}
12 changes: 12 additions & 0 deletions libs/core/src/scss/base/_functions.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use 'sass:list';
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'sass:string';
@use '../themes/colors';
@use 'variables';
Expand Down Expand Up @@ -109,6 +110,17 @@
@return $classes;
}

/// Remove the unit of a length
/// @param {Number} $number - Number to remove unit from
/// @return {Number} - Unitless number
/// Source: https://css-tricks.com/snippets/sass/strip-unit-function/
@function strip-unit($number) {
@if meta.type-of($number) == 'number' and not math.is-unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}

@mixin slotted($selectors...) {
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
::ng-deep > {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,13 @@ describe('DropdownComponent (popover version)', () => {
});

describe('when configured with popout direction', () => {
/* TODO: This test has been flakey for some time.
I've excluded it as it is currently worthless.
For an example take a look at this test run:
https://github.com/kirbydesign/designsystem/runs/5813726617
*/
xit('should open card to the left when popout=left', fakeAsync(() => {
it('should open card to the left when popout=left', fakeAsync(() => {
spectator.component.popout = HorizontalDirection.left;
spectator.element.style.cssFloat = 'right';

spectator.component.open();
tick(openDelayInMs);
spectator.detectChanges();

const card = spectator.query('kirby-card');
const buttonRect = buttonElement.getBoundingClientRect();
Expand Down Expand Up @@ -310,12 +306,6 @@ describe('DropdownComponent (popover version)', () => {
expect(spectator.component.isOpen).toBeTruthy();
expect(spectator.element).toBeFocused();
}));

it('should open dropdown within actual delay', async () => {
spectator.click('button');
await TestHelper.whenTrue(() => spectator.component.isOpen, openDelayInMs + 1);
expect(spectator.component.isOpen).toBeTruthy();
});
});

describe('and Space key is pressed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ kirby-card {
}
}

:host(.with-popover) {
&.is-open {
kirby-card {
display: block;
}
}
}

:host(.is-open) {
& > button {
box-shadow: utils.get-elevation(8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,6 @@ describe('DropdownComponent', () => {
expect(spectator.component.isOpen).toBeTruthy();
expect(spectator.element).toBeFocused();
}));

it('should open dropdown within actual delay', async () => {
spectator.click('button');
await TestHelper.whenTrue(() => spectator.component.isOpen, openDelayInMs);
expect(spectator.component.isOpen).toBeTruthy();
});
});

describe('and Space key is pressed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('ItemSlidingComponent', () => {
});

it('should create', () => {
expect(spectator.component).toBeTruthy;
expect(spectator.component).toBeTruthy();
});

it('should project slotted content', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ describe('ActionSheetHelper', () => {
});

it('backdrop click should dismiss action-sheet', async () => {
let modalDidDismiss = false;
ionModal.onDidDismiss().then((_) => (modalDidDismiss = true));
const onDidDismiss = ionModal.onDidDismiss();

backdrop.dispatchEvent(new MouseEvent('click'));
await new Promise<void>((resolve) => setTimeout(resolve, 15));
expect(modalDidDismiss).toBeTrue();

await expectAsync(onDidDismiss).toBeResolved();
});

it('action-sheet should have correct backdrop style when opened on top of a modal', async () => {
Expand Down
32 changes: 17 additions & 15 deletions libs/designsystem/src/lib/components/popover/popover.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,9 @@ export class PopoverComponent implements AfterViewInit, OnDestroy {
}
}

@HostListener('click')
_backdropClick() {
this.willHide.emit();
this.hide();
}

@HostListener('window:resize')
_onWindowResize() {
if (this.isShowing) {
this.willHide.emit();
this.hide();
}
this.hide();
}

constructor(private elementRef: ElementRef<HTMLElement>, private renderer: Renderer2) {
Expand Down Expand Up @@ -97,8 +88,13 @@ export class PopoverComponent implements AfterViewInit, OnDestroy {
}

// document.removeEventListener needs the exact same event handler & options reference:
private preventEvent(event: TouchEvent) {
event.preventDefault();
private static preventEventOutsidePopover(event: TouchEvent) {
if (event.target instanceof HTMLElement) {
const targetIsInPopover = !!event.target.closest('kirby-popover');
if (!targetIsInPopover) {
event.preventDefault();
}
}
}

private preventScroll() {
Expand All @@ -110,7 +106,7 @@ export class PopoverComponent implements AfterViewInit, OnDestroy {
// preventDefault does not work with Renderer2.listen method; add event listener directly to document instead
this.document.addEventListener(
'touchmove',
this.preventEvent,
PopoverComponent.preventEventOutsidePopover,
this.preventScrollEventListenerOptions
);
}
Expand All @@ -122,7 +118,7 @@ export class PopoverComponent implements AfterViewInit, OnDestroy {

this.document.removeEventListener(
'touchmove',
this.preventEvent,
PopoverComponent.preventEventOutsidePopover,
this.preventScrollEventListenerOptions
);
}
Expand All @@ -141,7 +137,13 @@ export class PopoverComponent implements AfterViewInit, OnDestroy {
}

hide() {
this.renderer.removeChild(this.document.body, this.elementRef.nativeElement);
if (!this.isShowing) return;

this.willHide.emit();
this.renderer.removeChild(
this.elementRef.nativeElement.parentElement,
this.elementRef.nativeElement
);
this.releaseScroll();

this.renderer.removeStyle(this.targetElement, 'z-index');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ion-segment
*ngIf="mode === 'default'"
[value]="value?.id"
[scrollable]="disableChangeOnSwipe"
(ionChange)="onSegmentSelect($event.detail.value)"
(click)="preventWrapperClick($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ export class SegmentedControlComponent {
this.isSmallSize = size === 'sm';
}

private _disableChangeOnSwipe: boolean = false;
get disableChangeOnSwipe(): boolean {
return this._disableChangeOnSwipe;
}

@Input() set disableChangeOnSwipe(value: boolean) {
this._disableChangeOnSwipe = value;
}

@Output() segmentSelect: EventEmitter<SegmentItem> = new EventEmitter();

onSegmentSelect(selectedId: string) {
Expand Down
96 changes: 23 additions & 73 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "designsystem",
"version": "5.3.1",
"version": "5.4.0",
"description": "Kirby Design Angular Components. This library provides Angular wrappers for the @kirbydesign/core package, for smoother integration into Angular projects.",
"engines": {
"node": "^14.16"
Expand Down

0 comments on commit b6881eb

Please sign in to comment.