Skip to content

Commit

Permalink
feat(rating): add aria-label attribute (#5607)
Browse files Browse the repository at this point in the history
Add aria label attribute
Add RatingConfig class

Close #5579

Co-authored-by: Dmitriy Danilov <daniloff200@gmail.com>
  • Loading branch information
IraErshova and daniloff200 committed Jan 24, 2020
1 parent 009aeaa commit 5d505ea
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 69 deletions.
4 changes: 4 additions & 0 deletions demo/src/app/components/+rating/demos/config/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<rating [(ngModel)]="rate" [max]="max"></rating>
<div class="card">
<pre class="card-block card-header" style="margin:15px 0;">Rate: <b>{{rate}}</b> </pre>
</div>
17 changes: 17 additions & 0 deletions demo/src/app/components/+rating/demos/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { RatingConfig } from 'ngx-bootstrap/rating';

// such override allows to keep some initial values
export function getRatingConfig(): RatingConfig {
return Object.assign(new RatingConfig(), { ariaLabel: 'My Rating' });
}

@Component({
selector: 'demo-rating-config',
templateUrl: './config.html',
providers: [{ provide: RatingConfig, useFactory: getRatingConfig }]
})
export class DemoRatingConfigComponent {
max = 10;
rate = 7;
}
4 changes: 3 additions & 1 deletion demo/src/app/components/+rating/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { DemoRatingBasicComponent } from './basic/basic';
import { DemoRatingCustomComponent } from './custom/custom';
import { DemoRatingDynamicComponent } from './dynamic/dynamic';
import { DemoRatingSelectOnEnterComponent } from './select-on-enter/select-on-enter';
import { DemoRatingConfigComponent } from './config/config';

export const DEMO_COMPONENTS = [
DemoRatingBasicComponent,
DemoRatingCustomComponent,
DemoRatingDynamicComponent,
DemoRatingSelectOnEnterComponent
DemoRatingSelectOnEnterComponent,
DemoRatingConfigComponent
];
15 changes: 14 additions & 1 deletion demo/src/app/components/+rating/rating-section.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { DemoRatingBasicComponent } from './demos/basic/basic';
import { DemoRatingCustomComponent } from './demos/custom/custom';
import { DemoRatingDynamicComponent } from './demos/dynamic/dynamic';
import { DemoRatingSelectOnEnterComponent } from './demos/select-on-enter/select-on-enter';
import { DemoRatingConfigComponent } from './demos/config/config';

import { ContentSection } from '../../docs/models/content-section.model';
import { DemoTopSectionComponent } from '../../docs/demo-section-components/demo-top-section/index';
import { ExamplesComponent } from '../../docs/demo-section-components/demo-examples-section/index';
import { ApiSectionsComponent } from '../../docs/demo-section-components/demo-api-section/index';

import { NgApiDocComponent } from '../../docs/api-docs';
import { NgApiDocComponent, NgApiDocConfigComponent } from '../../docs/api-docs';

export const demoComponentContent: ContentSection[] = [
{
Expand Down Expand Up @@ -53,6 +54,13 @@ export const demoComponentContent: ContentSection[] = [
component: require('!!raw-loader!./demos/select-on-enter/select-on-enter'),
html: require('!!raw-loader!./demos/select-on-enter/select-on-enter.html'),
outlet: DemoRatingSelectOnEnterComponent
},
{
title: 'Configuring defaults',
anchor: 'demo-rating-config',
component: require('!!raw-loader!./demos/config/config'),
html: require('!!raw-loader!./demos/config/config.html'),
outlet: DemoRatingConfigComponent
}
]
},
Expand All @@ -65,6 +73,11 @@ export const demoComponentContent: ContentSection[] = [
title: 'RatingComponent',
anchor: 'rating-component',
outlet: NgApiDocComponent
},
{
title: 'RatingConfig',
anchor: 'rating-config',
outlet: NgApiDocConfigComponent
}
]
}
Expand Down
Loading

0 comments on commit 5d505ea

Please sign in to comment.