Skip to content

Commit f403d42

Browse files
Elliott Marquezcopybara-github
authored andcommitted
docs(catalog): refactor catalog to use material panel layout
PiperOrigin-RevId: 537973428
1 parent 88b5cfe commit f403d42

File tree

12 files changed

+181
-126
lines changed

12 files changed

+181
-126
lines changed

catalog/site/css/components.css

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ figure {
4040

4141
catalog-component-header img {
4242
height: var(--catalog-header-image-height, 50%);
43-
width: var(--catalog-header-image-width, 100%);
4443
}
4544

4645
.figure-wrapper {
@@ -97,7 +96,7 @@ tr th:last-of-type {
9796
th {
9897
background-color: var(--md-sys-color-surface-container);
9998
text-shadow: 0 1px 1px var(--md-sys-color-surface-container-lowest);
100-
color: var(--md-sys-color-on-surface-container);
99+
color: var(--md-sys-color-on-surface);
101100
font-size: 1.25em;
102101
}
103102

@@ -111,19 +110,19 @@ th {
111110
}
112111

113112
tr th:first-of-type {
114-
border-start-start-radius: 28px;
113+
border-start-start-radius: var(--catalog-shape-xl);
115114
}
116115

117116
tr th:last-of-type {
118-
border-start-end-radius: 28px;
117+
border-start-end-radius: var(--catalog-shape-xl);
119118
}
120119

121120
tr:last-of-type td:first-of-type {
122-
border-end-start-radius: 28px;
121+
border-end-start-radius: var(--catalog-shape-xl);
123122
}
124123

125124
tr:last-of-type td:last-of-type {
126-
border-end-end-radius: 28px;
125+
border-end-end-radius: var(--catalog-shape-xl);
127126
}
128127

129128
/* Hides offscreen accesible text for h1,2,3 hover links. */
@@ -158,7 +157,7 @@ a .offscreen {
158157
align-items: center;
159158
position: absolute;
160159
inset: 0;
161-
inset-inline-start: calc(-1 * var(--_content-padding) + 4px);
160+
inset-inline-start: calc(-1 * var(--catalog-spacing-xl) + 4px);
162161
opacity: 0;
163162
font-size: calc(1.5em - 4px);
164163
transition: opacity 0.2s cubic-bezier(0.2, 0, 0, 1);

catalog/site/css/global.css

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@
2626

2727
:root {
2828
font-family: 'Google Sans', Roboto, system-ui;
29-
background-color: var(--md-sys-color-background);
30-
color: var(--md-sys-color-on-background);
31-
--catalog-top-app-bar-height: 48px;
32-
--catalog-top-app-bar-padding-block: 12px;
33-
scroll-padding-block-start: calc(var(--catalog-top-app-bar-height) + var(--catalog-top-app-bar-padding-block) * 2);
34-
29+
background-color: var(--md-sys-color-surface-container);
30+
color: var(--md-sys-color-on-surface);
3531
/* These values are copied from mio */
3632
--catalog-display-xl-font-size: 88px;
3733
--catalog-display-m-font-size: 45px;
@@ -40,6 +36,17 @@
4036
--catalog-title-s-font-size: 14px;
4137
--catalog-body-l-font-size: 16px;
4238
--catalog-body-m-font-size: 14px;
39+
--catalog-shape-xl: 28px;
40+
--catalog-shape-l: 16px;
41+
--catalog-shape-m: 12px;
42+
--catalog-shape-s: 8px;
43+
--catalog-shape-xs: 4px;
44+
--catalog-spacing-xl: 28px;
45+
--catalog-spacing-l: 16px;
46+
--catalog-spacing-m: 12px;
47+
--catalog-spacing-s: 8px;
48+
--catalog-top-app-bar-height: calc(48px + 2 * var(--catalog-spacing-m));
49+
scroll-padding-block-start: calc(var(--catalog-top-app-bar-height) + var(--catalog-top-app-bar-padding-block) * 2);
4350
}
4451

4552
@media screen and (max-width: 600px) {
@@ -48,6 +55,8 @@
4855
--catalog-title-l-font-size: 16px;
4956
--catalog-body-l-font-size: 14px;
5057
--catalog-body-m-font-size: 12px;
58+
/* Mostly to accommodate content padding on small screens */
59+
--catalog-spacing-xl: 16px;
5160
}
5261
}
5362

@@ -70,15 +79,27 @@ nav-drawer md-list-item-link[selected] {
7079
--md-list-item-list-item-container-color: var(--md-sys-color-surface-container-highest);
7180
}
7281

82+
@media (forced-colors: active) {
83+
nav-drawer md-list-item-link[selected] {
84+
border: 4px double CanvasText;
85+
}
86+
87+
nav-drawer md-list-item-link {
88+
border-radius: var(--catalog-shape-xl);
89+
border: 1px solid CanvasText;
90+
}
91+
}
92+
7393
md-list {
7494
--md-list-container-color: transparent;
95+
--md-list-item-list-item-container-color: transparent;
7596
display: block;
76-
margin-inline: 12px;
97+
margin-inline: var(--catalog-spacing-m);
7798
min-width: unset;
7899
}
79100

80101
md-list-item-link {
81-
margin-block: 12px;
102+
margin-block: var(--catalog-spacing-m);
82103
display: block;
83104
}
84105

catalog/site/css/home-page.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
h1,
88
.subtitle {
99
text-align: center;
10+
margin-block-start: 0;
1011
}

catalog/site/css/syntax-highlight.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ code,
5959
code[class*="language-"],
6060
pre[class*="language-"] {
6161
color: var(--md-sys-color-on-surface-variant);
62-
text-shadow: 0 1px 1px var(--md-sys-color-background);
62+
text-shadow: 0 1px 1px var(--md-sys-color-surface);
6363
font-family: 'Google Sans Mono', Menlo, Monaco, "Courier New", monospace;
6464
direction: ltr;
6565
text-align: left;

catalog/src/components/catalog-component-header-title.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ export class CatalogComponentHeaderTitle extends LitElement {
2727
justify-content: center;
2828
border-radius: var(--catalog-image-border-radius);
2929
padding: 56px;
30-
background-color: var(--md-sys-color-surface-container);
31-
color: var(--md-sys-color-on-surface-container);
30+
/* It has no border so we need it to be a different color from the top app
31+
* bar and nav drawer.
32+
*/
33+
background-color: var(--md-sys-color-surface-variant);
34+
color: var(--md-sys-color-on-surface-variant);
3235
}
3336
3437
slot::slotted(h1) {

catalog/src/components/catalog-component-header.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CatalogComponentHeader extends LitElement {
2929
static styles = css`
3030
:host {
3131
display: block;
32-
--catalog-image-border-radius: 24px;
32+
--catalog-image-border-radius: var(--catalog-shape-xl);
3333
container: host / inline-size;
3434
position: relative;
3535
}
@@ -56,7 +56,8 @@ export class CatalogComponentHeader extends LitElement {
5656
}
5757
5858
.image {
59-
background-color: var(--md-sys-color-surface-container);
59+
/* Color needs to differ from top-app-bar and sidebar */
60+
background-color: var(--md-sys-color-surface-variant);
6061
border-radius: var(--catalog-image-border-radius);
6162
overflow: hidden;
6263
margin-block-start: 16px;
@@ -78,7 +79,8 @@ export class CatalogComponentHeader extends LitElement {
7879
justify-content: center;
7980
}
8081
81-
@container (width > 1100px) {
82+
/* fit ipad pro at least */
83+
@container (width > 1000px) {
8284
div {
8385
display: grid;
8486
grid-gap: 8px;

0 commit comments

Comments
 (0)