Skip to content

Commit 82a2fda

Browse files
authored
Merge pull request #54 from IATI/ml/code-block-styles
Add code block styles
2 parents 6ea4c52 + 131f81b commit 82a2fda

File tree

5 files changed

+56
-9
lines changed

5 files changed

+56
-9
lines changed

src/scss/tokens/_font.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$font-stack-heading: "Hanken Grotesk", sans-serif;
22
$font-stack-body: "Nunito Sans", sans-serif;
3-
$font-stack-monospace: monospace;
3+
$font-stack-monospace: "Roboto Mono", monospace;
44

55
$font-weight-body: 400;
66
$font-weight-body-strong: 600;

src/scss/tokens/fonts.mdx

+19
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ import tokens from "./_tokens.module.scss";
5151
"line-height-body": tokens["line-height-body"],
5252
}}
5353
/>
54+
55+
## Code
56+
57+
**Font:** Roboto Mono
58+
59+
<Typeset
60+
fontSizes={["1.2rem", "1.0rem", "0.8rem"]}
61+
fontWeight={tokens["font-weight-body"]}
62+
sampleText="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
63+
fontFamily={tokens["font-stack-monospace"]}
64+
/>
65+
66+
<TokensTable
67+
tokens={{
68+
"font-stack-monospace": tokens["font-stack-monospace"],
69+
"font-weight-body": tokens["font-weight-body"],
70+
"line-height-body": tokens["line-height-body"],
71+
}}
72+
/>

src/scss/typography/_code.scss

+26-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,41 @@
22
@use "../tokens/font" as *;
33
@use "../tokens/spacing" as *;
44

5+
:not(pre) > code,
56
.iati-code {
7+
background-color: $color-grey-10;
8+
border: 1px solid $color-grey-20;
9+
border-radius: 4px;
10+
color: $color-grey-90;
611
font-family: $font-stack-monospace;
12+
padding: 0.1em 0.2em;
13+
}
14+
15+
pre > code,
16+
.iati-code--block {
717
background-color: $color-grey-10;
8-
color: #000;
918
border: 1px solid $color-grey-20;
19+
border-radius: 4px;
20+
color: $color-grey-90;
21+
display: block;
22+
font-family: $font-stack-monospace;
23+
overflow-x: scroll;
24+
padding: $padding-block;
25+
}
26+
27+
.iati-reference {
28+
background-color: #fff;
29+
border: 1px solid $color-grey-20;
30+
border-radius: 4px;
31+
color: $color-blue-80;
32+
font-family: $font-stack-monospace;
1033
padding: 0.1em 0.2em;
1134

1235
&--block {
36+
border-radius: 4px;
1337
display: block;
14-
padding: $padding-block;
1538
overflow-x: scroll;
39+
padding: $padding-block;
1640
}
1741
}
1842

src/scss/typography/_index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:ital,wght@0,100..900;1,100..900&display=swap");
66
@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap");
7+
@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap");

src/scss/typography/typography.stories.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,17 @@ export const Quotes: Story = {
122122

123123
export const Code: Story = {
124124
render: () => html`
125-
<h3>This heading contains <span class="iati-code">inline code</span>.</h3>
125+
<h3>This heading contains <code>inline code</code>.</h3>
126+
<p>This paragraph contains <code>inline code</code>.</p>
127+
<pre>
128+
<code>
129+
print("This is a block of code")
130+
</code>
131+
</pre>
126132
<p>
127-
This paragraph contains
128-
<span class="iati-code">inline code</span>.
133+
This paragraph contains a <span class="iati-reference">reference</span> to
134+
an element in the standard.
129135
</p>
130-
<code class="iati-code iati-code--block">
131-
<span>print("This is a block of code")</span>
132-
</code>
133136
<p>
134137
This paragraph contains a key-binding:
135138
<kbd class="iati-kbd">Ctrl</kbd> + <kbd class="iati-kbd">C</kbd>

0 commit comments

Comments
 (0)