mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 16:46:34 +03:00
fix: fix second-level heading in description
This commit is contained in:
parent
866217667a
commit
a0845325d9
|
@ -22,6 +22,11 @@ export const markdownCss = css`
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
${headerCommonMixin(2)};
|
||||||
|
color: ${props => props.theme.colors.text};
|
||||||
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
color: #e53935;
|
color: #e53935;
|
||||||
background-color: rgba(38, 50, 56, 0.04);
|
background-color: rgba(38, 50, 56, 0.04);
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class MenuItem extends React.Component<MenuItemProps> {
|
||||||
{item.type === 'operation' ? (
|
{item.type === 'operation' ? (
|
||||||
<OperationMenuItemContent item={item as OperationModel} />
|
<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>
|
<MenuItemTitle title={item.name}>{item.name}</MenuItemTitle>
|
||||||
{(item.depth > 0 &&
|
{(item.depth > 0 &&
|
||||||
item.items.length > 0 && (
|
item.items.length > 0 && (
|
||||||
|
|
|
@ -5,7 +5,7 @@ import styled, { css, withProps } from '../../styled-components';
|
||||||
|
|
||||||
export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({
|
export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({
|
||||||
className: props => `operation-type ${props.type}`,
|
className: props => `operation-type ${props.type}`,
|
||||||
})`
|
}) `
|
||||||
width: 26px;
|
width: 26px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: ${props => props.theme.code.fontSize};;
|
height: ${props => props.theme.code.fontSize};;
|
||||||
|
@ -70,7 +70,7 @@ function menuItemActiveBg(depth): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MenuItemUl = withProps<{ active: boolean }>(styled.ul)`
|
export const MenuItemUl = withProps<{ active: boolean }>(styled.ul) `
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export const MenuItemUl = withProps<{ active: boolean }>(styled.ul)`
|
||||||
${props => (props.active ? '' : 'display: none;')};
|
${props => (props.active ? '' : 'display: none;')};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const MenuItemLi = withProps<{ depth: number }>(styled.li)`
|
export const MenuItemLi = withProps<{ depth: number }>(styled.li) `
|
||||||
list-style: none inside none;
|
list-style: none inside none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
@ -114,17 +114,19 @@ export const MenuItemLabel = withProps<{
|
||||||
depth: number;
|
depth: number;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
deprecated?: boolean;
|
deprecated?: boolean;
|
||||||
|
type?: string;
|
||||||
}>(styled.label).attrs({
|
}>(styled.label).attrs({
|
||||||
role: 'menuitem',
|
role: 'menuitem',
|
||||||
className: props =>
|
className: props =>
|
||||||
classnames('-depth' + props.depth, {
|
classnames('-depth' + props.depth, {
|
||||||
active: props.active,
|
active: props.active,
|
||||||
}),
|
}),
|
||||||
})`
|
}) `
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: ${props => (props.active ? props.theme.colors.main : props.theme.colors.text)};
|
color: ${props => (props.active ? props.theme.colors.main : props.theme.colors.text)};
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 12.5px ${props => props.theme.spacingUnit}px;
|
padding: 12.5px ${props => props.theme.spacingUnit}px;
|
||||||
|
${({ depth, type, theme }) => type === 'section' && depth > 1 && 'padding-left: ' + theme.spacingUnit * 2 + 'px;' || ''}
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
font-family: ${props => props.theme.headingsFont.family};
|
font-family: ${props => props.theme.headingsFont.family};
|
||||||
|
@ -138,7 +140,7 @@ export const MenuItemLabel = withProps<{
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const MenuItemTitle = withProps<{ width?: string }>(styled.span)`
|
export const MenuItemTitle = withProps<{ width?: string }>(styled.span) `
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: ${props => (props.width ? props.width : 'auto')};
|
width: ${props => (props.width ? props.width : 'auto')};
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class MenuBuilder {
|
||||||
const group = new GroupModel('section', heading, parent);
|
const group = new GroupModel('section', heading, parent);
|
||||||
group.depth = depth;
|
group.depth = depth;
|
||||||
if (heading.items) {
|
if (heading.items) {
|
||||||
group.items = mapHeadingsDeep(group, group.items, depth + 1);
|
group.items = mapHeadingsDeep(group, heading.items, depth + 1);
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,9 @@ describe('Markdown renderer', () => {
|
||||||
expect(Object.keys(renderer.headings)).toHaveLength(1);
|
expect(Object.keys(renderer.headings)).toHaveLength(1);
|
||||||
expect(renderer.headings[0].name).toEqual('Sub Intro');
|
expect(renderer.headings[0].name).toEqual('Sub Intro');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return a level-2 heading as a child of level-1', () => {
|
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).toHaveLength(1);
|
||||||
expect(headings[0].name).toEqual('Introduction');
|
expect(headings[0].name).toEqual('Introduction');
|
||||||
expect(headings[0].items).toBeDefined();
|
expect(headings[0].items).toBeDefined();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user