Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Stories for Card, Banner, Media with Caption. #7

Merged
merged 15 commits into from
Mar 5, 2024
7 changes: 0 additions & 7 deletions .storybook/stories/elements/lockup/Lockup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ export const LockupM: Story = {
suLockupOptions: "m"
}
}
export const LockupN: Story = {
render: LockupDisplay.render,
args: {
...LockupDisplay.args,
suLockupOptions: "n"
}
}
export const LockupO: Story = {
render: LockupDisplay.render,
args: {
Expand Down
47 changes: 47 additions & 0 deletions .storybook/stories/paragraphs/Banner.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type {Meta, StoryObj} from '@storybook/react';
import {ComponentProps} from "react";
import {ParagraphStanfordBanner, Text} from "@lib/gql/__generated__/drupal";
import BannerParagraph from '@components/paragraphs/stanford-banner/banner-paragraph';
import { getStoryBookImage } from '../storybook-entities';

type ComponentStoryProps = ComponentProps<typeof BannerParagraph> & {
text: Text["processed"]
}

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<ComponentStoryProps> = {
title: 'Design/Paragraphs/Banner',
component: BannerParagraph,
tags: ['autodocs'],
argTypes: {}
};

export default meta;
type Story = StoryObj<ComponentStoryProps>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Banner: Story = {
render: ({...args}) => {
return <BannerParagraph {...args}/>
},
args: {
paragraph:{
__typename: 'ParagraphStanfordBanner',
composition: {},
langcode: {},
created: {
offset: "",
timestamp: Math.round(new Date().getTime() / 1000),
time: new Date().toISOString(),
timezone: "America/Los_Angeles"
},
id: "9954cc81-919b-4498-9151-bf930831fca7",
suBannerHeader: "Nam scelerisque, urna vitae auctor efficitur, tortor nunc cursus tortor, ut blandit purus arcu quis sapien",
suBannerBody: {
processed: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae dignissim felis. Nullam nulla leo, venenatis at feugiat sit amet, ultricies non lorem.</p>"
},
suBannerImage: getStoryBookImage(),
suBannerSupHeader: "Vestibulum"
}
}
};
50 changes: 50 additions & 0 deletions .storybook/stories/paragraphs/MediaWithCaption.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { Meta, StoryObj } from '@storybook/react';
import { ComponentProps } from "react";
import StanfordMediaCaption from '@components/paragraphs/stanford-media-caption/media-caption-paragraph';
import { getStoryBookImage } from '../storybook-entities';

type ComponentStoryProps = ComponentProps<typeof StanfordMediaCaption> & {
// text: Text["processed"]
}

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<ComponentStoryProps> = {
title: 'Design/Paragraphs/MediaCaption',
component: StanfordMediaCaption,
tags: ['autodocs'],
argTypes: {}
};

export default meta;
type Story = StoryObj<ComponentStoryProps>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Caption: Story = {
render: ({ ...args }) => {
return <StanfordMediaCaption {...args} />
},
args: {
paragraph: {
id:"6fa23537-dda7-4861-930a-648445d9904c",
__typename: 'ParagraphStanfordMediaCaption',
composition: {},
langcode: {},
created: {
offset: "",
timestamp: Math.round(new Date().getTime() / 1000),
time: new Date().toISOString(),
timezone: "America/Los_Angeles"
},
suMediaCaptionCaption: {
processed:"<p>Here is my caption.</p>"
},
suMediaCaptionLink: {
title:"Link text.",
url:"/publications",
internal:true
},
suMediaCaptionMedia: getStoryBookImage(),
}
}
};

2 changes: 1 addition & 1 deletion src/components/elements/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Button = ({
'inline-block text-center w-fit': !centered,
'btn btn--big transition text-5xl text-white hocus:text-white bg-digital-red hocus:bg-black no-underline hocus:underline py-6 px-12 font-normal': big && !secondary,
'btn btn--secondary transition text-digital-red border-2 border-digital-red hocus:border-black no-underline hocus:underline py-4 px-8 font-normal': !big && secondary,
'btn bg-digital-red text-white hocus:bg-black hocus:text-white py-4 px-8 no-underline hocus:underline transition': !big && !secondary,
'btn bg-digital-red font-normal text-white hocus:bg-black hocus:text-white py-4 px-8 no-underline hocus:underline transition': !big && !secondary,
}
)

Expand Down
4 changes: 2 additions & 2 deletions src/components/elements/lockup/lockup-a.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const LockupA = ({line1, line5, siteName, logoUrl}: FooterLockupProps) => {
return (
<div className="py-10">
<Link href="/" className="no-underline text-black">
<div className="flex flex-col lg:flex-row gap-4">
<div className="flex flex-col items-start lg:flex-row gap-4">
<LockupLogo logoUrl={logoUrl} siteName={siteName}/>

<div className="w-[1px] bg-black shrink-0"/>
Expand All @@ -16,7 +16,7 @@ const LockupA = ({line1, line5, siteName, logoUrl}: FooterLockupProps) => {
</div>

{line5 &&
<div className="font-semibold uppercase">
<div className="font-semibold uppercase mt-4 border-t border-black lg:border-t-0">
{line5}
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/lockup/lockup-h.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LockupH = ({line1, line3, line4, siteName, logoUrl}: FooterLockupProps) =>
<div className="flex flex-col lg:flex-row gap-4">
<div>
<LockupLogo logoUrl={logoUrl} siteName={siteName}/>
<div className="font-semibold text-m2">{line4}</div>
<div className="font-semibold uppercase text-m1">{line4}</div>
</div>

<div className="w-[1px] bg-black shrink-0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/lockup/lockup-i.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LockupI = ({line1, line3, line4, siteName, logoUrl}: FooterLockupProps) =>
<div className="flex flex-col lg:flex-row gap-4">
<div>
<LockupLogo logoUrl={logoUrl} siteName={siteName}/>
<div className="font-semibold text-m2 uppercase">{line4}</div>
<div className="font-semibold text-m1 uppercase">{line4}</div>
</div>

<div className="w-[1px] bg-black shrink-0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/lockup/lockup-p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LockupP = ({line1, line4, siteName, logoUrl}: FooterLockupProps) => {
<div className="flex flex-col lg:flex-row gap-4">
<div>
<LockupLogo logoUrl={logoUrl} siteName={siteName}/>
<div className="font-semibold text-m1">{line4}</div>
<div className="font-semibold uppercase text-m1">{line4}</div>
</div>

<div className="w-[1px] bg-black shrink-0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/lockup/lockup-r.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const LockupR = ({line5, siteName, logoUrl}: FooterLockupProps) => {
<div className="flex flex-col lg:flex-row gap-4">
<div>
<LockupLogo logoUrl={logoUrl} siteName={siteName}/>
<div className="font-normal">{line5}</div>
<div className="font-normal uppercase mt-4">{line5}</div>
</div>
</div>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/global/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PageHeader = async () => {
<div className="bg-cardinal-red">
<div className="centered py-3">
<a
className="font-stanford no-underline hocus:underline text-white hocus:text-white leading-none"
className="font-stanford no-underline font-regular text-20 hocus:underline text-white hocus:text-white leading-none"
href="https://www.stanford.edu"
>
Stanford University
Expand Down
4 changes: 2 additions & 2 deletions src/components/menu/main-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const MenuItem = ({id, url, title, activeTrail, children, level}: MenuItemProps)
const inTrail = activeTrail.includes(id) && !isCurrent;

const linkStyles = clsx(
'w-full relative inline-block text-white lg:text-cardinal-red hocus:text-white lg:hocus:text-black no-underline hocus:underline py-5 lg:pl-0 border-l-[6px]',
'w-full relative inline-block text-white lg:text-digital-red hocus:text-white lg:hocus:text-black no-underline hocus:underline py-5 lg:pl-0 border-l-[6px]',
leftPadding[level],
// Top menu item styles.
{
Expand Down Expand Up @@ -150,7 +150,7 @@ const MenuItem = ({id, url, title, activeTrail, children, level}: MenuItemProps)
{level === 0 && <div className="block ml-5 w-[1px] h-[25px] mb-[6px] bg-archway-light shrink-0"/>}
<button
ref={buttonRef}
className="shrink-0 mb-[6px] relative right-10 lg:right-0 text-white lg:text-cardinal-red bg-cardinal-red lg:bg-transparent rounded-full lg:rounded-none group border-b border-transparent hocus:border-black hocus:bg-white"
className="shrink-0 mb-[6px] relative right-10 lg:right-0 text-white lg:text-digital-red bg-digital-red lg:bg-transparent rounded-full lg:rounded-none group border-b border-transparent hocus:border-black hocus:bg-white"
onClick={toggleSubmenu}
aria-expanded={submenuOpen}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const BannerParagraph = ({paragraph, eagerLoadImage, ...props}: Props) => {

return (
<div {...props}>
<div className="@container md:min-h-[400px] mb-20">
<div className="@container md:min-h-[400px] rs-mb-5">
<div
className="aspect-[16/9] @6xl:aspect-auto relative @6xl:absolute w-full @6xl:h-full bg-cool-grey">
{paragraph.suBannerImage?.mediaImage.url &&
Expand All @@ -40,7 +40,7 @@ const BannerParagraph = ({paragraph, eagerLoadImage, ...props}: Props) => {

{hasCard &&
<div
className={twMerge("w-full relative shadow-lg flex flex-col gap-10 py-20 px-10 @6xl:bg-white @6xl:max-w-[550px] @6xl:my-20 @6xl:z-10", behaviors.hero_pattern?.overlay_position === "right" ? "@6xl:ml-auto @6xl:mr-20" : "@6xl:mr-auto @6xl:ml-20")}>
className={twMerge("w-full relative shadow-lg flex flex-col gap-10 rs-p-2 @6xl:bg-white @6xl:max-w-[550px] @6xl:my-20 @6xl:z-10", behaviors.hero_pattern?.overlay_position === "right" ? "@6xl:ml-auto @6xl:mr-20" : "@6xl:mr-auto @6xl:ml-20")}>

{paragraph.suBannerHeader &&
<div className={twMerge("order-2", behaviors.hero_pattern?.hide_heading && "sr-only")}>
Expand All @@ -60,12 +60,12 @@ const BannerParagraph = ({paragraph, eagerLoadImage, ...props}: Props) => {
}

{paragraph.suBannerSupHeader &&
<div className="order-1 font-semibold">
<div className="order-1 text-09em font-semibold">
{paragraph.suBannerSupHeader}
</div>
}

<Wysiwyg html={paragraph.suBannerBody?.processed} className="order-3"/>
<Wysiwyg html={paragraph.suBannerBody?.processed} className="order-3 text-m0"/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a 100ch width applied to the p within this. It keeps it from aligning flush right to the image edge. @pookmish Do you know the best way to fix that?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I know what you mean. when should the text align to the image edge of the banner?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry @pookmish That comment should have gone on the media with caption file.

<Wysiwyg html={paragraph.suMediaCaptionCaption?.processed}/>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but from what I see, it is aligning to the right of the image. I'm not sure what you are seeing different
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is right aligned fine now for me too. 🤷🏼‍♀️


{paragraph.suBannerButton?.url &&
<div className="order-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MediaCaptionParagraph = ({paragraph, ...props}: Props) => {
}
{videoUrl && <Oembed url={videoUrl}/>}

<figcaption className="text-right">
<figcaption className="text-right text-m0 text-cool-grey color">
{paragraph.suMediaCaptionLink?.url &&
<Link href={paragraph.suMediaCaptionLink.url} className="">
{paragraph.suMediaCaptionLink.title}
Expand Down
Loading