Skip to content

Commit

Permalink
🐛 fix issues with resourcelink and promotile (#2249)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle authored Apr 22, 2024
1 parent e7e94c2 commit 053cfb4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
3 changes: 2 additions & 1 deletion web/core/Link/ResourceLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const ResourceLink = forwardRef<HTMLAnchorElement, ResourceLinkProps>(fun
text-energy-red-100
dark:text-white-100
justify-self-end
max-h-[25px]
${iconRotation[type]}
${
type === 'downloadableFile' || type === 'downloadableImage'
Expand All @@ -60,7 +61,7 @@ export const ResourceLink = forwardRef<HTMLAnchorElement, ResourceLinkProps>(fun

return (
<BaseLink className={classNames} ref={ref} href={href} {...rest}>
<span className="grid grid-cols-[auto_1fr] align-baseline pb-5 pr-2">
<span className="grid grid-cols-[1fr_max-content] gap-2 items-end pb-5 pr-2">
{children}
<ArrowRight className={iconClassNames} />
</span>
Expand Down
2 changes: 1 addition & 1 deletion web/core/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const List = forwardRef<HTMLDivElement, ListProps>(
className={twMerge(
`list-inside
${ListTag === 'ul' ? 'list-disc' : 'list-decimal'}
${split ? 'md:grid md:grid-cols-2 md:gap-8' : ''}`,
${split ? 'md:grid md:grid-cols-2 gap-x-8 gap-y-6 items-end' : ''}`,
className,
)}
>
Expand Down
15 changes: 10 additions & 5 deletions web/pageComponents/topicPages/PromoTileArray.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { BackgroundContainer } from '@components'
import Card from '@sections/cards/Card'
import { tokens } from '@equinor/eds-tokens'
import styled from 'styled-components'
import type { PromoTileArrayData, PromoTileData } from '../../types/types'
import Image, { Ratios } from '../shared/SanityImage'
import { Ratios } from '../shared/SanityImage'
import { Carousel } from '../shared/Carousel'
import { useMediaQuery } from '../../lib/hooks/useMediaQuery'
import { useSanityLoader } from '../../lib/hooks/useSanityLoader'
import { BaseLinkProps } from '@core/Link'
import { ArrowRight } from '../../icons'
import { getUrlFromAction } from '../../common/helpers'
import { colorKeyToUtilityMap } from '../../styles/colorKeyToUtilityMap'
import { ColorKeyTokens, colorKeyToUtilityMap } from '../../styles/colorKeyToUtilityMap'
import { twMerge } from 'tailwind-merge'

/* const { Header, Action, Media } = Card */
Expand Down Expand Up @@ -91,7 +89,14 @@ const TWPromoTile = ({ id, designOptions, image, title, action, linkLabelAsTitle
const bgImage = useSanityLoader(image, 400, Ratios.FIVE_TO_FOUR)
const url = getUrlFromAction(action)
const { background } = designOptions
const twBg = background?.backgroundUtility && colorKeyToUtilityMap[background.backgroundUtility]?.background
const colorName =
Object.keys(colorKeyToUtilityMap).find(
(key) => colorKeyToUtilityMap[key as keyof ColorKeyTokens]?.backgroundName === background?.backgroundColor,
) ?? 'white-100'

const twBg = background?.backgroundUtility
? colorKeyToUtilityMap[background.backgroundUtility]?.background
: colorKeyToUtilityMap[colorName as keyof ColorKeyTokens]?.background

return (
<Card
Expand Down
3 changes: 1 addition & 2 deletions web/sections/cards/Card/CardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ export const CardContent = forwardRef<HTMLDivElement, CardContentProps>(function
) {
const variantClassNames = {
primary: `flex-col items-start border border-grey-10 border-t-0`,
secondary: `flex-row items-center`,
secondary: `pb-12 lg:pb-16 flex-row items-center justify-between items-center`,
}
const variantLinkClassNames = {
primary: `self-end mt-auto`,
secondary: ``,
}
const iconClassNames = twMerge(
`
mt-4
max-h-8
text-energy-red-100
dark:text-white-100
Expand Down
9 changes: 9 additions & 0 deletions web/styles/colorKeyToUtilityMap.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
export const colorKeyToUtilityMap = {
'blue-50': {
backgroundName: 'Mid blue',
background: 'bg-blue-50',
text: 'text-blue-50',
},
'white-100': {
backgroundName: 'White',
background: 'bg-white-100',
text: 'text-white-100',
},
'moss-green-50': {
backgroundName: 'Moss Green Light',
background: 'bg-moss-green-50',
text: 'text-moss-green-50',
},
'spruce-wood-90': {
backgroundName: 'Spruce Wood',
background: 'bg-spruce-wood-90',
text: 'text-spruce-wood-90',
},
'mist-blue-100': {
backgroundName: 'Mist Blue',
background: 'bg-mist-blue-100',
text: 'text-mist-blue-100',
},
'energy-red-100': {
backgroundName: 'Energy Red',
background: 'bg-energy-red-100',
text: 'text-energy-red-100',
},
'green-50': {
backgroundName: 'Mid Green',
background: 'bg-green-50',
text: 'text-green-50',
},
'yellow-50': {
backgroundName: 'Mid Yellow',
background: 'bg-yellow-50',
text: 'text-yellow-50',
},
'orange-50': {
backgroundName: 'Mid Orange',
background: 'bg-orange-50',
text: 'text-orange-50',
},
Expand Down

0 comments on commit 053cfb4

Please sign in to comment.