Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 64b0710

Browse files
authored
Typesetting improvements (#446)
* switch from em to rem When a table specimen is used with a `baseFontSize` other than tha default `16px` the table cells are displayed with a strange font size. That's because the font size of the `table` gets multiplied with the one of the `cell` or the `paragraph`. For example for `baseFontSize` set to `18px`: `18 / 16 = 1.125em` (which will result in a calculated font size of `22.7833px` (`1.25 * 1.25 * 18`). Switching to rem (root em) solves this issue. * Fix elements nested in blockquotes * Add more variations to test page * Improve headings in hints * Remove unnecessary text styles on <table> * Add comment about blockquote style * Define letter spacing * Remove unused sidebar theming option * More specific styling of sidebar Doesn't solve #347 completely but addresses some potential issues with global stylesheets * More spefic list styling in content * More specific link styling in content * More specific navigation bar styling Also changes unsemantic headings to divs, fixes #444 * More specific link styling in Download specimen Also removes non-semantic headings, fixes #444 * More layout fixes * Fix nested list margin * Text fixes in color specimens * Fix responsive tabs text styles * Fix hint link styles * Update test snapshots * Make blockquoteStyle lazy to fix font loading `@import`s in `insertRule` only work if they're the first rule https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule#Restrictions * Upgrade create-emotion * Fix single active link padding
1 parent a068c52 commit 64b0710

File tree

18 files changed

+215
-99
lines changed

18 files changed

+215
-99
lines changed

docs/configuration/theming.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Theming Catalog
32

43
### `logoSrc`
@@ -56,7 +55,7 @@ Used in the navigation bar.
5655
ResponsiveTabs (tab text), Download specimen (title text).
5756
Typography: headings.
5857

59-
##### `sidebarColor{,Active,Text,TextActive,Line,Heading}`
58+
##### `sidebarColor{,Text,TextActive,Line,Heading}`
6059

6160
Used in the sidebar.
6261

@@ -73,4 +72,3 @@ codeStyles: {
7372
tag: {color: '#FF5555', fontWeight: 'bold'}
7473
}
7574
```
76-

docs/test/test.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ An ordinary paragraph can follow after the lead text. It can repeat things. It c
66

77
> Blockquotes can appear multiple times, even though that might not make too much sense … Inline elements are styled nicely: text [link](http://example.com) text _italic_ text **bold** text `.code` text.
88
>
9+
> ## Heading in a blockquote
10+
>
911
> * Blockquotes
1012
> * With lists
13+
>
14+
> > Nested blockquote
1115
1216
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
1317
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
1418
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
15-
consequat. Inline elements are styled nicely: text [link](http://example.com) text _italic_ text **bold** text `(...args) => {return args;}` text.
19+
consequat. Inline elements are styled nicely: text [link](http://example.com) text _italic_ text **bold** text `(...args) => {return args;}` text. ~~Strikethrough text~~
1620

1721
Link [to a heading](#jump-to-me)
1822

@@ -37,6 +41,14 @@ Plain email foo@bar.com
3741
3842
Some `inline code`, yeah!
3943
44+
## Subheading
45+
### Subheading
46+
#### Subheading
47+
##### Subheading
48+
###### Subheading
49+
50+
> Foo bar
51+
4052
And a [link](#hints-with-content), and another one: https://catalog.style
4153
```
4254

@@ -223,3 +235,7 @@ Similar to button, but looks more important.
223235
```
224236
<a class="important-button" href="#">Important Button</a>
225237
```
238+
239+
> a block quote
240+
241+
> another one

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"babel-runtime": "^6.26.0",
5858
"babel-standalone": "^6.26.0",
5959
"chalk": "^2.1.0",
60-
"create-emotion": "^9.1.2",
60+
"create-emotion": "^9.2.6",
6161
"create-react-class": "^15.6.0",
6262
"css-loader": "^0.28.7",
6363
"d3-color": "^1.1.0",

src/DefaultTheme.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default {
2828
brandColor: "#003B5C",
2929

3030
sidebarColor: "#FFFFFF",
31-
sidebarColorActive: "#D1312E",
3231
sidebarColorText: "#003B5C",
3332
sidebarColorTextActive: "#FF5555",
3433
sidebarColorLine: "#EBEBEB",

src/__snapshots__/configure.test.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ Object {
132132
"pageHeadingHeight": 200,
133133
"pageHeadingTextColor": "#fff",
134134
"sidebarColor": "#FFFFFF",
135-
"sidebarColorActive": "#D1312E",
136135
"sidebarColorHeading": "#003B5C",
137136
"sidebarColorLine": "#EBEBEB",
138137
"sidebarColorText": "#003B5C",
@@ -275,7 +274,6 @@ Object {
275274
"pageHeadingHeight": 200,
276275
"pageHeadingTextColor": "#fff",
277276
"sidebarColor": "#FFFFFF",
278-
"sidebarColorActive": "#D1312E",
279277
"sidebarColorHeading": "#003B5C",
280278
"sidebarColorLine": "#EBEBEB",
281279
"sidebarColorText": "#003B5C",
@@ -452,7 +450,6 @@ Object {
452450
"pageHeadingHeight": 200,
453451
"pageHeadingTextColor": "#fff",
454452
"sidebarColor": "#FFFFFF",
455-
"sidebarColorActive": "#D1312E",
456453
"sidebarColorHeading": "#003B5C",
457454
"sidebarColorLine": "#EBEBEB",
458455
"sidebarColorText": "#003B5C",

src/components/App/AppLayout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const getStyles = (theme, sidebarVisible) => ({
5050
},
5151
sideNav: {
5252
background: theme.sidebarColor,
53+
boxSizing: "content-box",
5354
color: "#fff",
5455
overflowY: "auto",
5556
position: "fixed",

src/components/App/NavigationBar.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ const verticalPadding = 28;
1111
const horizontalPadding = 21;
1212

1313
function getStyles(theme) {
14+
const baseLinkStyle = {
15+
color: theme.navBarTextColor,
16+
display: "block",
17+
fontFamily: theme.fontFamily,
18+
textDecoration: "none",
19+
border: "none",
20+
background: "none",
21+
transition: "none"
22+
};
1423
return {
1524
navbar: {
1625
width: "100%",
@@ -22,7 +31,7 @@ function getStyles(theme) {
2231
verticalAlign: "top",
2332
width: "50%",
2433
transition: ".2s opacity",
25-
":hover": {
34+
"&:hover, &:focus, &:focus-within": {
2635
opacity: 0.65
2736
}
2837
},
@@ -37,17 +46,14 @@ function getStyles(theme) {
3746
rightNavLink: {
3847
padding: `${verticalPadding}px ${horizontalPadding}px ${verticalPadding}px 0`,
3948
textAlign: "right",
40-
borderLeft: `1px solid ${theme.background}`,
4149
"@media (min-width: 1000px)": {
4250
padding: `${verticalPadding}px ${horizontalPadding *
4351
2}px ${verticalPadding}px 0`
4452
}
4553
},
4654
link: {
47-
color: theme.navBarTextColor,
48-
display: "block",
49-
fontFamily: theme.fontFamily,
50-
textDecoration: "none"
55+
...baseLinkStyle,
56+
"&:hover, &:focus, &:active, &:visited": baseLinkStyle
5157
},
5258
leftLinkIcon: {
5359
display: "none",
@@ -132,10 +138,12 @@ class NavigationBar extends React.Component {
132138
>
133139
{leftIcon}
134140
<div className={css(styles.linklabels)}>
135-
<h4 className={css(styles.linkSuperTitle)}>
141+
<div className={css(styles.linkSuperTitle)}>
136142
{previousPage.superTitle}
137-
</h4>
138-
<h3 className={css(styles.linkTitle)}>{previousPage.title}</h3>
143+
</div>
144+
<div className={css(styles.linkTitle)}>
145+
{previousPage.title}
146+
</div>
139147
</div>
140148
</Link>
141149
)}
@@ -147,10 +155,10 @@ class NavigationBar extends React.Component {
147155
className={css({ ...styles.link, ...styles.rightNavLink })}
148156
>
149157
<div className={css(styles.linklabels)}>
150-
<h4 className={css(styles.linkSuperTitle)}>
158+
<div className={css(styles.linkSuperTitle)}>
151159
{nextPage.superTitle}
152-
</h4>
153-
<h3 className={css(styles.linkTitle)}>{nextPage.title}</h3>
160+
</div>
161+
<div className={css(styles.linkTitle)}>{nextPage.title}</div>
154162
</div>
155163
{rightIcon}
156164
</Link>

src/components/Content/Markdown.js

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,50 @@ const baseListStyle = {
1111
paddingLeft: "2rem"
1212
};
1313

14+
// Defined with `css`, so it can be used as a selector for nested elements
15+
// For example: `Paragraph`
16+
const blockquoteStyle = () =>
17+
css({
18+
quotes: "none",
19+
margin: "48px 0 32px 0",
20+
width: "100%",
21+
"&::before, &::after": { content: "none" },
22+
"& > :first-child": { marginTop: 0 },
23+
"& > :last-child": { marginBottom: 0 },
24+
"& + &": { marginTop: 0 }
25+
});
26+
1427
export const Paragraph = styled("p", (props, { theme }) => ({
1528
...text(theme),
1629
flexBasis: "100%",
30+
[`.${blockquoteStyle()} &`]: { fontSize: getFontSize(theme, 1) },
1731
margin: `16px 0 0 0`
1832
}));
19-
export const UnorderedList = styled("ul", (props, { theme }) => ({
33+
export const UnorderedList = styled("ul", {
2034
...baseListStyle,
21-
...text(theme),
2235
listStyle: "disc",
2336
marginTop: "16px",
24-
marginBottom: 0
25-
}));
26-
export const OrderedList = styled("ol", (props, { theme }) => ({
37+
marginBottom: 0,
38+
"& > li": { listStyle: "disc" }
39+
});
40+
export const OrderedList = styled("ol", {
2741
...baseListStyle,
28-
...text(theme),
2942
listStyle: "ordinal",
3043
marginTop: "16px",
31-
marginBottom: 0
32-
}));
44+
marginBottom: 0,
45+
"& > li": { listStyle: "ordinal" }
46+
});
3347
export const ListItem = styled("li", (props, { theme }) => ({
3448
...text(theme),
35-
"& > :first-child": { marginTop: 0 },
49+
[`.${blockquoteStyle()} &`]: { fontSize: getFontSize(theme, 1) },
50+
margin: 0,
51+
padding: 0,
52+
"& > :first-child, & > ul, & > ol": { marginTop: 0 },
3653
"& > :last-child": { marginBottom: 0 }
3754
}));
38-
export const BlockQuote = styled("blockquote", (props, { theme }) => ({
39-
fontSize: getFontSize(theme, 1),
40-
quotes: "none",
41-
margin: "48px 0 32px 0",
42-
"&::before, &::after": { content: "none" },
43-
"& > :first-child": { marginTop: 0 },
44-
"& > :last-child": { marginBottom: 0 },
45-
"+ blockquote": { marginBottom: 0 }
46-
}));
55+
export const BlockQuote = props => (
56+
<blockquote className={blockquoteStyle()} {...props} />
57+
);
4758
export const Hr = styled("hr", {
4859
border: "none",
4960
flexBasis: "100%",
@@ -65,21 +76,35 @@ export const CodeSpan = styled("code", (props, { theme }) => ({
6576
padding: "0.12em 0.2em",
6677
textIndent: 0
6778
}));
68-
export const Del = styled("del", (props, { theme }) => text(theme));
79+
export const Del = styled("del", {
80+
textDecoration: "line-through"
81+
});
6982
export const Image = styled("img", {
7083
maxWidth: "100%"
7184
});
7285

73-
export const Link = (props, { catalog: { theme } }) => (
74-
<BaseLink
75-
className={css({
76-
color: theme.linkColor,
77-
textDecoration: "none",
78-
":hover": { textDecoration: "underline" }
79-
})}
80-
{...props}
81-
/>
82-
);
86+
export const Link = (props, { catalog: { theme } }) => {
87+
const baseLinkStyle = {
88+
color: theme.linkColor,
89+
transition: "none",
90+
border: "none",
91+
background: "none",
92+
textDecoration: "none"
93+
};
94+
return (
95+
<BaseLink
96+
className={css({
97+
...baseLinkStyle,
98+
"&:active, &:visited": baseLinkStyle,
99+
"&:hover, &:focus": {
100+
...baseLinkStyle,
101+
textDecoration: "underline"
102+
}
103+
})}
104+
{...props}
105+
/>
106+
);
107+
};
83108

84109
Link.contextTypes = {
85110
catalog: catalogShape

0 commit comments

Comments
 (0)