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(docs-infra): disable "status" selector in API list when displaying only packages #25718

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions aio/src/app/custom-elements/api/api-list.component.html
Expand Up @@ -10,6 +10,7 @@
<aio-select (change)="setStatus($event.option)"
[options]="statuses"
[selected]="status"
[disabled]="type.value === 'package'"
label="Status:">
</aio-select>

Expand Down
2 changes: 1 addition & 1 deletion aio/src/app/shared/select/select.component.html
@@ -1,5 +1,5 @@
<div class="form-select-menu">
<button class="form-select-button" (click)="toggleOptions()">
<button class="form-select-button" (click)="toggleOptions()" [disabled]="disabled">
<strong>{{label}}</strong><span *ngIf="showSymbol" class="symbol {{selected?.value}}"></span>{{selected?.title}}
</button>
<ul class="form-select-dropdown" *ngIf="showOptions">
Expand Down
26 changes: 25 additions & 1 deletion aio/src/app/shared/select/select.component.spec.ts
Expand Up @@ -67,6 +67,28 @@ describe('SelectComponent', () => {
fixture.detectChanges();
expect(getOptionContainer()).toEqual(null);
});

it('should be disabled if the component is disabled', () => {
host.options = options;
fixture.detectChanges();
expect(getButton().disabled).toBe(false);
expect(getButton().getAttribute('disabled')).toBe(null);

host.disabled = true;
fixture.detectChanges();
expect(getButton().disabled).toBe(true);
expect(getButton().getAttribute('disabled')).toBeDefined();
});

it('should not toggle the visibility of the options list if disabled', () => {
host.options = options;
host.disabled = true;

fixture.detectChanges();
getButton().click();
fixture.detectChanges();
expect(getOptionContainer()).toEqual(null);
});
});

describe('options list', () => {
Expand Down Expand Up @@ -138,7 +160,8 @@ describe('SelectComponent', () => {
[options]="options"
[selected]="selected"
[label]="label"
[showSymbol]="showSymbol">
[showSymbol]="showSymbol"
[disabled]="disabled">
</aio-select>`
})
class HostComponent {
Expand All @@ -147,6 +170,7 @@ class HostComponent {
selected: Option;
label: string;
showSymbol: boolean;
disabled: boolean;
}

function getButton(): HTMLButtonElement {
Expand Down
3 changes: 3 additions & 0 deletions aio/src/app/shared/select/select.component.ts
Expand Up @@ -25,6 +25,9 @@ export class SelectComponent implements OnInit {
@Input()
label: string;

@Input()
disabled: boolean;

showOptions = false;

constructor(private hostElement: ElementRef) {}
Expand Down
5 changes: 5 additions & 0 deletions aio/src/styles/2-modules/_select-menu.scss
Expand Up @@ -30,6 +30,11 @@
border: 1px solid $blue-400;
box-shadow: 0 2px 2px rgba($blue-400, 0.24), 0 0 2px rgba($blue-400, 0.12);
}

&[disabled] {
color: lightgrey;
cursor: not-allowed;
}
}

.form-select-dropdown {
Expand Down