1 | import "core-js/modules/es.string.split.js";
|
2 | import "core-js/modules/es.regexp.exec.js";
|
3 | import "core-js/modules/es.string.trim.js";
|
4 | import React, { useContext } from 'react';
|
5 | import { Title as PureTitle } from '@storybook/components';
|
6 | import { DocsContext } from './DocsContext';
|
7 | var STORY_KIND_PATH_SEPARATOR = /\s*\/\s*/;
|
8 | export var extractTitle = function extractTitle(_ref) {
|
9 | var title = _ref.title;
|
10 | var groups = title.trim().split(STORY_KIND_PATH_SEPARATOR);
|
11 | return groups && groups[groups.length - 1] || title;
|
12 | };
|
13 | export var Title = function Title(_ref2) {
|
14 | var children = _ref2.children;
|
15 | var context = useContext(DocsContext);
|
16 | var text = children;
|
17 |
|
18 | if (!text) {
|
19 | text = extractTitle(context);
|
20 | }
|
21 |
|
22 | return text ? React.createElement(PureTitle, {
|
23 | className: "sbdocs-title"
|
24 | }, text) : null;
|
25 | }; |
\ | No newline at end of file |