fix: fix second-level heading in description

This commit is contained in:
Roman Hotsiy 2018-03-21 19:54:45 +02:00
parent 866217667a
commit a0845325d9
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 24 additions and 16 deletions

View File

@ -22,6 +22,11 @@ export const markdownCss = css`
margin-top: 0;
}
h2 {
${headerCommonMixin(2)};
color: ${props => props.theme.colors.text};
}
code {
color: #e53935;
background-color: rgba(38, 50, 56, 0.04);

View File

@ -44,7 +44,7 @@ export class MenuItem extends React.Component<MenuItemProps> {
{item.type === 'operation' ? (
<OperationMenuItemContent item={item as OperationModel} />
) : (
<MenuItemLabel depth={item.depth} active={item.active}>
<MenuItemLabel depth={item.depth} active={item.active} type={item.type}>
<MenuItemTitle title={item.name}>{item.name}</MenuItemTitle>
{(item.depth > 0 &&
item.items.length > 0 && (

View File

@ -114,6 +114,7 @@ export const MenuItemLabel = withProps<{
depth: number;
active: boolean;
deprecated?: boolean;
type?: string;
}>(styled.label).attrs({
role: 'menuitem',
className: props =>
@ -125,6 +126,7 @@ export const MenuItemLabel = withProps<{
color: ${props => (props.active ? props.theme.colors.main : props.theme.colors.text)};
margin: 0;
padding: 12.5px ${props => props.theme.spacingUnit}px;
${({ depth, type, theme }) => type === 'section' && depth > 1 && 'padding-left: ' + theme.spacingUnit * 2 + 'px;' || ''}
display: flex;
justify-content: space-between;
font-family: ${props => props.theme.headingsFont.family};

View File

@ -62,7 +62,7 @@ export class MenuBuilder {
const group = new GroupModel('section', heading, parent);
group.depth = depth;
if (heading.items) {
group.items = mapHeadingsDeep(group, group.items, depth + 1);
group.items = mapHeadingsDeep(group, heading.items, depth + 1);
}
return group;
});

View File

@ -11,8 +11,9 @@ describe('Markdown renderer', () => {
expect(Object.keys(renderer.headings)).toHaveLength(1);
expect(renderer.headings[0].name).toEqual('Sub Intro');
});
test('should return a level-2 heading as a child of level-1', () => {
const headings = renderer.extractHeadings('# Introduction \n ## Sub Intro', false);
const headings = renderer.extractHeadings('# Introduction \n ## Sub Intro');
expect(headings).toHaveLength(1);
expect(headings[0].name).toEqual('Introduction');
expect(headings[0].items).toBeDefined();