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

CTC-108: default images #338

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/components/atoms/OakImage/OakImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type StyledImageProps = Omit<OakImageProps, "as"> & {
$showOakPlaceholder: boolean;
};

const oakPlaceholder =
export const oakPlaceholder =
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZmlsbD0iIzIyMiIgZD0iTTI4Ljc3OSAxOS4xNzZhMjcuMTkxIDI3LjE5MSAwIDAgMC0zLjggMS42IDE2LjcgMTYuNyAwIDAgMC03LjEgOC40YzAgLjEtLjEuMi0uMS4zLS43IDIuNC0uNiAyIDEuMyAyLjMgMS45LjMgMSAuNSAxIDEuMy0uMSA4LjggNC4xIDE1LjEgMTEuNCAxOS42YTEuNSAxLjUgMCAwIDAgMS43LjJjNS43LTIuNiA5LjMtNyAxMC4zLTEzLjJhMSAxIDAgMCAxIDEtMWwzLS4yYy44IDAgMS4zLjIgMS4yIDEuMmExNy45IDE3LjkgMCAwIDEtMy4yIDkuMiAyMy43IDIzLjcgMCAwIDEtMTAuOSA5LjEgNS40MDEgNS40MDEgMCAwIDEtNC41LS4yIDI2LjI5OCAyNi4yOTggMCAwIDEtOC41LTYuNiAyNS45IDI1LjkgMCAwIDEtNi40LTE0LjRjMC0uNi0uMi0uNy0uOC0uOC0yLjUtLjQtMi41LS4xLTIuMy0yLjlhMTkuMyAxOS4zIDAgMCAxIDEwLjgtMTYuNiAzOC45OTkgMzguOTk5IDAgMCAxIDUuNy0yLjEgMi4xIDIuMSAwIDAgMCAuOS0xLjMgMTQuMSAxNC4xIDAgMCAxIDMuNS02LjNsLjMtLjNjMS45LTIgMi42LTIgNC4zLjJsLjQuNWMxLjEgMS4xIDEgMS41LS4xIDIuNmExMS45IDExLjkgMCAwIDAtMy4yIDQuNCAxNi45IDE2LjkgMCAwIDEgNy41IDIuM2M1LjcgMy41IDkuMiA4LjMgOS45IDE1IC4wMTYuOTAxLS4wMTcgMS44MDItLjEgMi43IDAgLjgtLjYgMS0xLjIgMS4yYTE2LjEgMTYuMSAwIDAgMS0xMS0uNyAxNy45MDEgMTcuOTAxIDAgMCAxLTEwLjktMTMuNiA5Ljc5NiA5Ljc5NiAwIDAgMS0uMS0xLjlabTE4LjEgMTIuMmMuNC01LjUtNi45LTEyLjYtMTMtMTIuMS41IDYuNSA3LjYgMTIuOCAxMyAxMi4xWiIgb3BhY2l0eT0iLjEiLz48L3N2Zz4=";

const clickStyles = css<{ onClick?: MouseEventHandler }>`
Expand All @@ -58,7 +58,7 @@ const clickStyles = css<{ onClick?: MouseEventHandler }>`
`}
`;

const placeholderStyles = css<StyledImageProps>`
export const placeholderStyles = css<StyledImageProps>`
${(props) =>
props.$showOakPlaceholder &&
css`
Expand Down
11 changes: 9 additions & 2 deletions src/components/organisms/shared/OakMediaClip/OakMediaClip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
OakImage,
OakP,
OakLI,
oakPlaceholder,
placeholderStyles,
} from "@/components/atoms";
import { OakCombinedColorToken } from "@/styles";
import { InternalButton } from "@/components/atoms/InternalButton";
Expand Down Expand Up @@ -75,6 +77,10 @@ const MediaButtonWrapper = styled(StyledButtonWrapper)`
width: 100%;
`;

export const StyledMediaClipImage = styled(OakImage)`
${placeholderStyles}
`;

const ImageBox = styled(OakFlex)<{ disabled?: boolean }>`
img {
border-radius: 2px;
Expand Down Expand Up @@ -231,12 +237,13 @@ export const OakMediaClip = ({
$flexShrink={0}
>
{!isAudioClip && thumbnailImage ? (
<OakImage
<StyledMediaClipImage
fill
$height={"100%"}
$width={"100%"}
src={thumbnailImage}
src={thumbnailImage ?? oakPlaceholder}
alt={imageAltText}
$showOakPlaceholder={!thumbnailImage ? true : false}
$borderRadius={"border-radius-xs"}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ exports[`OakMediaClip matches snapshot 1`] = `
.c12 {
position: relative;
width: 100%;
height: 100%;
border-radius: 0.125rem;
font-family: --var(google-font),Lexend,sans-serif;
}

Expand Down Expand Up @@ -266,7 +264,7 @@ exports[`OakMediaClip matches snapshot 1`] = `
className="c9 c10 c11"
>
<div
className="c12"
className="c12 "
fill={true}
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
OakTypography,
OakHeading,
OakIcon,
placeholderStyles,
oakPlaceholder,
} from "@/components/atoms";
import { parseBorderRadius } from "@/styles/helpers/parseBorderRadius";
import { parseColor } from "@/styles/helpers/parseColor";
Expand Down Expand Up @@ -56,6 +58,7 @@ const ImageStackShadow = styled(OakBox)`
img {
object-fit: fill;
-webkit-filter: brightness(100%);
${placeholderStyles}
}

&::after {
Expand Down Expand Up @@ -110,6 +113,9 @@ export const OakMediaClipStackListItem = (
$height={["all-spacing-11", "all-spacing-11", "all-spacing-15"]}
$position={"relative"}
$mb={["space-between-none", "space-between-none", "space-between-xs"]}
$showOakPlaceholder={!imageUrl ? true : false}
src={imageUrl ?? oakPlaceholder}
alt={!imageUrl ? "oak" : ""}
k-huggs marked this conversation as resolved.
Show resolved Hide resolved
>
<OakImage
src={imageUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ exports[`OakMediaClipStackListItem matches snapshot 1`] = `
className="c3"
>
<div
alt=""
k-huggs marked this conversation as resolved.
Show resolved Hide resolved
className="c4 c5"
src="https://res.cloudinary.com/mock-cloudinary-cloud/image/upload/v1698336494/samples/landscapes/nature-mountains.jpg"
>
<div
className="c6"
Expand Down
Loading