Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(community): new community page design #11653

Merged
merged 57 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f1e9437
chore(community): empty page
caugner Jul 25, 2024
45cba61
wip
caugner Jul 26, 2024
22b9eee
mobile design
caugner Jul 29, 2024
a23c2e5
chore(community): add hero bg
caugner Jul 30, 2024
bb53fe9
chore: progress
caugner Jul 31, 2024
43524c7
chore(community): add Contributors circles
caugner Jul 31, 2024
fda2acf
chore(community): wip
caugner Aug 1, 2024
d243fe9
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Aug 19, 2024
fb56258
feat(community): implement simplified design
LeoMcA Aug 19, 2024
146d02b
fix(community): ensure csp doesn't block circle background
LeoMcA Aug 19, 2024
dc3317a
fix(search): don't index non doc pages
fiji-flo Aug 20, 2024
c667573
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Aug 23, 2024
c1e7e6c
fix(community): design tweaks from design review
LeoMcA Aug 23, 2024
d92c98f
fix(community): stylelint
LeoMcA Aug 23, 2024
78d90c1
fix(community): fix links, update contributors in spotlight
LeoMcA Aug 23, 2024
a065e13
fix(community): add gap between contributor sections on mobile
LeoMcA Aug 23, 2024
c89164d
chore(community): revert webpack changes
LeoMcA Sep 6, 2024
f6b07c7
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 6, 2024
9e19c6f
fix(community): use avatars.githubusercontent.com directly to avoid c…
LeoMcA Sep 10, 2024
8c2e6f6
fix(community): react item key error
LeoMcA Sep 10, 2024
76be41c
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 10, 2024
235f40e
fix(community): match button padding to login button
LeoMcA Sep 10, 2024
261f340
fix(community): cache github issues response in localstorage to mitig…
LeoMcA Sep 10, 2024
58987f0
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 11, 2024
ba1662e
fix(community): don't try to access localstorage on the server
LeoMcA Sep 11, 2024
a08dfa8
fix(community): avoid hydration errors with localstorage cache
LeoMcA Sep 11, 2024
c75c9f4
fix(community): randomly select contributors to display
LeoMcA Sep 11, 2024
9908ed9
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 11, 2024
cfecfdc
fix(community): stylelint
LeoMcA Sep 11, 2024
f161f8b
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 20, 2024
8fae5dc
fix(community): reduce width
LeoMcA Sep 20, 2024
36bbb68
wip(community): various fixes
LeoMcA Sep 23, 2024
9275d81
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 23, 2024
d8e590a
wip(community): fix tsc
LeoMcA Sep 23, 2024
5023a33
wip(community): fix line clamp
LeoMcA Sep 23, 2024
846ba4e
Merge remote-tracking branch 'upstream/main' into MP-1369-new-communi…
fiji-flo Sep 24, 2024
2f3e816
fix(community): use md to build
fiji-flo Sep 25, 2024
d3742d2
fix(community): remove hack
fiji-flo Sep 25, 2024
cade810
fix(community): use hyData format
fiji-flo Sep 25, 2024
73c068f
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Sep 27, 2024
8bf0bf2
fix(community): offset-path url not working in chrome
LeoMcA Sep 27, 2024
88fb28e
fix(community): update copy
LeoMcA Sep 27, 2024
a9d4513
fix(community): keep things within main box
LeoMcA Sep 27, 2024
5bfa3bb
fix(community): run svgs through svgo
LeoMcA Sep 27, 2024
9af3518
fix(community): stylelint
LeoMcA Sep 27, 2024
dcb1967
fix(community): avoid '| Contribute to MDN' title
LeoMcA Sep 30, 2024
8b751f0
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Oct 1, 2024
28aa732
fix(community): fix tabbing order in contributor circle
LeoMcA Oct 1, 2024
608d563
wip(community): fix stylelint
LeoMcA Oct 1, 2024
3e07e84
wip(community): clip-path: inset(); doesn't work properly on webkit
LeoMcA Oct 1, 2024
285efc0
wip(community): review updates
LeoMcA Oct 1, 2024
0c8328b
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Oct 7, 2024
ffdce80
fix(community): show focus ring on youtube link
LeoMcA Oct 8, 2024
c4fc5d0
fix(community): fix lint
LeoMcA Oct 8, 2024
d97fc32
fix(community): fix for https://github.com/mdn/yari/pull/11930
LeoMcA Oct 8, 2024
40e5677
Merge remote-tracking branch 'origin/main' into MP-1369-new-community…
LeoMcA Oct 10, 2024
af6fbc1
fix(community): further fix for https://github.com/mdn/yari/pull/11930
LeoMcA Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions build/spas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export async function buildSPAs(options: {
noIndexing: true,
},
{ prefix: "about", pageTitle: "About MDN" },
{ prefix: "community", pageTitle: "Contribute to MDN" },
{
prefix: "advertising",
pageTitle: "Advertise with us",
Expand Down Expand Up @@ -269,16 +268,9 @@ export async function buildSPAs(options: {
}

// Building the MDN Plus pages.

/**
*
* @param {string} dirpath
* @param {string} slug
* @param {string} title
*/
async function buildStaticPages(
dirpath: string,
slug: string,
slugPrefix?: string,
title = "MDN"
) {
const crawler = new fdir()
Expand All @@ -299,13 +291,14 @@ export async function buildSPAs(options: {
const frontMatter = frontmatter<DocFrontmatter>(markdown);
const rawHTML = await m2h(frontMatter.body, { locale });

const url = `/${locale}/${slug}/${page}`;
const slug = slugPrefix ? `${slugPrefix}/${page}` : `${page}`;
const url = `/${locale}/${slug}`;
const d = {
url,
rawBody: rawHTML,
metadata: {
locale: DEFAULT_LOCALE,
slug: `${slug}/${page}`,
slug,
url,
},

Expand All @@ -327,16 +320,13 @@ export async function buildSPAs(options: {
};
const context: HydrationData = {
hyData,
pageTitle: `${frontMatter.attributes.title || ""} | ${title}`,
pageTitle: frontMatter.attributes.title
? `${frontMatter.attributes.title} | ${title}`
: title,
url,
};

const outPath = path.join(
BUILD_OUT_ROOT,
pathLocale,
...slug.split("/"),
page
);
const outPath = path.join(BUILD_OUT_ROOT, pathLocale, ...slug.split("/"));
fs.mkdirSync(outPath, { recursive: true });
const jsonFilePath = path.join(outPath, "index.json");
fs.writeFileSync(jsonFilePath, JSON.stringify(context));
Expand All @@ -363,6 +353,11 @@ export async function buildSPAs(options: {
"observatory/docs",
OBSERVATORY_TITLE
);
await buildStaticPages(
fileURLToPath(new URL("../copy/community/", import.meta.url)),
"",
"Contribute to MDN"
);

// Build all the home pages in all locales.
// Fetch merged content PRs for the latest contribution section.
Expand Down
4 changes: 2 additions & 2 deletions client/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PageNotFound } from "./page-not-found";
import { Plus } from "./plus";
import { About } from "./about";
import { getCategoryByPathname } from "./utils";
import { Contribute } from "./community";
import { Community } from "./community";
import { ContributorSpotlight } from "./contributor-spotlight";
import { useIsServer, usePing } from "./hooks";

Expand Down Expand Up @@ -330,7 +330,7 @@ export function App(appProps: HydrationData) {
path="/community/*"
element={
<StandardLayout>
<Contribute />
<Community {...appProps} />
</StandardLayout>
}
/>
Expand Down
1 change: 1 addition & 0 deletions client/src/assets/community/community-calls-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/community-calls.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/discord-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/people-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/people.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/quote-end-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/quote-end.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/quote-start-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/quote-start.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/video-bg-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/video-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/community/video-thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/community/youtube-play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions client/src/community/contributor-list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
@use "../ui/vars" as *;

* {
box-sizing: border-box;
}

.wrap {
--img-size: 3.75em;
--li-size: calc(var(--img-size) * 2.5);
}

ul {
--circle-border-size: 0.375em;
align-content: start;
display: grid;
gap: 2rem 1rem;
grid-template-columns: repeat(auto-fit, minmax(var(--li-size), 1fr));
justify-items: center;
margin: 0;
padding: 0;

@media (max-width: $screen-md) {
display: flex;
margin-top: 2rem;
overflow-x: auto;
}
}

li,
a {
align-items: center;
display: flex;
flex-direction: column;
flex-shrink: 0;
text-align: center;
}

li {
color: var(--community-text-primary);
width: var(--li-size);
}

img {
background: var(--community-circle-img-border);
border: var(--circle-border-size) var(--community-circle-img-border) solid;
border-radius: 50%;
flex-shrink: 0;
height: var(--img-size);
width: var(--img-size);
}

a {
color: unset;
font-weight: 500;
}

svg {
display: none;
}

@supports (offset-path: ellipse(100% 50% at 100% 50%)) {
@media (min-width: $screen-md) {
.wrap {
container-type: size;
height: 100%;
width: 100%;
}

.inner {
font-size: min(1rem, 3.5cqmin);
padding: calc(var(--img-size) / 2) calc(var(--li-size) / 2);
}

ul {
aspect-ratio: 1 / 2;
display: block;
margin-left: auto;
max-height: var(--community-circle-height);
min-height: 0;
min-width: 0;
position: relative;
}

svg {
display: block;
fill: none;
height: 100%;
overflow: visible;
position: absolute;
stroke: var(--community-circle-img-border);
stroke-width: var(--circle-border-size);
width: 100%;
}

li {
$outer-elements: 5;
$inner-elements: 3;

// necessary because Firefox seems to have a bug where the links aren't
// clickable until we force some kind of re-render which an animation does:
animation: community-circle 0.1ms forwards;
offset-anchor: center calc(0.5 * var(--img-size));
offset-distance: var(--offset-distance);
offset-path: ellipse(100% 50% at 100% 50%);
offset-rotate: 0deg;

&:nth-of-type(n + #{$outer-elements + 1}) {
--img-size: 5em;
offset-path: ellipse(50% 25% at 100% 50%);
}

@keyframes community-circle {
from {
offset-distance: calc(var(--offset-distance) - 0.1%);
}
}

@for $i from 1 through $outer-elements {
&:nth-of-type(#{$i}) {
--offset-distance: #{calc(
75% - (($i - 1) * 50% / ($outer-elements - 1))
)};
}
}

@for $i from 1 through $inner-elements {
&:nth-of-type(#{$outer-elements + $i}) {
--offset-distance: #{calc(
75% - (($i - 1) * 50% / ($inner-elements - 1))
)};
}
}
}

.org {
-webkit-box-orient: vertical;
/* stylelint-disable-next-line value-no-vendor-prefix */
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
}
}
}
109 changes: 109 additions & 0 deletions client/src/community/contributor-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js";

import styles from "./contributor-list.scss?css" with { type: "css" };

interface ContributorData {
name: string;
github: string;
org?: string;
}

@customElement("contributor-list")
export class ContributorList extends LitElement {
_contributors: ContributorData[] = [];

static properties = {
_contributors: { state: true },
};

static styles = styles;

constructor() {
super();
const contributorList = this.querySelector("ul");
const randomContributors: ContributorData[] = [];
if (contributorList) {
const contributors = [...contributorList.querySelectorAll("li")];
for (let index = 0; index < 8; index++) {
const contributor = popRandom(contributors);
if (!contributor) {
break;
}
const [name, github, org] = [...contributor.childNodes].map(
(node) => node?.textContent?.trim() || undefined
);
if (!name || !github) {
index--;
continue;
}
randomContributors.push({
name,
github,
org,
});
}
this._contributors = randomContributors;
}
}

render() {
return html`<div class="wrap">
<div class="inner">
<ul>
<svg>
<defs>
<mask id="hide-half">
<rect
x="0%"
y="0%"
width="100%"
height="100%"
fill="#fff"
stroke="#fff"
/>
</mask>
</defs>
<ellipse
rx="100%"
ry="50%"
cx="100%"
cy="50%"
mask="url(#hide-half)"
/>
<ellipse
rx="50%"
ry="25%"
cx="100%"
cy="50%"
mask="url(#hide-half)"
/>
</svg>
${this._contributors.map(({ name, github, org }) => {
const imgSrc = `https://avatars.githubusercontent.com/${github
?.split("/")
.slice(-1)}`;
return html`<li>
<a href="${github}" target="_blank" rel="nofollow noreferrer">
<img
src="${imgSrc}?size=80"
srcset="${imgSrc}?size=160 2x"
loading="lazy"
referrerpolicy="no-referrer"
/>
${name}
</a>
<span class="org">${org}</span>
</li>`;
})}
</ul>
</div>
</div>`;
}
}

function popRandom<T>(array: Array<T>) {
const i = Math.floor(Math.random() * array.length);
// mutate the array:
return array.splice(i, 1)[0];
LeoMcA marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading