Skip to content

Commit f429c1b

Browse files
committed
Add new component mapping
1 parent 9498115 commit f429c1b

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

src/configs/components.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const components = {
2+
Button: 'button',
3+
IconButton: 'button',
4+
Link: 'a',
5+
Spinner: 'svg',
6+
Octicon: 'svg',
7+
ToggleSwitch: 'button',
8+
Radio: 'input',
9+
TextInput: {
10+
Action: 'button',
11+
self: 'input',
12+
},
13+
Select: {
14+
Option: 'option',
15+
self: 'select',
16+
},
17+
UnderlineNav: {
18+
Link: 'a',
19+
self: 'nav',
20+
},
21+
TabNav: {
22+
Link: 'a',
23+
self: 'nav',
24+
},
25+
SubNav: {
26+
Link: 'a',
27+
self: 'nav',
28+
},
29+
}
30+
31+
const flattenComponents = (componentObj) => {
32+
let result = {};
33+
34+
Object.keys(componentObj).forEach((key) => {
35+
if (typeof componentObj[key] === 'object') {
36+
const test = Object.keys(componentObj[key]).forEach((item) => {
37+
result = { ...result, [`${key}${item !== 'self' ? `.${item}` : ''}`]: componentObj[key][item] };
38+
});
39+
} else {
40+
result = {...result, [key]: componentObj[key]}
41+
}
42+
});
43+
44+
return result;
45+
}
46+
47+
48+
exports.components = flattenComponents(components);

src/configs/recommended.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ module.exports = {
1515
},
1616
settings: {
1717
'jsx-a11y': {
18-
components: {
19-
Button: 'button',
20-
IconButton: 'button',
21-
Link: 'a'
22-
}
18+
components: require('./components')
2319
}
2420
}
2521
}

0 commit comments

Comments
 (0)