Skip to content

Commit 26d7651

Browse files
committed
next/index: customize the tagline in blue
1 parent 67ff619 commit 26d7651

File tree

11 files changed

+93
-46
lines changed

11 files changed

+93
-46
lines changed

src/packages/database/settings/customize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface Customize {
2929
logoRectangularURL?: string;
3030
splashImage?: string;
3131
indexInfo?: string;
32+
indexTagline?: string;
3233
imprint?: string;
3334
policies?: string;
3435
shareServer?: boolean;
@@ -42,7 +43,6 @@ export interface Customize {
4243
accountCreationInstructions?: string;
4344
zendesk?: boolean; // true if zendesk support is configured.
4445
stripePublishableKey?: string;
45-
index_info_html?: string;
4646
imprint_html?: string;
4747
policies_html?: string;
4848
reCaptchaKey?: string;
@@ -123,6 +123,7 @@ export default async function getCustomize(): Promise<Customize> {
123123
googleAnalytics: settings.google_analytics,
124124

125125
indexInfo: settings.index_info_html,
126+
indexTagline: settings.index_tagline,
126127
imprint: settings.imprint,
127128
policies: settings.policies,
128129
support: settings.support,

src/packages/frontend/editors/slate/elements/link/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
44
*/
55

6-
import { CSSProperties } from "react";
76
import { Text } from "slate";
8-
import { register, SlateElement } from "../register";
9-
import { dict } from "@cocalc/util/misc";
7+
8+
import { CSS } from "@cocalc/frontend/app-framework";
109
import { useFileContext } from "@cocalc/frontend/lib/file-context";
10+
import { dict } from "@cocalc/util/misc";
11+
import { register, SlateElement } from "../register";
1112

12-
export const LINK_STYLE = {
13+
export const LINK_STYLE: CSS = {
1314
backgroundColor: "white",
1415
padding: "1px",
1516
margin: "-1px", // so the position isn't changed; important when background is white so doesn't look weird.
1617
borderRadius: "2px",
17-
} as CSSProperties;
18+
} as const;
1819

1920
export interface Link extends SlateElement {
2021
type: "link";
@@ -29,14 +30,15 @@ register({
2930
StaticElement: ({ attributes, children, element }) => {
3031
const node = element as Link;
3132
let { url, title } = node;
32-
const { AnchorTagComponent, urlTransform } = useFileContext();
33+
const { AnchorTagComponent, urlTransform, anchorStyle } = useFileContext();
34+
const style: CSS = { ...LINK_STYLE, ...anchorStyle };
3335
if (AnchorTagComponent != null) {
3436
return (
3537
<AnchorTagComponent
3638
{...attributes}
3739
href={url}
3840
title={title}
39-
style={LINK_STYLE}
41+
style={style}
4042
>
4143
{children}
4244
</AnchorTagComponent>
@@ -52,7 +54,7 @@ register({
5254
};
5355
}
5456
return (
55-
<a {...attributes} {...props} title={title} style={LINK_STYLE}>
57+
<a {...attributes} {...props} title={title} style={style}>
5658
{children}
5759
{isBlank(element) && <span contentEditable={false}>(blank link)</span>}
5860
</a>

src/packages/frontend/editors/slate/static-markdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ application.
1010
*/
1111

1212
import { CSSProperties, useEffect, useState } from "react";
13+
1314
import "./elements/init-ssr";
1415
import { getStaticRender } from "./elements/register";
15-
import { markdown_to_slate as markdownToSlate } from "./markdown-to-slate";
1616
import Leaf from "./leaf";
17+
import { markdown_to_slate as markdownToSlate } from "./markdown-to-slate";
1718
import { ChangeContext } from "./use-change";
1819

1920
interface Props {

src/packages/frontend/lib/file-context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import React, {
1414
ReactNode,
1515
} from "react";
1616

17-
interface IFileContext {
17+
export interface IFileContext {
1818
// allow customizing anchor tags that get generated by various components, e.g., Markdown via slate.
1919
AnchorTagComponent?: React.FC<{
2020
href?: string;
@@ -41,6 +41,7 @@ interface IFileContext {
4141
// If given, then when an anchor (A) tag is clicked
4242
// on, the given function is called.
4343
anchorTagAction?: (url: string) => void;
44+
anchorStyle?: CSSProperties;
4445

4546
// If given, then all href and src attributes in all
4647
// tags are transformed by urlTransform, except anchor

src/packages/next/components/landing/cocalc-com-features.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -577,28 +577,3 @@ export function CoCalcComFeatures() {
577577
</>
578578
);
579579
}
580-
581-
export function Hero() {
582-
return (
583-
<Info.Heading
584-
level={2}
585-
textStyle={{ color: "white" }}
586-
style={{
587-
backgroundColor: COLORS.BLUE_D,
588-
paddingBottom: "30px",
589-
marginTop: "30px",
590-
paddingTop: "30px",
591-
}}
592-
>
593-
Realtime collaborative{" "}
594-
<A href="/features/jupyter-notebook" style={{ color: "white" }}>
595-
Jupyter notebooks
596-
</A>
597-
,{" "}
598-
<A href="/features/latex-editor" style={{ color: "white" }}>
599-
LaTeX
600-
</A>
601-
, Markdown, and Linux with GPUs
602-
</Info.Heading>
603-
);
604-
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.
3+
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
4+
*/
5+
6+
import { COLORS } from "@cocalc/util/theme";
7+
import Info from "components/landing/info";
8+
import { CSS } from "components/misc";
9+
import A from "components/misc/A";
10+
import SanitizedMarkdown from "components/misc/sanitized-markdown";
11+
12+
const A_STYLE: CSS = {
13+
color: "white",
14+
backgroundColor: "transparent",
15+
} as const;
16+
17+
export function Tagline({ value }: { value?: string }) {
18+
function renderContent() {
19+
if (value) {
20+
return <SanitizedMarkdown value={value} anchorStyle={A_STYLE} />;
21+
} else {
22+
return (
23+
<>
24+
Realtime collaborative{" "}
25+
<A href="/features/jupyter-notebook" style={A_STYLE}>
26+
Jupyter notebooks
27+
</A>
28+
,{" "}
29+
<A href="/features/latex-editor" style={A_STYLE}>
30+
LaTeX
31+
</A>
32+
, Markdown, and Linux with GPUs
33+
</>
34+
);
35+
}
36+
}
37+
38+
return (
39+
<Info.Heading
40+
level={2}
41+
textStyle={{ color: "white" }}
42+
style={{
43+
backgroundColor: COLORS.BLUE_D,
44+
paddingBottom: "30px",
45+
marginTop: "30px",
46+
paddingTop: "30px",
47+
}}
48+
>
49+
{renderContent()}
50+
</Info.Heading>
51+
);
52+
}

src/packages/next/components/misc/A.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import Link from "next/link";
7-
import basePath from "lib/base-path";
87
import { join } from "path";
98

9+
import basePath from "lib/base-path";
10+
1011
export default function A(props: any) {
1112
const { href } = props;
1213
if (href == null) {

src/packages/next/components/misc/sanitized-markdown.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@
66
import { CSSProperties } from "react";
77

88
import Markdown from "@cocalc/frontend/editors/slate/static-markdown";
9-
import { FileContext } from "@cocalc/frontend/lib/file-context";
9+
import { FileContext, IFileContext } from "@cocalc/frontend/lib/file-context";
1010
import A from "components/misc/A";
1111

1212
export default function SanitizedMarkdown({
1313
style,
1414
value,
15+
anchorStyle,
1516
}: {
1617
style?: CSSProperties;
18+
anchorStyle?: CSSProperties;
1719
value: string;
1820
}) {
19-
const ctx = {
21+
const ctx: IFileContext = {
2022
AnchorTagComponent: A,
2123
noSanitize: false,
24+
anchorStyle,
2225
};
2326
return (
2427
<FileContext.Provider value={ctx}>

src/packages/next/components/support/create.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { Icon } from "@cocalc/frontend/components/icon";
2-
import { is_valid_email_address as isValidEmailAddress } from "@cocalc/util/misc";
3-
import { COLORS } from "@cocalc/util/theme";
41
import {
52
Alert,
63
Button,
@@ -11,6 +8,12 @@ import {
118
Radio,
129
Space,
1310
} from "antd";
11+
import { useRouter } from "next/router";
12+
import { ReactNode, useRef, useState } from "react";
13+
14+
import { Icon } from "@cocalc/frontend/components/icon";
15+
import { is_valid_email_address as isValidEmailAddress } from "@cocalc/util/misc";
16+
import { COLORS } from "@cocalc/util/theme";
1417
import { Paragraph, Title } from "components/misc";
1518
import A from "components/misc/A";
1619
import ChatGPTHelp from "components/openai/chatgpt-help";
@@ -20,8 +23,6 @@ import SiteName from "components/share/site-name";
2023
import apiPost from "lib/api/post";
2124
import { MAX_WIDTH } from "lib/config";
2225
import { useCustomize } from "lib/customize";
23-
import { useRouter } from "next/router";
24-
import { ReactNode, useRef, useState } from "react";
2526
import getBrowserInfo from "./browser-info";
2627
import RecentFiles from "./recent-files";
2728
import { Type } from "./tickets";

src/packages/next/pages/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { COLORS } from "@cocalc/util/theme";
1212
import { RecentHeadline } from "@cocalc/util/types/news";
1313
import {
1414
CoCalcComFeatures,
15-
Hero,
1615
} from "components/landing/cocalc-com-features";
1716
import Content from "components/landing/content";
1817
import Footer from "components/landing/footer";
@@ -29,6 +28,7 @@ import { Customize, CustomizeType } from "lib/customize";
2928
import { PublicPath as PublicPathType } from "lib/share/types";
3029
import withCustomize from "lib/with-customize";
3130
import screenshot from "public/cocalc-screenshot-20200128-nq8.png";
31+
import { Tagline } from "components/landing/tagline";
3232

3333
const TOP_LINK_STYLE: CSS = { marginRight: "20px" } as const;
3434

@@ -51,6 +51,7 @@ export default function Home(props: Props) {
5151
onCoCalcCom,
5252
account,
5353
isCommercial,
54+
indexTagline,
5455
} = customize;
5556

5657
function contentDescription() {
@@ -172,7 +173,7 @@ export default function Home(props: Props) {
172173
onCoCalcCom ? <Videos videos={YOUTUBE_IDS} /> : indexInfo
173174
}
174175
/>
175-
<Hero />
176+
<Tagline value={indexTagline} />
176177
{renderCoCalcComFeatures()}
177178
<Footer />
178179
</Layout.Content>

0 commit comments

Comments
 (0)