diff --git a/site/docs/themes/index.mdx b/site/docs/themes/index.mdx index bcec08e591..9572ed8dd5 100644 --- a/site/docs/themes/index.mdx +++ b/site/docs/themes/index.mdx @@ -359,18 +359,44 @@ You can apply styling options as corresponding props to `SaltProviderNext` – When Amplitude is used, default heading font weight is set to medium (instead of semi bold for Open Sans), via `--salt-palette-text-heading-fontWeight` and `--salt-palette-text-display-fontWeight` variables. -You'll need to install Amplitude font to your application to make sure every user will see the font correctly, e.g., +To ensure that every user sees the Amplitude font correctly, you'll need to add it to your application, which can be downloaded from the [fonts page](https://go/salt-ds-internal/design/fonts) on the internal site if you're part of JPMC. ```css @font-face { - font-family: "Amplitude"; + font-family: Amplitude; + font-style: normal; + font-weight: 300; + src: + local("Amplitude Light"), + url("../public/fonts/amplitude-light.woff2") format("woff2"); +} + +@font-face { + font-family: Amplitude; font-style: normal; - font-display: swap; font-weight: 400; - src: url("PATH/TO/FONT.woff2") format("woff2"); + src: + local("Amplitude"), + url("../public/fonts/amplitude-regular.woff2") format("woff2"); } -/** and other font styles and weights */ +@font-face { + font-family: Amplitude; + font-style: normal; + font-weight: 500; + src: + local("Amplitude Medium"), + url("../public/fonts/amplitude-medium.woff2") format("woff2"); +} + +@font-face { + font-family: Amplitude; + font-style: normal; + font-weight: 700; + src: + local("Amplitude Bold"), + url("../public/fonts/amplitude-bold.woff2") format("woff2"); +} ``` #### Display text sizes diff --git a/site/public/fonts/amplitude-bold.woff2 b/site/public/fonts/amplitude-bold.woff2 new file mode 100644 index 0000000000..2ea16bb352 Binary files /dev/null and b/site/public/fonts/amplitude-bold.woff2 differ diff --git a/site/public/fonts/amplitude-light.woff2 b/site/public/fonts/amplitude-light.woff2 new file mode 100644 index 0000000000..9b80b0178e Binary files /dev/null and b/site/public/fonts/amplitude-light.woff2 differ diff --git a/site/public/fonts/amplitude-medium.woff2 b/site/public/fonts/amplitude-medium.woff2 new file mode 100644 index 0000000000..ac4c24c7e3 Binary files /dev/null and b/site/public/fonts/amplitude-medium.woff2 differ diff --git a/site/public/fonts/amplitude-regular.woff2 b/site/public/fonts/amplitude-regular.woff2 new file mode 100644 index 0000000000..01035f2819 Binary files /dev/null and b/site/public/fonts/amplitude-regular.woff2 differ diff --git a/site/src/components/components/LivePreview.tsx b/site/src/components/components/LivePreview.tsx index c34b2960fd..05dd36ad47 100644 --- a/site/src/components/components/LivePreview.tsx +++ b/site/src/components/components/LivePreview.tsx @@ -70,7 +70,8 @@ export const LivePreview: FC = ({ .catch((e) => console.error(`Failed to load example ${exampleName}`, e)); }, [exampleName, componentName]); - const { density, mode, accent, corner, themeNext } = useLivePreviewControls(); + const { density, mode, accent, corner, themeNext, headingFont, actionFont } = + useLivePreviewControls(); const handleShowCodeToggle = (event: ChangeEvent) => { const newShowCode = event.target.checked; @@ -90,7 +91,13 @@ export const LivePreview: FC = ({ [styles.smallViewport]: isMobileView, })} > - +
diff --git a/site/src/components/components/LivePreviewControls.tsx b/site/src/components/components/LivePreviewControls.tsx index 7d8265d867..318acec6a2 100644 --- a/site/src/components/components/LivePreviewControls.tsx +++ b/site/src/components/components/LivePreviewControls.tsx @@ -1,10 +1,10 @@ import { type Accent, + type ActionFont, type Corner, type Density, FlexItem, - FlexLayout, - FlowLayout, + type HeadingFont, type Mode, SaltProvider, type SaltProviderNextProps, @@ -15,7 +15,6 @@ import { ToggleButtonGroup, Tooltip, useBreakpoint, - useViewport, } from "@salt-ds/core"; import { DarkIcon, HelpIcon, LightIcon } from "@salt-ds/icons"; import { @@ -25,7 +24,6 @@ import { createContext, useState, } from "react"; -import useIsMobileView from "../../utils/useIsMobileView"; import clsx from "clsx"; import styles from "./LivePreviewControls.module.css"; @@ -44,7 +42,7 @@ const defaultMode = modes[0]; export type LivePreviewContextType = Pick< SaltProviderNextProps, - "accent" | "mode" | "density" | "corner" + "accent" | "mode" | "density" | "corner" | "headingFont" | "actionFont" > & { themeNext?: boolean; }; @@ -59,6 +57,8 @@ export const LivePreviewControls: FC = ({ const [themeNext, setThemeNext] = useState(false); const [accent, setAccent] = useState("blue"); const [corner, setCorner] = useState("sharp"); + const [headingFont, setHeadingFont] = useState("Open Sans"); + const [actionFont, setActionFont] = useState("Open Sans"); const { matchedBreakpoints } = useBreakpoint(); const isMobileView = !matchedBreakpoints.includes("md"); @@ -195,6 +195,52 @@ export const LivePreviewControls: FC = ({ ); + const headingFontToggleGroup = ( + + Heading font + { + setHeadingFont((prev) => + prev === "Open Sans" ? "Amplitude" : "Open Sans", + ); + }} + > + Open Sans + Amplitude + + + ); + + const actionFontToggleGroup = ( + + Action font + { + setActionFont((prev) => + prev === "Open Sans" ? "Amplitude" : "Open Sans", + ); + }} + > + Open Sans + Amplitude + + + ); + return ( <> @@ -210,6 +256,8 @@ export const LivePreviewControls: FC = ({ <> {cornerToggleGroup} {accentToggleGroup} + {headingFontToggleGroup} + {actionFontToggleGroup} ) : null}
@@ -223,6 +271,8 @@ export const LivePreviewControls: FC = ({ themeNext, accent, corner, + headingFont, + actionFont, }} > {children} diff --git a/site/src/css/theme/theme.css b/site/src/css/theme/theme.css index 0ca461b15c..e41888e777 100644 --- a/site/src/css/theme/theme.css +++ b/site/src/css/theme/theme.css @@ -21,4 +21,5 @@ .salt-theme[data-mode="dark"] { --salt-typography-fontFamily-ptMono: var(--site-font-family-ptMono); --salt-typography-fontFamily-openSans: var(--site-font-family-openSans); + --salt-typography-fontFamily-amplitude: var(--site-font-family-amplitude); } diff --git a/site/src/pages/_app.tsx b/site/src/pages/_app.tsx index a6286e9471..c57c60394b 100755 --- a/site/src/pages/_app.tsx +++ b/site/src/pages/_app.tsx @@ -23,6 +23,7 @@ import clsx from "clsx"; import { SessionProvider } from "next-auth/react"; import type { AppProps } from "next/app"; import { Open_Sans, PT_Mono } from "next/font/google"; +import localFont from "next/font/local"; import Head from "next/head"; import { type ReactNode, useMemo } from "react"; import * as saltComponents from "../components"; @@ -81,6 +82,32 @@ const openSans = Open_Sans({ variable: "--site-font-family-openSans", }); +const amplitude = localFont({ + src: [ + { + path: "../../public/fonts/amplitude-light.woff2", + weight: "300", + style: "normal", + }, + { + path: "../../public/fonts/amplitude-regular.woff2", + weight: "400", + style: "normal", + }, + { + path: "../../public/fonts/amplitude-medium.woff2", + weight: "500", + style: "normal", + }, + { + path: "../../public/fonts/amplitude-bold.woff2", + weight: "700", + style: "normal", + }, + ], + variable: "--site-font-family-amplitude", +}); + export default function MyApp({ Component, pageProps = {}, @@ -110,6 +137,7 @@ export default function MyApp({ themeClassName, ptMono.variable, openSans.variable, + amplitude.variable, )} >