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

feat: logo cloud #928

Merged
merged 7 commits into from
Dec 17, 2024
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
19 changes: 19 additions & 0 deletions apps/studio/public/assets/css/preview-tw.css
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,10 @@ video {
-webkit-line-clamp: 3;
}

.\!block {
display: block !important;
}

.block {
display: block;
}
Expand Down Expand Up @@ -1686,6 +1690,10 @@ video {
max-width: 10rem;
}

.max-w-52 {
max-width: 13rem;
}

.max-w-5xl {
max-width: 64rem;
}
Expand Down Expand Up @@ -3129,6 +3137,11 @@ video {
color: rgb(26 86 229 / var(--tw-text-opacity));
}

.text-link-hover {
--tw-text-opacity: 1;
color: rgb(21 71 190 / var(--tw-text-opacity));
}

.text-site-secondary {
--tw-text-opacity: 1;
color: rgb(78 69 65 / var(--tw-text-opacity));
Expand Down Expand Up @@ -5466,6 +5479,12 @@ video {
margin-top: 2.25rem;
}

.\[\&\:not\(\:first-child\)\]\:first-of-type\:mt-7:first-of-type:not(
:first-child
) {
margin-top: 1.75rem;
}

.\[\&\:not\(\:last-child\)\]\:mb-0:not(:last-child) {
margin-bottom: 0px;
}
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

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

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],
},
}
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"}
Copy link
Contributor

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?

Copy link
Contributor Author

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)

</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>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./LogoCloud"
2 changes: 1 addition & 1 deletion packages/components/src/utils/isExternalUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Determine if the provided URL is an external link
export const isExternalUrl = (url?: string) => {
export const isExternalUrl = (url?: string): boolean => {
return (
!!url &&
!url.startsWith("/") &&
Expand Down
Loading