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(design)!: remove the diameter property of loading icon #3341

Merged
merged 4 commits into from
Nov 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ <h1>Loading Icon</h1>
<h2>Overview</h2>
<p>Loading icons are used to indicate to users that an event is ocurring and is still in progress. They should only be used for short loading processes. For events that can take a considerable amount of time, use the <a routerLink="/progress-bar">Progress Bar</a> component instead.</p>

<h2>Diameter</h2>
<p>The diameter of a loading icon can be defined by using the <code>diameter</code> property. By default, the diameter is set to <code>60</code>.</p>

<design-land-example-viewer-container example="loading-icon-diameter"></design-land-example-viewer-container>

<h2>Theming</h2>
<p>The loading icon color is defined by using the <code>color</code> property. By default, the color is set to <code>primary</code>. This can be changed to one of the supported colors.</p>

Expand Down
2 changes: 1 addition & 1 deletion libs/design/button/src/button/button-base.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ng-content select="[daffPrefix]"></ng-content>
}
@if (loading) {
<daff-loading-icon [diameter]="24"></daff-loading-icon>
<daff-loading-icon class="daff-button__loading"></daff-loading-icon>
} @else {
<span class="daff-button__content"><ng-content></ng-content></span>
}
Expand Down
8 changes: 6 additions & 2 deletions libs/design/button/src/button/button-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
display: inline-flex;
justify-content: center;
align-items: center;
gap: 8px;
gap: 0.5rem;
appearance: none;
border: none;
border-radius: 4px;
border-radius: 0.25rem;
position: relative;
text-align: center;
text-decoration: none;
Expand All @@ -25,6 +25,10 @@
z-index: 2;
}

.daff-button__loading {
max-width: 1.5rem;
}

.daff-button__content {
@include t.text-truncate();
}
Expand Down
5 changes: 0 additions & 5 deletions libs/design/loading-icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ export class CustomComponentModule { }

> This method is deprecated. It's recommended to update all custom components to standalone.

## Diameter
The diameter of a loading icon can be defined by using the `diameter` property. By default, the diameter is set to `60`.

<design-land-example-viewer-container example="loading-icon-diameter"></design-land-example-viewer-container>

## Theming
The loading icon color is defined by using the `color` property. By default, the color is set to `primary`. This can be changed to one of the supported colors.

Expand Down
2 changes: 0 additions & 2 deletions libs/design/loading-icon/examples/src/examples.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { LoadingIconColorComponent } from './loading-icon-color/loading-icon-color.component';
import { LoadingIconDiameterComponent } from './loading-icon-diameter/loading-icon-diameter.component';

export const LOADING_ICON_EXAMPLES = [
LoadingIconColorComponent,
LoadingIconDiameterComponent,
];

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $angle: 270 - $max-percentage-fill * 360;
:host {
display: flex;
width: 100%;
max-width: 4rem;
}

.daff-loading-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import { DaffPalette } from '@daffodil/design';
import { DaffLoadingIconComponent } from './loading-icon.component';

@Component({
template: '<daff-loading-icon [color]="color" [diameter]="diameter"></daff-loading-icon>',
template: '<daff-loading-icon [color]="color"></daff-loading-icon>',
standalone: true,
imports: [
DaffLoadingIconComponent,
],
})
class WrapperComponent {
color: DaffPalette;
diameter = 60;
}

describe('@daffodil/design/loading-icon | DaffLoadingIconComponent', () => {
Expand All @@ -44,30 +43,18 @@ describe('@daffodil/design/loading-icon | DaffLoadingIconComponent', () => {
fixture = TestBed.createComponent(WrapperComponent);
wrapper = fixture.componentInstance;
de = fixture.debugElement.query(By.css('daff-loading-icon'));
component = fixture.debugElement.query(By.css('daff-loading-icon')).componentInstance;
component = de.componentInstance;
fixture.detectChanges();
});

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

describe('<daff-loading-icon>', () => {
it('should add a class of "daff-loading-icon" to the host element', () => {
expect(de.classes).toEqual(jasmine.objectContaining({
'daff-loading-icon': true,
}));
});
});

it('has a default value of 60 for the diameter', () => {
expect(component.diameter).toEqual(60);
});

it('can take a `diameter` as input which sets max-width on the `daff-loading-icon` host', () => {
wrapper.diameter = 50;
fixture.detectChanges();
expect(de.nativeElement.style.maxWidth).toEqual('50px');
it('should add a class of "daff-loading-icon" to the host element', () => {
expect(de.classes).toEqual(jasmine.objectContaining({
'daff-loading-icon': true,
}));
});

it('should take color as an input', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Component,
ChangeDetectionStrategy,
Input,
HostBinding,
} from '@angular/core';

Expand All @@ -24,20 +23,8 @@ import { DaffColorableDirective } from '@daffodil/design';
standalone: true,
})
export class DaffLoadingIconComponent {

/**
* The (pixel) diameter of the animation
*/
@Input() diameter = 60;

/**
* @docs-private
*/
@HostBinding('class.daff-loading-icon') class = true;
/**
* @docs-private
*/
@HostBinding('style.max-width') get maxWidth() {
return this.diameter + 'px';
}
}