jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/382465 )
Change subject: Chore: refactor wiki and summary title and footer components
......................................................................
Chore: refactor wiki and summary title and footer components
DRY up footer and content header components used by wiki and summary.
No styling yet. Footer doesn't do much more than wrap a DRYed out
LastModified component.
Bug: T173326
Change-Id: Id7a7bb72d756f61fee1fd8499befeeeb24c4e199
---
A src/common/components/content-footer/content-footer.tsx
A src/common/components/content-header/content-header.tsx
A src/common/components/last-modified/last-modified.tsx
M src/common/pages/summary.tsx
M src/common/pages/wiki.tsx
5 files changed, 48 insertions(+), 26 deletions(-)
Approvals:
Niedzielski: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/common/components/content-footer/content-footer.tsx
b/src/common/components/content-footer/content-footer.tsx
new file mode 100644
index 0000000..224e318
--- /dev/null
+++ b/src/common/components/content-footer/content-footer.tsx
@@ -0,0 +1,14 @@
+import { h } from "preact";
+import LastModified from "../last-modified/last-modified";
+
+export default function ContentFooter({
+ lastModified
+}: {
+ lastModified: Date;
+}) {
+ return (
+ <div class="ContentFooter">
+ <LastModified class="ContentFooter-lastModified" date={lastModified} />
+ </div>
+ );
+}
diff --git a/src/common/components/content-header/content-header.tsx
b/src/common/components/content-header/content-header.tsx
new file mode 100644
index 0000000..8e15b29
--- /dev/null
+++ b/src/common/components/content-header/content-header.tsx
@@ -0,0 +1,13 @@
+import { h } from "preact";
+import Content from "../../components/content/content";
+
+export default function ContentHeader({ titleHTML }: { titleHTML: string }) {
+ return (
+ <Content class="ContentHeader">
+ <h1
+ class="ContentHeader-title"
+ dangerouslySetInnerHTML={{ __html: titleHTML }}
+ />
+ </Content>
+ );
+}
diff --git a/src/common/components/last-modified/last-modified.tsx
b/src/common/components/last-modified/last-modified.tsx
new file mode 100644
index 0000000..52d300f
--- /dev/null
+++ b/src/common/components/last-modified/last-modified.tsx
@@ -0,0 +1,13 @@
+import { h } from "preact";
+import { ClassProps, classOf } from "../preact-utils";
+
+export default function LastModified({
+ date,
+ ...props
+}: { date: Date } & ClassProps) {
+ return (
+ <span class={classOf("LastModified", props.class)}>
+ Last updated {date.toLocaleString("en-GB")}
+ </span>
+ );
+}
diff --git a/src/common/pages/summary.tsx b/src/common/pages/summary.tsx
index 2641107..9b823b2 100644
--- a/src/common/pages/summary.tsx
+++ b/src/common/pages/summary.tsx
@@ -1,12 +1,13 @@
import { h } from "preact";
import App from "../components/app/app";
-import Content from "../components/content/content";
import { PageSummary } from "../components/page-summary/page-summary";
import { PageSummary as PageSummaryModel } from "../models/page/summary";
import { PageTitleID, PageTitlePath } from "../models/page/title";
import Page from "../components/page/page";
import { RouteParams } from "../routers/route";
import { request } from "../data-clients/page-summary-data-client";
+import ContentHeader from "../components/content-header/content-header";
+import ContentFooter from "../components/content-footer/content-footer";
export interface Params extends RouteParams {
/**
@@ -26,21 +27,11 @@
export const Component = ({ summary }: Props): JSX.Element => (
<App>
<Page
- title={<Title summary={summary} />}
+ title={<ContentHeader titleHTML={summary.titleHTML} />}
subtitle={summary.descriptionText}
- footer={<Footer summary={summary} />}
+ footer={<ContentFooter lastModified={summary.lastModified} />}
>
<PageSummary summary={summary} />
</Page>
</App>
-);
-
-const Title = ({ summary }: Props) => (
- <Content>
- <h1 dangerouslySetInnerHTML={{ __html: summary.titleHTML }} />
- </Content>
-);
-
-const Footer = ({ summary }: Props) => (
- <span>Last updated {summary.lastModified.toLocaleString("en-GB")}</span>
);
diff --git a/src/common/pages/wiki.tsx b/src/common/pages/wiki.tsx
index b99dc23..b0eac1b 100644
--- a/src/common/pages/wiki.tsx
+++ b/src/common/pages/wiki.tsx
@@ -1,12 +1,13 @@
import { h } from "preact";
import App from "../components/app/app";
-import Content from "../components/content/content";
+import ContentHeader from "../components/content-header/content-header";
import { Page as PageModel } from "../models/page/page";
import { PageTitleID, PageTitlePath } from "../models/page/title";
import Page from "../components/page/page";
import { RouteParams } from "../routers/route";
import { requestPage } from "../data-clients/page-data-client";
import Section from "../components/section";
+import ContentFooter from "../components/content-footer/content-footer";
export interface Params extends RouteParams {
/**
@@ -26,21 +27,11 @@
export const Component = ({ page }: Props): JSX.Element => (
<App>
<Page
- title={<Title page={page} />}
+ title={<ContentHeader titleHTML={page.titleHTML} />}
subtitle={page.descriptionText}
- footer={<Footer page={page} />}
+ footer={<ContentFooter lastModified={page.lastModified} />}
>
{page.sections.map(section => <Section section={section} />)}
</Page>
</App>
-);
-
-const Title = ({ page }: Props) => (
- <Content>
- <h1 dangerouslySetInnerHTML={{ __html: page.titleHTML }} />
- </Content>
-);
-
-const Footer = ({ page }: Props) => (
- <span>Last updated {page.lastModified.toLocaleString("en-GB")}</span>
);
--
To view, visit https://gerrit.wikimedia.org/r/382465
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id7a7bb72d756f61fee1fd8499befeeeb24c4e199
Gerrit-PatchSet: 4
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits