Skip to content

Commit 9f5fdb4

Browse files
authored
Merge pull request #149 from bindable-ui/feature/unrestricted-classes
Updates to allow custom classes to be returned
2 parents 4272438 + 45af82c commit 9f5fdb4

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@bindable-ui/bindable",
33
"description": "An Aurelia component library",
4-
"version": "1.11.8",
4+
"version": "1.11.9",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/bindable-ui/bindable"

src/components/tables/c-table/c-table.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,5 +615,26 @@ describe('c-table component', () => {
615615
expect(col.sortClass).toBe(component.styles.sortDesc);
616616
});
617617
});
618+
619+
describe('#getClasses', () => {
620+
it('will update with css class names from styles', () => {
621+
const str = 'bgWarning';
622+
623+
const classes = component.getClasses(str);
624+
625+
expect(classes.split(' ')).toHaveLength(1);
626+
expect(classes).toContain(component.styles.bgWarning);
627+
});
628+
629+
it("will keep CSS class names applied that aren't in styles", () => {
630+
const str = 'bgWarning my-custom-class';
631+
632+
const classes = component.getClasses(str);
633+
634+
expect(classes.split(' ')).toHaveLength(2);
635+
expect(classes).toContain(component.styles.bgWarning);
636+
expect(classes).toContain('my-custom-class');
637+
});
638+
});
618639
});
619640
});

src/components/tables/c-table/c-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class CTable {
171171

172172
public getClasses(str = '') {
173173
const keys = str.split(' ');
174-
const classes = keys.map(key => this.styles[key]);
174+
const classes = keys.map(key => (this.styles[key] ? this.styles[key] : key));
175175

176176
return classes.join(' ');
177177
}

0 commit comments

Comments
 (0)