-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: logo cloud #928
Merged
Merged
feat: logo cloud #928
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2126745
feat: logo cloud
seaerchin 79b2dc4
chore: remove comment
seaerchin e2e24a7
fix: remove string assertion
seaerchin b1939ca
chore: fix typing
seaerchin b21dee4
chore: postbuild changes
seaerchin 7152927
chore: add extra stories
seaerchin 3e15492
fix: update to correct property
seaerchin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
packages/components/src/templates/next/components/complex/LogoCloud/LogoCloud.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
|
||
import { LogoCloud } from "./LogoCloud" | ||
|
||
const meta: Meta<typeof LogoCloud> = { | ||
title: "Next/Components/Logo Cloud", | ||
component: LogoCloud, | ||
argTypes: {}, | ||
parameters: { | ||
themes: { | ||
themeOverride: "Isomer Next", | ||
}, | ||
}, | ||
} | ||
export default meta | ||
type Story = StoryObj<typeof LogoCloud> | ||
|
||
const IMAGE = { src: "https://via.placeholder.com/150", alt: "placeholder" } | ||
const HORIZONTAL_IMAGE = { | ||
src: "https://via.placeholder.com/1000x100", | ||
alt: "placeholder", | ||
} | ||
const VERTICAL_IMAGE = { | ||
src: "https://via.placeholder.com/100x1000", | ||
alt: "placeholder", | ||
} | ||
|
||
// Default scenario | ||
export const Default: Story = { | ||
args: { | ||
images: [IMAGE], | ||
}, | ||
} | ||
|
||
export const ManyImages: Story = { | ||
args: { | ||
images: Array(10).fill(IMAGE), | ||
}, | ||
} | ||
|
||
export const Agency: Story = { | ||
args: { | ||
images: [ | ||
{ | ||
alt: "Some image", | ||
src: "https://www.ncss.gov.sg/images/default-source/asset/fwdsg_logo.png?sfvrsn=91b23ea8_1", | ||
}, | ||
{ | ||
alt: "Some image", | ||
src: "https://www.ncss.gov.sg/images/default-source/asset/togsgcares_logo.png?sfvrsn=d499b7ea_2", | ||
}, | ||
{ | ||
alt: "Some image", | ||
src: "https://www.ncss.gov.sg/images/default-source/asset/celebrating-volunteers-logo.png?sfvrsn=44b85185_2 ", | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export const HugeHorizontalLogo: Story = { | ||
args: { | ||
images: [...Array(4).fill(IMAGE), HORIZONTAL_IMAGE], | ||
}, | ||
} | ||
|
||
export const HugeVerticalLogo: Story = { | ||
args: { | ||
images: [...Array(4).fill(IMAGE), VERTICAL_IMAGE], | ||
}, | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/components/src/templates/next/components/complex/LogoCloud/LogoCloud.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { IsomerSiteProps } from "~/types" | ||
import { isExternalUrl } from "~/utils" | ||
import { ImageClient } from "../Image" | ||
|
||
interface Image { | ||
src: string | ||
alt: string | ||
} | ||
interface LogoCloudProps extends Pick<IsomerSiteProps, "assetsBaseUrl"> { | ||
images: Image[] | ||
title?: string | ||
} | ||
export const LogoCloud = ({ | ||
images: baseImages, | ||
title, | ||
assetsBaseUrl, | ||
}: LogoCloudProps) => { | ||
const images = baseImages.map(({ src, alt }) => { | ||
const transformedSrc = | ||
isExternalUrl(src) || (assetsBaseUrl === undefined && !!src) | ||
? src | ||
: `${assetsBaseUrl}${src}` | ||
|
||
return { src: transformedSrc, alt } | ||
}) | ||
return ( | ||
<div className="px-10 py-12"> | ||
<div className="flex flex-col gap-4"> | ||
<p className="prose-headline-base-medium self-center text-base-content-light"> | ||
{title ?? "With support from these agencies"} | ||
</p> | ||
<div className="flex flex-wrap justify-center"> | ||
{images.map((props) => ( | ||
<ImageClient | ||
{...props} | ||
width="100%" | ||
className="inset-0 w-fit max-w-52 object-contain p-2" | ||
assetsBaseUrl={assetsBaseUrl} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/components/src/templates/next/components/complex/LogoCloud/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./LogoCloud" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
btw
title
is required and won't be falsy? just checking if this is just a preventive measures?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.
yes defensive! reason why is because this is written to disk and read back (+ done manually)