UNPKG

835 BJavaScriptView Raw
1import "core-js/modules/es.string.split.js";
2import "core-js/modules/es.regexp.exec.js";
3import "core-js/modules/es.string.trim.js";
4import React, { useContext } from 'react';
5import { Title as PureTitle } from '@storybook/components';
6import { DocsContext } from './DocsContext';
7var STORY_KIND_PATH_SEPARATOR = /\s*\/\s*/;
8export 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};
13export 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 ? /*#__PURE__*/React.createElement(PureTitle, {
23 className: "sbdocs-title"
24 }, text) : null;
25};
\No newline at end of file