Skip to content

Commit bd0c671

Browse files
authored
isom-1687 update site identifier logos (#909)
* fix - use logo URL instead * replace with common method * change objectFit to contain * add 1rem padding for image
1 parent 6308a7f commit bd0c671

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

apps/studio/src/features/dashboard/SiteList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Link } from "@opengovsg/design-system-react"
1515

1616
import { NoResultIcon } from "~/components/Svg/NoResultIcon"
1717
import { withSuspense } from "~/hocs/withSuspense"
18+
import { generateAssetUrl } from "~/utils/generateAssetUrl"
1819
import { trpc } from "~/utils/trpc"
1920

2021
const Site = ({
@@ -39,10 +40,11 @@ const Site = ({
3940
borderColor="base.divider.medium"
4041
width="100%"
4142
height="100%"
42-
objectFit="cover"
43+
objectFit="contain"
4344
aspectRatio="1/1"
4445
backgroundColor="white"
4546
fallbackSrc="/isomer-sites-placeholder.png"
47+
padding="1rem" // Leave some space so that logo won't be flush with the border
4648
/>
4749
<Box
4850
position="absolute"
@@ -134,7 +136,7 @@ const SuspendableSiteList = (): JSX.Element => {
134136
<Site
135137
siteId={site.id}
136138
siteName={site.name}
137-
siteLogoUrl={site.config.logoUrl}
139+
siteLogoUrl={generateAssetUrl(site.config.logoUrl)}
138140
/>
139141
))}
140142
</SiteListSection>

apps/studio/src/features/editing-experience/components/form-builder/renderers/controls/JsonFormsImageControl.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
import type { ModifiedAsset } from "~/types/assets"
1414
import { JSON_FORMS_RANKING } from "~/constants/formBuilder"
1515
import { useEditorDrawerContext } from "~/contexts/EditorDrawerContext"
16-
import { useEnv } from "~/hooks/useEnv"
1716
import { getPresignedPutUrlSchema } from "~/schemas/asset"
17+
import { generateAssetUrl } from "~/utils/generateAssetUrl"
1818
import {
1919
IMAGE_UPLOAD_ACCEPTED_MIME_TYPES,
2020
MAX_IMG_FILE_SIZE_BYTES,
@@ -37,9 +37,6 @@ export function JsonFormsImageControl({
3737
errors,
3838
data,
3939
}: ControlProps) {
40-
const {
41-
env: { NEXT_PUBLIC_S3_ASSETS_DOMAIN_NAME },
42-
} = useEnv()
4340
const toast = useToast()
4441
const { modifiedAssets, setModifiedAssets } = useEditorDrawerContext()
4542
const [pendingAsset, setPendingAsset] = useState<ModifiedAsset | undefined>()
@@ -77,9 +74,7 @@ export function JsonFormsImageControl({
7774
async function convertImage(url: string) {
7875
const fileName = url.split("/").pop()
7976
const fileType = `image/${url.split(".").pop()}`
80-
const imageUrl = url.startsWith("/")
81-
? `https://${NEXT_PUBLIC_S3_ASSETS_DOMAIN_NAME}${url}`
82-
: url
77+
const imageUrl = generateAssetUrl(url)
8378
const file = await urlToFile(imageUrl, fileName || "", fileType)
8479
setPendingAsset({ path, src: url, file })
8580
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { env } from "~/env.mjs"
2+
3+
export const generateAssetUrl = (url: string): string => {
4+
return url.startsWith("/")
5+
? `https://${env.NEXT_PUBLIC_S3_ASSETS_DOMAIN_NAME}${url}`
6+
: url
7+
}

0 commit comments

Comments
 (0)