UNPKG

689 BJavaScriptView Raw
1/* eslint-disable no-underscore-dangle */
2const titleCase = str => str.split('-').map(part => part.charAt(0).toUpperCase() + part.slice(1)).join('');
3
4export const getComponentName = component => {
5 if (!component) {
6 return undefined;
7 }
8
9 if (typeof component === 'string') {
10 if (component.includes('-')) {
11 return titleCase(component);
12 }
13
14 return component;
15 }
16
17 if (component.__docgenInfo && component.__docgenInfo.displayName) {
18 return component.__docgenInfo.displayName;
19 }
20
21 return component.name;
22};
23export function scrollToElement(element, block = 'start') {
24 element.scrollIntoView({
25 behavior: 'smooth',
26 block,
27 inline: 'nearest'
28 });
29}
\No newline at end of file