Skip to content

Commit a084532

Browse files
committed
fix: fix second-level heading in description
1 parent 8662176 commit a084532

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/components/Markdown/styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export const markdownCss = css`
2222
margin-top: 0;
2323
}
2424
25+
h2 {
26+
${headerCommonMixin(2)};
27+
color: ${props => props.theme.colors.text};
28+
}
29+
2530
code {
2631
color: #e53935;
2732
background-color: rgba(38, 50, 56, 0.04);

src/components/SideMenu/MenuItem.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export class MenuItem extends React.Component<MenuItemProps> {
4444
{item.type === 'operation' ? (
4545
<OperationMenuItemContent item={item as OperationModel} />
4646
) : (
47-
<MenuItemLabel depth={item.depth} active={item.active}>
48-
<MenuItemTitle title={item.name}>{item.name}</MenuItemTitle>
49-
{(item.depth > 0 &&
50-
item.items.length > 0 && (
51-
<ShelfIcon float={'right'} direction={item.active ? 'down' : 'right'} />
52-
)) ||
53-
null}
54-
</MenuItemLabel>
55-
)}
47+
<MenuItemLabel depth={item.depth} active={item.active} type={item.type}>
48+
<MenuItemTitle title={item.name}>{item.name}</MenuItemTitle>
49+
{(item.depth > 0 &&
50+
item.items.length > 0 && (
51+
<ShelfIcon float={'right'} direction={item.active ? 'down' : 'right'} />
52+
)) ||
53+
null}
54+
</MenuItemLabel>
55+
)}
5656
{!withoutChildren &&
5757
item.items &&
5858
item.items.length > 0 && (

src/components/SideMenu/styled.elements.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styled, { css, withProps } from '../../styled-components';
55

66
export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({
77
className: props => `operation-type ${props.type}`,
8-
})`
8+
}) `
99
width: 26px;
1010
display: inline-block;
1111
height: ${props => props.theme.code.fontSize};;
@@ -70,7 +70,7 @@ function menuItemActiveBg(depth): string {
7070
}
7171
}
7272

73-
export const MenuItemUl = withProps<{ active: boolean }>(styled.ul)`
73+
export const MenuItemUl = withProps<{ active: boolean }>(styled.ul) `
7474
margin: 0;
7575
padding: 0;
7676
@@ -81,7 +81,7 @@ export const MenuItemUl = withProps<{ active: boolean }>(styled.ul)`
8181
${props => (props.active ? '' : 'display: none;')};
8282
`;
8383

84-
export const MenuItemLi = withProps<{ depth: number }>(styled.li)`
84+
export const MenuItemLi = withProps<{ depth: number }>(styled.li) `
8585
list-style: none inside none;
8686
overflow: hidden;
8787
text-overflow: ellipsis;
@@ -114,17 +114,19 @@ export const MenuItemLabel = withProps<{
114114
depth: number;
115115
active: boolean;
116116
deprecated?: boolean;
117+
type?: string;
117118
}>(styled.label).attrs({
118119
role: 'menuitem',
119120
className: props =>
120121
classnames('-depth' + props.depth, {
121122
active: props.active,
122123
}),
123-
})`
124+
}) `
124125
cursor: pointer;
125126
color: ${props => (props.active ? props.theme.colors.main : props.theme.colors.text)};
126127
margin: 0;
127128
padding: 12.5px ${props => props.theme.spacingUnit}px;
129+
${({ depth, type, theme }) => type === 'section' && depth > 1 && 'padding-left: ' + theme.spacingUnit * 2 + 'px;' || ''}
128130
display: flex;
129131
justify-content: space-between;
130132
font-family: ${props => props.theme.headingsFont.family};
@@ -138,7 +140,7 @@ export const MenuItemLabel = withProps<{
138140
}
139141
`;
140142

141-
export const MenuItemTitle = withProps<{ width?: string }>(styled.span)`
143+
export const MenuItemTitle = withProps<{ width?: string }>(styled.span) `
142144
display: inline-block;
143145
vertical-align: middle;
144146
width: ${props => (props.width ? props.width : 'auto')};

src/services/MenuBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class MenuBuilder {
6262
const group = new GroupModel('section', heading, parent);
6363
group.depth = depth;
6464
if (heading.items) {
65-
group.items = mapHeadingsDeep(group, group.items, depth + 1);
65+
group.items = mapHeadingsDeep(group, heading.items, depth + 1);
6666
}
6767
return group;
6868
});

src/services/__tests__/MarkdownRenderer.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ describe('Markdown renderer', () => {
1111
expect(Object.keys(renderer.headings)).toHaveLength(1);
1212
expect(renderer.headings[0].name).toEqual('Sub Intro');
1313
});
14+
1415
test('should return a level-2 heading as a child of level-1', () => {
15-
const headings = renderer.extractHeadings('# Introduction \n ## Sub Intro', false);
16+
const headings = renderer.extractHeadings('# Introduction \n ## Sub Intro');
1617
expect(headings).toHaveLength(1);
1718
expect(headings[0].name).toEqual('Introduction');
1819
expect(headings[0].items).toBeDefined();

0 commit comments

Comments
 (0)