Skip to content

Commit fbed917

Browse files
Elliott Marquezcopybara-github
authored andcommitted
docs(catalog): make code block border-radius visible to app & fix nowrap
Oops I forgot to copy this over form my local env to internal code review. In this CL I expose --catalog-code-block-border-radius so that it's available to the copy button component. Additionally, run syntax-highlight.css through prettier because my old formatter was the built-in vscode one. Also removed nowrap from the navigation pane since I just went with a fixed width. PiperOrigin-RevId: 538700609
1 parent 7f33702 commit fbed917

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

catalog/site/css/syntax-highlight.css

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
--playground-code-font-size: var(--__code-block-font-size);
1717
--playground-code-background: var(--md-sys-color-surface-variant);
1818
--playground-code-default-color: var(--md-sys-color-on-surface-variant);
19-
--playground-code-font-family: 'Google Sans Mono', Menlo, Monaco, "Courier New", monospace;
19+
--playground-code-font-family: 'Google Sans Mono', Menlo, Monaco,
20+
'Courier New', monospace;
2021
--playground-code-callee-color: var(--md-sys-color-primary);
2122
--playground-code-comment-color: var(--md-sys-color-on-surface-dim);
2223
--playground-code-operator-color: var(--md-sys-color-on-surface);
@@ -35,18 +36,25 @@
3536
--playground-code-linenumber-color: var(--md-sys-color-outline);
3637
--playground-code-qualifier-color: var(--md-sys-color-tertiary);
3738
--playground-code-cursor-color: var(--md-sys-color-on-surface-variant);
38-
--playground-preview-toolbar-background: var(--md-sys-color-surface-container-high);
39+
--playground-preview-toolbar-background: var(
40+
--md-sys-color-surface-container-high
41+
);
3942
--playground-preview-toolbar-foreground-color: var(--md-sys-color-on-surface);
43+
44+
/* perfect circle of one line is (padding-block * 2 + (line-height: 1.5x font size)) / 2 */
45+
--catalog-code-block-border-radius: calc(
46+
(2 * var(--__code-block-font-size) + 1.5 * var(--__code-block-font-size)) /
47+
2
48+
);
4049
}
4150

4251
/* Formats the code boxes themselves */
4352
.example playground-file-editor,
44-
pre[class*="language-"] {
53+
pre[class*='language-'] {
4554
padding: var(--__code-block-font-size);
4655
/* Remove the extra hard coded 3px from line number padding. */
4756
padding-inline-start: calc(var(--__code-block-font-size) - 3px);
48-
/* perfect circle of one line is (padding * 2 + (line-height: 1.5x font size)) / 2 */
49-
border-radius: calc((2 * var(--__code-block-font-size) + 1.5 * var(--__code-block-font-size))/2);
57+
border-radius: var(--catalog-code-block-border-radius);
5058
}
5159

5260
playground-file-editor {
@@ -56,11 +64,11 @@ playground-file-editor {
5664
}
5765

5866
code,
59-
code[class*="language-"],
60-
pre[class*="language-"] {
67+
code[class*='language-'],
68+
pre[class*='language-'] {
6169
color: var(--md-sys-color-on-surface-variant);
6270
text-shadow: 0 1px 1px var(--md-sys-color-surface);
63-
font-family: 'Google Sans Mono', Menlo, Monaco, "Courier New", monospace;
71+
font-family: 'Google Sans Mono', Menlo, Monaco, 'Courier New', monospace;
6472
direction: ltr;
6573
text-align: left;
6674
word-spacing: normal;
@@ -74,20 +82,20 @@ pre[class*="language-"] {
7482
hyphens: none;
7583
}
7684

77-
pre[class*="language-"],
78-
:not(pre)>code[class*="language-"] {
85+
pre[class*='language-'],
86+
:not(pre) > code[class*='language-'] {
7987
background: var(--md-sys-color-surface-container);
8088
border: 1px solid var(--md-sys-color-outline);
8189
}
8290

8391
/* Code blocks */
84-
pre[class*="language-"] {
92+
pre[class*='language-'] {
8593
overflow: auto;
8694
scrollbar-width: none;
8795
}
8896

8997
/* Inline code */
90-
:not(pre)>code[class*="language-"] {
98+
:not(pre) > code[class*='language-'] {
9199
padding: 5px 10px;
92100
line-height: 1;
93101
border-radius: 3px;
@@ -107,7 +115,7 @@ pre[class*="language-"] {
107115
}
108116

109117
.token.namespace {
110-
opacity: .7;
118+
opacity: 0.7;
111119
}
112120

113121
.token.tag,
@@ -147,4 +155,4 @@ pre[class*="language-"] {
147155
.token.important,
148156
.token.deliminator {
149157
color: var(--md-sys-color-error);
150-
}
158+
}

catalog/src/components/nav-drawer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ import {SignalElement} from '../signals/signal-element.js';
219219
}
220220
221221
.pane.toc h2 {
222-
white-space: nowrap;
223222
margin-block: var(--catalog-spacing-s) var(--catalog-spacing-m);
224223
font-size: var(--catalog-headline-s-font-size);
225224
}

0 commit comments

Comments
 (0)