Skip to content

Commit 09f817d

Browse files
committed
Documentation
1 parent 86d3729 commit 09f817d

File tree

6 files changed

+66
-53
lines changed

6 files changed

+66
-53
lines changed

docs/insiders/benefits.md

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ future holds!
8686

8787
[sponsoring tiers]: sponsoring-tiers.md#commercial-use
8888

89+
<div data-mdx-component="sponsorship"></div>
90+
8991
## Funding <span class="mdx-sponsorship-total" data-mdx-component="sponsorship-total"></span>
9092

9193
### Goals

material/overrides/assets/javascripts/custom.058c863c.min.js

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/overrides/assets/javascripts/custom.b457887c.min.js.map renamed to material/overrides/assets/javascripts/custom.058c863c.min.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/overrides/assets/javascripts/custom.b457887c.min.js

-18
This file was deleted.

material/overrides/main.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
{% endblock %}
2424
{% block scripts %}
2525
{{ super() }}
26-
<script src="{{ 'assets/javascripts/custom.b457887c.min.js' | url }}"></script>
26+
<script src="{{ 'assets/javascripts/custom.058c863c.min.js' | url }}"></script>
2727
{% endblock %}

src/overrides/assets/javascripts/components/sponsorship/index.ts

+42-31
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
* IN THE SOFTWARE.
2121
*/
2222

23-
import { Observable, map } from "rxjs"
23+
import { Observable, from, map, switchMap, tap } from "rxjs"
2424

25-
import { getElement, requestJSON } from "~/browser"
25+
import { getOptionalElement, requestJSON } from "~/browser"
2626

2727
import { renderPrivateSponsor, renderPublicSponsor } from "_/templates"
2828

29-
import { Component, getComponentElement } from "../_"
29+
import { Component, getComponentElements } from "../_"
3030

3131
/* ----------------------------------------------------------------------------
3232
* Types
@@ -113,35 +113,46 @@ export function mountSponsorship(
113113
)
114114

115115
/* Retrieve adjacent components */
116-
const count = getComponentElement("sponsorship-count")
117-
const total = getComponentElement("sponsorship-total")
118-
119-
/* Render sponsorship */
120-
sponsorship$.subscribe(sponsorship => {
121-
el.removeAttribute("hidden")
122-
123-
/* Render public sponsors with avatar and links */
124-
const list = getElement(":scope > :first-child", el)
125-
for (const sponsor of sponsorship.sponsors)
126-
if (sponsor.type === "public")
127-
list.appendChild(renderPublicSponsor(sponsor.user))
128-
129-
/* Render combined private sponsors */
130-
list.appendChild(renderPrivateSponsor(
131-
sponsorship.sponsors.filter(({ type }) => (
132-
type === "private"
133-
)).length
134-
))
135-
136-
/* Render sponsorship count and total */
137-
count.innerText = `${sponsorship.sponsors.length}`
138-
total.innerText = `$ ${sponsorship.total
139-
.toString()
140-
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
141-
} a month`
142-
})
116+
const count = getComponentElements("sponsorship-count")
117+
const total = getComponentElements("sponsorship-total")
143118

144-
// /* Create and return component */
119+
/* Render sponsorship count */
120+
sponsorship$.pipe(
121+
switchMap(sponsorship => from(count).pipe(
122+
tap(child => child.innerText = `${sponsorship.sponsors.length}`)
123+
))
124+
)
125+
.subscribe(() => el.removeAttribute("hidden"))
126+
127+
/* Render sponsorship total */
128+
sponsorship$.pipe(
129+
switchMap(sponsorship => from(total).pipe(
130+
tap(child => child.innerText = `$ ${sponsorship.total
131+
.toString()
132+
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
133+
} a month`)
134+
))
135+
)
136+
.subscribe()
137+
138+
// Render sponsorship list
139+
const list = getOptionalElement(":scope > .mdx-sponsorship__list", el)
140+
if (list && count.length) {
141+
sponsorship$.subscribe(sponsorship => {
142+
for (const sponsor of sponsorship.sponsors)
143+
if (sponsor.type === "public")
144+
list.appendChild(renderPublicSponsor(sponsor.user))
145+
146+
/* Render combined private sponsors */
147+
list.appendChild(renderPrivateSponsor(
148+
sponsorship.sponsors.filter(({ type }) => (
149+
type === "private"
150+
)).length
151+
))
152+
})
153+
}
154+
155+
/* Create and return component */
145156
return sponsorship$
146157
.pipe(
147158
map(state => ({ ref: el, ...state }))

0 commit comments

Comments
 (0)