Skip to content

Commit 697ecf6

Browse files
authored
Merge pull request #919 from lit/edit-this-page
2 parents 73471ab + f93c133 commit 697ecf6

File tree

4 files changed

+69
-18
lines changed

4 files changed

+69
-18
lines changed

packages/lit-dev-content/site/_includes/articles.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ <h1>{{ title }}</h1>
5555

5656
{% block articleContent %}{{ content | safe }}{% endblock %}
5757

58+
{% set editableDocumentsRegex = r/articles\/article\/.+/ %}
59+
{% if editableDocumentsRegex.test(page.inputPath) %}
60+
<p id="edit-page-link">
61+
<a
62+
href="https://github.com/lit/lit.dev/edit/main/packages/lit-dev-content/{{ page.inputPath }}">
63+
Edit this page
64+
<lazy-svg
65+
loading="visible"
66+
svg-aria-hidden
67+
href="{{ site.baseurl }}/images/icons/edit-square.svg#icon">
68+
</lazy-svg>
69+
</a>
70+
</p>
71+
{% endif %}
72+
5873
{% set navItems = collections[collection] | eleventyNavigation | flattenNavigationAndAddNextPrev %}
5974
{% for item in navItems %}
6075
{% if item.url === page.url and item.parent %}
@@ -101,5 +116,4 @@ <h1>{{ title }}</h1>
101116
</article>
102117
</div>
103118

104-
105119
{% endblock %}

packages/lit-dev-content/site/_includes/docs.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ <h2><a href="#content">Contents: {{ title }}</a></h2>
4040
</div>
4141
</nav>
4242
{% endif %}
43+
<litdev-edit-this-page filepath="{{ page.inputPath }}"></litdev-edit-this-page>
4344
</div>
4445

4546
<div id="articleWrapper">
@@ -57,6 +58,19 @@ <h1>{{ title }}</h1>
5758

5859
{{ content | safe }}
5960

61+
62+
<p id="edit-page-link">
63+
<a
64+
href="https://github.com/lit/lit.dev/edit/main/packages/lit-dev-content/{{ page.inputPath }}">
65+
Edit this page
66+
<lazy-svg
67+
loading="visible"
68+
svg-aria-hidden
69+
href="{{ site.baseurl }}/images/icons/edit-square.svg#icon">
70+
</lazy-svg>
71+
</a>
72+
</p>
73+
6074
{% set navItems = collections[collection] | eleventyNavigation | flattenNavigationAndAddNextPrev %}
6175
{% for item in navItems %}
6276
{% if item.url === page.url and item.parent %}
@@ -101,5 +115,4 @@ <h1>{{ title }}</h1>
101115
</article>
102116
</div>
103117

104-
105118
{% endblock %}

