-
-
Notifications
You must be signed in to change notification settings - Fork 14
Feat/Create Universal Image Component #243
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
base: saga
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,24 +6,11 @@ type Image = { | |
| width: number; | ||
| height: number; | ||
| altText: string; | ||
| caption: string; | ||
| attribution: string; | ||
| alignment: "left" | "center" | "right"; | ||
| }; | ||
|
|
||
| // const [isHovering, setIsHovering] = useState(false) | ||
|
|
||
| const Images: FC<Image> = ({ | ||
| image, | ||
| width, | ||
| height, | ||
| altText, | ||
| caption, | ||
| attribution, | ||
| alignment, | ||
| }) => { | ||
| const Images: FC<Image> = ({ image, width, height, altText, alignment }) => { | ||
| let flexAlignment = getFlexAlignment(alignment); | ||
| let textAlignment = getTextAlignment(alignment); | ||
|
|
||
| return ( | ||
| <div className={`flex ${flexAlignment}`}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Is it possible to use RadixUI's Flex component here instead of Tailwind? Maybe have a |
||
|
|
@@ -35,10 +22,6 @@ const Images: FC<Image> = ({ | |
| <div className="relative"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Does this div do anything? Not sure why that was there originally. |
||
| <Image src={image} alt={altText} height={height} width={width} /> | ||
| </div> | ||
| <p className={`text-neutral-500 text-sm ${textAlignment}`}> | ||
| Photo Credit: {attribution} | ||
| </p> | ||
| <p className={`${textAlignment}`}>{caption}</p> | ||
| </div> | ||
| </div> | ||
| ); | ||
|
|
@@ -55,13 +38,3 @@ export const getFlexAlignment = (alignment: string) => { | |
| return "justify-center"; | ||
| } | ||
| }; | ||
|
|
||
| export const getTextAlignment = (alignment: string) => { | ||
| if (alignment === "right") { | ||
| return "text-right"; | ||
| } else if (alignment === "left") { | ||
| return "text-left"; | ||
| } else { | ||
| return "text-center"; | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { FC } from "react"; | ||
| import Image from "next/image"; | ||
|
|
||
| type ImageWithCaption = { | ||
| image: string; | ||
| width: number; | ||
| height: number; | ||
| altText: string; | ||
| caption?: string; | ||
| attribution?: string; | ||
| alignment: "left" | "center" | "right"; | ||
| }; | ||
|
|
||
| const ImagesWithCaption: FC<ImageWithCaption> = ({ | ||
| image, | ||
| width, | ||
| height, | ||
| altText, | ||
| caption, | ||
| attribution, | ||
| alignment, | ||
| }) => { | ||
| let flexAlignment = getFlexAlignment(alignment); | ||
| let textAlignment = getTextAlignment(alignment); | ||
|
|
||
| return ( | ||
| <div className={`flex ${flexAlignment}`}> | ||
| <div | ||
| style={{ | ||
| width: width, | ||
| }} | ||
| > | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Use RadixUI's Box component here? That'd enable us to use their mobile-responsive breakpoints, etc. |
||
| <div className="relative"> | ||
| <Image src={image} alt={altText} height={height} width={width} /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Would we want to pass thru sizes & styles like the above component does? |
||
| </div> | ||
| {attribution && ( | ||
| <p className={`text-neutral-500 text-sm ${textAlignment}`}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Use RadixUI's Text component here, and for the caption below. |
||
| Photo Credit: {attribution} | ||
| </p> | ||
| )} | ||
| {caption && <p className={`${textAlignment}`}>{caption}</p>} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ImagesWithCaption; | ||
|
|
||
| export const getFlexAlignment = (alignment: string) => { | ||
| if (alignment === "right") { | ||
| return "justify-end"; | ||
| } else if (alignment === "left") { | ||
| return "justify-start"; | ||
| } else { | ||
| return "justify-center"; | ||
| } | ||
| }; | ||
|
|
||
| export const getTextAlignment = (alignment: string) => { | ||
| if (alignment === "right") { | ||
| return "text-right"; | ||
| } else if (alignment === "left") { | ||
| return "text-left"; | ||
| } else { | ||
| return "text-center"; | ||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include sizes and style props (see https://github.com/distributeaid/next-website-v2/pull/211/files#diff-da94d5a2e703325b54c2f3822b9a488da97997c511acb3d5e55a73f9703ac731)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heard, those changes should be reflected in 58f993a