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

isom-1646 - infocards and infocols should behave consistently when opens in a new link #954

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
22 changes: 7 additions & 15 deletions apps/studio/public/assets/css/preview-tw.css
Original file line number Diff line number Diff line change
Expand Up @@ -1418,10 +1418,6 @@ video {
-webkit-line-clamp: 3;
}

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

.block {
display: block;
}
Expand Down Expand Up @@ -1821,6 +1817,13 @@ video {
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.rotate-\[-45deg\] {
--tw-rotate: -45deg;
transform: translate(var(--tw-translate-x), var(--tw-translate-y))
rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.scale-100 {
--tw-scale-x: 1;
--tw-scale-y: 1;
Expand Down Expand Up @@ -3156,11 +3159,6 @@ 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 @@ -5510,12 +5508,6 @@ 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
2 changes: 2 additions & 0 deletions packages/components/src/interfaces/complex/InfoCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,15 @@ export const InfoCardsSchema = Type.Intersect(

export type SingleCardNoImageProps = Static<typeof SingleCardNoImageSchema> & {
site: IsomerSiteProps
isExternalLink?: boolean
LinkComponent?: LinkComponentType
}
export type SingleCardWithImageProps = Static<
typeof SingleCardWithImageSchema
> & {
site: IsomerSiteProps
layout: IsomerPageLayoutType
isExternalLink?: boolean
LinkComponent?: LinkComponentType
}
export type InfoCardsProps = Static<typeof InfoCardsSchema> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const generateArgs = ({
imageUrl: "https://placehold.co/200x300",
imageAlt: "alt text",
imageFit: "contain",
url: "https://www.google.com",
url: "/faq",
},
{
title: "Card with short title",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const createInfoCardsStyles = tv({
grid: "md:grid-cols-2 lg:grid-cols-3",
},
},
isExternalLink: {
true: {
cardTitleArrow: "rotate-[-45deg]",
},
},
},
defaultVariants: {
layout: "default",
Expand All @@ -103,14 +108,19 @@ const InfoCardContainer = ({
site,
LinkComponent,
children,
isExternalLink,
}: PropsWithChildren<
Pick<SingleCardNoImageProps, "url" | "site" | "LinkComponent">
Pick<
SingleCardNoImageProps,
"url" | "site" | "isExternalLink" | "LinkComponent"
>
>): JSX.Element => {
return url ? (
<Link
href={getReferenceLinkHref(url, site.siteMap, site.assetsBaseUrl)}
className={compoundStyles.cardContainer()}
LinkComponent={LinkComponent}
isExternal={isExternalLink}
>
{children}
</Link>
Expand Down Expand Up @@ -159,9 +169,10 @@ const InfoCardText = ({
title,
description,
url,
isExternalLink,
}: Pick<
SingleCardWithImageProps,
"title" | "description" | "url"
"title" | "description" | "url" | "isExternalLink"
>): JSX.Element => (
<div className={compoundStyles.cardTextContainer()}>
<h3 className={infoCardTitleStyle({ isClickableCard: !!url })}>
Expand All @@ -170,7 +181,9 @@ const InfoCardText = ({
{url && (
<BiRightArrowAlt
aria-hidden
className={compoundStyles.cardTitleArrow()}
className={compoundStyles.cardTitleArrow({
isExternalLink,
})}
/>
)}
</h3>
Expand All @@ -185,9 +198,20 @@ const InfoCardNoImage = ({
site,
LinkComponent,
}: SingleCardNoImageProps): JSX.Element => {
const isExternalLink = isExternalUrl(url)
return (
<InfoCardContainer url={url} site={site} LinkComponent={LinkComponent}>
<InfoCardText title={title} description={description} url={url} />
<InfoCardContainer
url={url}
site={site}
isExternalLink={isExternalLink}
LinkComponent={LinkComponent}
>
<InfoCardText
title={title}
description={description}
url={url}
isExternalLink={isExternalLink}
/>
</InfoCardContainer>
)
}
Expand All @@ -203,8 +227,14 @@ const InfoCardWithImage = ({
site,
LinkComponent,
}: SingleCardWithImageProps): JSX.Element => {
const isExternalLink = isExternalUrl(url)
return (
<InfoCardContainer url={url} site={site} LinkComponent={LinkComponent}>
<InfoCardContainer
url={url}
site={site}
isExternalLink={isExternalLink}
LinkComponent={LinkComponent}
>
<InfoCardImage
imageFit={imageFit}
imageUrl={imageUrl}
Expand All @@ -213,7 +243,12 @@ const InfoCardWithImage = ({
site={site}
layout={layout}
/>
<InfoCardText title={title} description={description} url={url} />
<InfoCardText
title={title}
description={description}
url={url}
isExternalLink={isExternalLink}
/>
</InfoCardContainer>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getReferenceLinkHref,
getTailwindVariantLayout,
groupFocusVisibleHighlight,
isExternalUrl,
} from "~/utils"
import { ComponentContent } from "../../internal/customCssClass"
import { Link } from "../../internal/Link"
Expand Down Expand Up @@ -48,6 +49,11 @@ const createInfoColsStyles = tv({
headerSubtitle: "prose-body-base",
},
},
isExternalLink: {
true: {
infoBoxButtonIcon: "rotate-[-45deg]",
},
},
},
defaultVariants: {
layout: "default",
Expand All @@ -72,37 +78,43 @@ const InfoBoxes = ({
return (
<div className={compoundStyles.infoBoxesContainer()}>
{infoBoxes.map(
({ title, icon, description, buttonUrl, buttonLabel }, idx) => (
<Link
LinkComponent={LinkComponent}
href={getReferenceLinkHref(
buttonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
key={idx}
className={compoundStyles.infoBox()}
>
{icon && <InfoBoxIcon icon={icon} aria-hidden="true" />}
({ title, icon, description, buttonUrl, buttonLabel }, idx) => {
const isExternalLink = isExternalUrl(buttonUrl)
return (
<Link
LinkComponent={LinkComponent}
href={getReferenceLinkHref(
buttonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
key={idx}
className={compoundStyles.infoBox()}
isExternal={isExternalLink}
>
{icon && <InfoBoxIcon icon={icon} aria-hidden="true" />}

<h3 className={compoundStyles.infoBoxTitle()}>{title}</h3>
<h3 className={compoundStyles.infoBoxTitle()}>{title}</h3>

{description && (
<p className={compoundStyles.infoBoxDescription()}>
{description}
</p>
)}
{description && (
<p className={compoundStyles.infoBoxDescription()}>
{description}
</p>
)}

{buttonLabel && buttonUrl && (
<div className={compoundStyles.infoBoxButton()}>
{buttonLabel}
<BiRightArrowAlt
className={compoundStyles.infoBoxButtonIcon()}
/>
</div>
)}
</Link>
),
{buttonLabel && buttonUrl && (
<div className={compoundStyles.infoBoxButton()}>
{buttonLabel}
<BiRightArrowAlt
className={compoundStyles.infoBoxButtonIcon({
isExternalLink,
})}
/>
</div>
)}
</Link>
)
},
)}
</div>
)
Expand Down
Loading