Skip to content

Commit

Permalink
add wysiwyg typography example
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahongsf committed Nov 5, 2024
1 parent 216954d commit 33f397d
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 60 deletions.
12 changes: 11 additions & 1 deletion app/components/MediaCaptionImage/MediaCaptionImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface MediaCaptionImageProps extends HTMLAttributes<HTMLElement> {
imageAlt?: string;
link?: string;
caption: string;
imageClasses?: string;
aspectRatio?: "default" | "square";
}

const MediaCaptionImage = ({
Expand All @@ -17,6 +19,8 @@ const MediaCaptionImage = ({
imageAlt = "",
link,
caption,
aspectRatio = "default",
imageClasses,
...props
}: MediaCaptionImageProps) => {
return (
Expand All @@ -27,7 +31,13 @@ const MediaCaptionImage = ({
props.className,
)}
>
<div className="relative aspect-[16/9] w-full">
<div
className={cnb(
"relative w-full overflow-hidden",
aspectRatio === "square" ? "aspect-[1/1]" : "aspect-[16/9]",
imageClasses,
)}
>
<Image
className="object-cover"
src={imageSrc}
Expand Down
3 changes: 1 addition & 2 deletions app/components/Typography/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type HeadingProps = Omit<TypographyProps, "as"> &
// Convenience component for paragraphs
export const Heading = ({
as = "h2",
font = "serif",
weight = "bold",
...rest
}: HeadingProps) => <Text {...rest} font={font} weight={weight} as={as} />;
}: HeadingProps) => <Text {...rest} weight={weight} as={as} />;
9 changes: 5 additions & 4 deletions app/components/Typography/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ export type TextProps = TypographyProps &

export const Text = ({
as: AsComponent = "div",
font = "sans",
font = "dm-sans",
size,
weight,
align,
color = "default",
variant,
leading,
useDefaultTracking = font === "ds-sans",
useDefaultTracking = font === "dm-sans",
italic,
srOnly,
uppercase = font === "ds-sans",
uppercase,
icon,
iconProps,
className,
Expand All @@ -60,6 +60,7 @@ export const Text = ({
<AsComponent
{...rest}
className={cnb(
"rs-mb-2",
font ? styles.fontFamilies[font] : "",
size ? styles.fontSizes[size] : "",
weight ? styles.fontWeights[weight] : "",
Expand All @@ -71,7 +72,7 @@ export const Text = ({
srOnly ? "sr-only" : "",
uppercase ? "uppercase" : "",
useDefaultTracking ? "tracking-normal" : "",
font === "ds-sans" ? "tracking-normal sm:tracking-wide" : "",
font === "dm-sans" ? "tracking-normal sm:tracking-wide" : "",
className,
)}
>
Expand Down
2 changes: 1 addition & 1 deletion app/components/Typography/typography.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const fontFamilies = {
sans: "font-sans",
serif: "font-serif",
"ds-sans": "font-ds-sans",
"dm-sans": "font-dm-sans",
};

export const fontWeights = {
Expand Down
132 changes: 128 additions & 4 deletions app/example/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { loadTimelineData } from "@/utilities/loadTimelineData";
import { GradientBanner } from "@/components/GradientBanner/GradientBanner";
import TimelineEven from "@/components/TimelineEven/TimelineOverview";
import MediaCaptionImage from "@/components/MediaCaptionImage/MediaCaptionImage";
import { Container } from "@/components/Container";

const ExamplePage = async () => {
const timelineData = await loadTimelineData();
Expand Down Expand Up @@ -48,11 +49,134 @@ const ExamplePage = async () => {
</Text>
</FeatureHero>
<ShapeAnimation />
<MediaCaptionImage
imageSrc="https://placecats.com/neo/1500/1000"
caption="Caption/credit lorem ipsum"
/>
<PageTitle heading="100 years of" bigText="Impact" />
<Container width="site" py={9} className="font-dm-sans">
<MediaCaptionImage
imageSrc="https://placecats.com/neo/1500/1000"
caption="Caption/credit lorem ipsum aspect ratio square"
aspectRatio="square"
imageClasses="w-[500px] rounded-lg"
/>
<MediaCaptionImage
imageSrc="https://placecats.com/neo/1500/1000"
caption="Caption/credit lorem ipsum aspect ratio 16/9"
/>
<Text className="type-3 intro-text">
Overview style lorem ipsum dolar sit amet vestibulum parimentium elit
rhoncus donec. Scelerisque urna et euismod in daphibus nec leo euismod
nisi, pharetra raesent nec. Aliquam dignissim nisi convalis quis, leo
vestibulum duis euismod.
</Text>
<Text className="big-paragraph">
Long copy paragraph text style raesent nec dapibus odio. Aliquam
dignissim nisi nisi, pharetra faucibus elit rhoncus in. Donec
efficitur scelerisque urna et sollicitudin. Donec euismod enim a dui
convallis, quis suscipit leo vestibulum. Duis aliquam euismod enim,
sit amet
</Text>
<Heading>Header Two</Heading>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed in text link. Praesent nec dapibus
odio. Aliquam dignissim nisi nisi, pharetra faucibus elit rhoncus in.
Donec efficitur scelerisque urna et sollicitudin. Duis aliquam euismod
enim, sit amet in text link hover state. Aliquam sodales consequat
arcu in egestas. Aliquam condimentum viverra eros.Donec efficitur
scelerisque urna et sollicitudin. Duis aliquam euismod enim, sit amet.
</Text>
<Heading as="h3">Header Three</Heading>
<Text className="big-paragraph">
Aenean sollicitudin facilisis ex, in tincidunt velit sodales ac.
Nullam consequat leo ut sem pharetra, a fringilla massa commodo. Etiam
molestie, justo nec congue ultricies, augue massa tempus ante, nec
sagittis dui tellus ac lectus. Duis aliquam euismod enim, sit amet
lobortis ante porttitor. Donec efficitur scelerisque urna et
sollicitudin. Duis aliquam euismod enim, sit amet.
</Text>
<Heading as="h4">Header Four</Heading>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed, egestas quis mi. Praesent nec
dapibus odio. Aliquam dignissim nisi nisi, pharetra faucibus elit
rhoncus in.
</Text>
<Heading as="h5">Header Five</Heading>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed, egestas quis mi. Praesent nec
dapibus odio. Aliquam dignissim nisi nisi, pharetra faucibus elit
rhoncus in. Donec efficitur scelerisque urna et sollicitudin. Donec
euismod enim a dui convallis, quis suscipit leo vestibulum. Duis
aliquam euismod enim, sit amet lobortis ante porttitor. Donec
efficitur scelerisque urna et sollicitudin. Duis aliquam euismod enim,
sit amet.
</Text>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed, egestas quis mi. Praesent nec
dapibus odio. Aliquam dignissim nisi nisi, pharetra faucibus elit
rhoncus in. Donec efficitur scelerisque urna et sollicitudin. Donec
efficitur scelerisque urna et sollicitudin.
</Text>
<Text className="big-paragraph">
<ul>
<li>Fusce sem enim, tempus nec massa id, mollis faucibus sem.</li>
<li>
Sem enim, tempus nec massa id, mollis faucibus sem imperdiet eu
fermentum nec massa mollis donec efficitur scelerisque urna et
sollicitudin.
</li>
<li>
Ut ipsum erat, imperdiet eu fermentum sed, egestas quis mi
praesent dapibus odio aliquam dignissim nisi nisi pharetra
faucibus elit
</li>
<li>
Donec efficitur scelerisque urna et sollicitudin. Donec euismod
enim a dui convallis, quis suscipit leo vestibulum. Duis aliquam
euismod enim lobortis ante porttitor aliquam praesent Sodales
consequat arcu in egestas Aliquam condimentum viverra eros, in
dapibus purus faucibus ut
</li>
</ul>
</Text>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed, egestas quis mi. Praesent nec
dapibus odio. Aliquam dignissim nisi nisi, pharetra faucibus elit
rhoncus in. Donec efficitur scelerisque urna et sollicitudin. Donec
efficitur scelerisque urna et sollicitudin.
</Text>
<Text className="big-paragraph">
<ol>
<li>Fusce sem enim, tempus nec massa id, mollis faucibus sem.</li>
<li>
Sem enim, tempus nec massa id, mollis faucibus sem imperdiet eu
fermentum nec massa mollis donec efficitur scelerisque urna et
sollicitudin.
</li>
<li>
Ut ipsum erat, imperdiet eu fermentum sed, egestas quis mi
praesent dapibus odio aliquam dignissim nisi nisi pharetra
faucibus elit
</li>
<li>
Donec efficitur scelerisque urna et sollicitudin. Donec euismod
enim a dui convallis, quis suscipit leo vestibulum. Duis aliquam
euismod enim lobortis ante porttitor aliquam praesent Sodales
consequat arcu in egestas Aliquam condimentum viverra eros, in
dapibus purus faucibus ut
</li>
</ol>
</Text>
<Text className="big-paragraph">
Fusce sem enim, tempus nec massa id, mollis faucibus sem. Ut ipsum
erat, imperdiet eu fermentum sed, egestas quis mi. Praesent nec
dapibus odio. Aliquam dignissim nisi nisi, pharetra faucibus elit
rhoncus in. Donec efficitur scelerisque urna et sollicitudin. Donec
efficitur scelerisque urna et sollicitudin.
</Text>
</Container>
<GradientBanner>
<Heading
as="h1"
Expand Down
2 changes: 1 addition & 1 deletion out/404.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 33f397d

Please sign in to comment.