packages/lit-dev-content/site/css/docs.css

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ main {
1414
--docs-nav-color: #242424;
1515
--playground-code-background: #fafafa;
1616
--code-border: 1px solid #ddd;
17+
--docs-on-surface-color: #3e3e3e;
1718

1819
/* IMPORTANT: If any of the following variables change, one or both of the
1920
@media query thresholds below need to be updated. */
@@ -22,8 +23,8 @@ main {
2223
--docs-toc-min-width: 5em;
2324
--docs-article-min-width: 30em;
2425
--docs-article-max-width: 49em;
25-
--docs-article-margin-horizontal: 3em;
26-
--docs-margin-top: 32px;
26+
--docs-article-margin-inline: 3em;
27+
--docs-margin-block: 32px;
2728

2829
display: grid;
2930
grid-template-columns:
@@ -37,7 +38,7 @@ main {
3738
font-family: "Open Sans", sans-serif;
3839

3940
background: var(--color-light-gray);
40-
padding-top: var(--docs-margin-top);
41+
padding-block: var(--docs-margin-block);
4142
}
4243

4344
/* ------------------------------------
@@ -46,11 +47,11 @@ main {
4647

4748
article {
4849
max-width: var(--docs-article-max-width);
49-
padding: var(--docs-margin-top) var(--docs-article-margin-horizontal) var(--docs-margin-top)
50-
var(--docs-article-margin-horizontal);
50+
padding-block: var(--docs-margin-block);
51+
padding-inline: var(--docs-article-margin-inline);
5152
line-height: 1.8em;
5253
font-size: 0.88889em; /* 16px / 18px basis */
53-
color: #3e3e3e;
54+
color: var(--docs-on-surface-color);
5455
background: white;
5556
box-shadow: 0 0 5px 0 rgb(0 0 0 / 10%);
5657
margin-right: 2em;
@@ -59,13 +60,31 @@ article {
5960
}
6061

6162
/* ------------------------------------
62-
* Body text
63+
* Exit externally link
6364
* ------------------------------------ */
6465

65-
article {
66-
color: #3E3E3E;
66+
#edit-page-link {
67+
height: 24px;
68+
margin-block-start: 2rem;
69+
margin-block-end: 1rem;
70+
}
71+
72+
#edit-page-link a {
73+
display: inline-flex;
74+
align-items: center;
75+
justify-content: center;
6776
}
6877

78+
#edit-page-link lazy-svg::part(svg) {
79+
height: 24px;
80+
width: 24px;
81+
margin-inline-start: 8px;
82+
}
83+
84+
/* ------------------------------------
85+
* Body text
86+
* ------------------------------------ */
87+
6988
article :not(litdev-aside) p {
7089
margin-block-start: 1.5em;
7190
margin-block-end: 1.5em;
@@ -391,7 +410,7 @@ table.directory tr.subheading {
391410
#prevAndNextLinks {
392411
display: flex;
393412
justify-content: space-between;
394-
margin-top: 3em;
413+
margin-block-start: 0;
395414
padding-top: 1.5em;
396415
border-top: 1px solid rgb(223, 223, 223);
397416
}
@@ -453,7 +472,7 @@ table.directory tr.subheading {
453472

454473
#docsNavWrapper {
455474
position: sticky;
456-
top: calc(var(--header-height) + var(--docs-margin-top));
475+
top: calc(var(--header-height) + var(--docs-margin-block));
457476
margin-bottom: 1.5em;
458477
height: calc(100vh - var(--header-height));
459478
display: flex;
@@ -584,7 +603,7 @@ table.directory tr.subheading {
584603
#rhsToc {
585604
padding: 10px 1em 0 0;
586605
position: sticky;
587-
top: calc(var(--header-height) + var(--docs-margin-top));
606+
top: calc(var(--header-height) + var(--docs-margin-block));
588607
}
589608

590609
/* "Contents" heading */
@@ -694,14 +713,14 @@ litdev-banner > a {
694713
*
695714
* (14 + 49 + 5 + (3 * 2)) * 18 = 1332
696715
* | | | | +--- font-size
697-
* | | | +------------- docs-article-margin-horizontal
716+
* | | | +------------- docs-article-margin-inline
698717
* | | +------------------ docs-toc-min-width
699718
* | +----------------------- docs-article-max-width
700719
* +---------------------------- docs-nav-min-width
701720
*/
702721
@media (max-width: 1332px) {
703722
main {
704-
--docs-article-margin-horizontal: 2.5em;
723+
--docs-article-margin-inline: 2.5em;
705724
}
706725

707726
#rhsTocWrapper {
@@ -750,7 +769,7 @@ litdev-banner > a {
750769
*
751770
* (14 + 30 + 3) * 18 = 846
752771
* | | | +------------- font-size
753-
* | | +------------------ docs-article-margin-horizontal
772+
* | | +------------------ docs-article-margin-inline
754773
* | +----------------------- docs-article-min-width
755774
* +---------------------------- docs-nav-min-width
756775
*/
@@ -765,7 +784,7 @@ litdev-banner > a {
765784
}
766785
article {
767786
margin: auto;
768-
--docs-article-margin-horizontal: 1.5em;
787+
--docs-article-margin-inline: 1.5em;
769788
}
770789
.anchor {
771790
left: -1.1rem;
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)