Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions packages/visual-editor/src/components/DefaultThemeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h1-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
h2: {
Expand All @@ -104,6 +111,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h2-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
h3: {
Expand All @@ -130,6 +144,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h3-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
h4: {
Expand All @@ -156,6 +177,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h4-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
h5: {
Expand All @@ -182,6 +210,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h5-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
h6: {
Expand All @@ -208,6 +243,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-h6-fontFamily"),
default: "700",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
body: {
Expand All @@ -234,6 +276,13 @@ export function createDefaultThemeConfig(
options: fontWeightOptions("--fontFamily-body-fontFamily"),
default: "400",
},
textTransform: {
label: msg("theme.textTransform.textTransform", "Text Transform"),
type: "select",
plugin: "textTransform",
options: ThemeOptions.TEXT_TRANSFORM,
default: "none",
},
},
},
pageSection: {
Expand Down
7 changes: 6 additions & 1 deletion packages/visual-editor/src/components/atoms/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface BodyProps
VariantProps<typeof bodyVariants> {}

export const Body = React.forwardRef<HTMLParagraphElement, BodyProps>(
({ className, variant, ...props }, ref) => {
({ className, variant, style, ...props }, ref) => {
return (
<p
className={themeManagerCn(
Expand All @@ -36,6 +36,11 @@ export const Body = React.forwardRef<HTMLParagraphElement, BodyProps>(
}),
className
)}
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
textTransform: `var(--textTransform-body-textTransform)`,
...style,
}}
ref={ref}
{...props}
>
Expand Down
17 changes: 7 additions & 10 deletions packages/visual-editor/src/components/atoms/heading.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { themeManagerCn, HeadingLevel } from "@yext/visual-editor";
import { HeadingLevel, themeManagerCn } from "@yext/visual-editor";

// Define the variants for the heading component
export const headingVariants = cva("components", {
Expand Down Expand Up @@ -51,17 +51,10 @@ export const headingVariants = cva("components", {
"800": "font-extrabold",
"900": "font-black",
},
transform: {
none: "",
uppercase: "uppercase",
lowercase: "lowercase",
capitalize: "capitalize",
},
},
defaultVariants: {
fontSize: "default",
weight: "default",
transform: "none",
},
});

Expand All @@ -79,9 +72,9 @@ export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
className,
level = 1,
weight,
transform,
fontSize,
semanticLevelOverride,
style,
...props
},
ref
Expand All @@ -103,12 +96,16 @@ export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
headingVariants({
fontSize,
weight,
transform,
level,
}),
Tag === "span" && "block",
className
)}
style={{
// @ts-expect-error ts(2322) the css variable here resolves to a valid enum value
textTransform: `var(--textTransform-h${level}-textTransform)`,
...style,
}}
ref={ref}
{...props}
>
Expand Down
8 changes: 8 additions & 0 deletions packages/visual-editor/src/components/atoms/maybeRTF.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
font-size: var(--fontSize-body-fontSize) !important;
line-height: calc(var(--fontSize-body-fontSize) + 4px) !important;
font-weight: var(--fontWeight-body-fontWeight) !important;
text-transform: var(--textTransform-body-textTransform) !important;
}
li {
font-family: var(--fontFamily-body-fontFamily) !important;
font-size: var(--fontSize-body-fontSize) !important;
line-height: calc(var(--fontSize-body-fontSize) + 4px) !important;
font-weight: var(--fontWeight-body-fontWeight) !important;
text-transform: var(--textTransform-body-textTransform) !important;
}
h1 {
font-family: var(--fontFamily-h2-fontFamily) !important;
font-size: var(--fontSize-h2-fontSize) !important;
line-height: calc(var(--fontSize-h2-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h2-fontWeight) !important;
text-transform: var(--textTransform-h1-textTransform) !important;
@media (min-width: 640px) {
font-family: var(--fontFamily-h1-fontFamily) !important;
font-size: var(--fontSize-h1-fontSize) !important;
Expand All @@ -28,6 +31,7 @@
font-size: var(--fontSize-h3-fontSize) !important;
line-height: calc(var(--fontSize-h3-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h3-fontWeight) !important;
text-transform: var(--textTransform-h2-textTransform) !important;
@media (min-width: 640px) {
font-family: var(--fontFamily-h2-fontFamily) !important;
font-size: var(--fontSize-h2-fontSize) !important;
Expand All @@ -40,6 +44,7 @@
font-size: var(--fontSize-h4-fontSize) !important;
line-height: calc(var(--fontSize-h4-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h4-fontWeight) !important;
text-transform: var(--textTransform-h3-textTransform) !important;
@media (min-width: 640px) {
font-family: var(--fontFamily-h3-fontFamily) !important;
font-size: var(--fontSize-h3-fontSize) !important;
Expand All @@ -52,6 +57,7 @@
font-size: var(--fontSize-h5-fontSize) !important;
line-height: calc(var(--fontSize-h5-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h5-fontWeight) !important;
text-transform: var(--textTransform-h4-textTransform) !important;
@media (min-width: 640px) {
font-family: var(--fontFamily-h4-fontFamily) !important;
font-size: var(--fontSize-h4-fontSize) !important;
Expand All @@ -64,6 +70,7 @@
font-size: var(--fontSize-h6-fontSize) !important;
line-height: calc(var(--fontSize-h6-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h6-fontWeight) !important;
text-transform: var(--textTransform-h5-textTransform) !important;
@media (min-width: 640px) {
font-family: var(--fontFamily-h5-fontFamily) !important;
font-size: var(--fontSize-h5-fontSize) !important;
Expand All @@ -76,6 +83,7 @@
font-size: var(--fontSize-h6-fontSize) !important;
line-height: calc(var(--fontSize-h6-fontSize) + 4px) !important;
font-weight: var(--fontWeight-h6-fontWeight) !important;
text-transform: var(--textTransform-h6-textTransform) !important;
}
a {
font-family: var(--fontFamily-link-fontFamily) !important;
Expand Down