Skip to content

Commit

Permalink
Merge branch 'padms/2736' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
padms committed Jan 22, 2025
2 parents 90c923c + a67eee3 commit 6c84287
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
10 changes: 10 additions & 0 deletions sanityv3/schemas/documents/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sharedHeroFields from './header/sharedHeaderFields'
import { EdsIcon } from '../../icons'
import { paste } from '@equinor/eds-icons'
import { lang } from './langField'
import { description } from '../objects/iframe/sharedIframeFields'

export default {
type: 'document',
Expand All @@ -26,6 +27,14 @@ export default {
collapsed: true,
},
},
{
title: 'Sticky Menu',
name: 'stickymenu',
options: {
collapsible: true,
collaped: true,
},
},
],
fields: [
lang,
Expand All @@ -46,6 +55,7 @@ export default {
name: 'stickyMenu',
title: 'Sticky Menu',
type: 'stickyMenu',
fieldset: 'stickymenu',
},
...sharedHeroFields,
{
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/schemas/objects/stickyMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
Rule.unique()
.max(2)
.custom((value: any) => {
if (value.length == 2 && value[0]._type == value[1]._type) return 'Cannot have two links of same type'
if (value?.length == 2 && value[0]._type == value[1]._type) return 'Cannot have two links of same type'
return true
}),
},
Expand Down
7 changes: 3 additions & 4 deletions web/core/Link/StickyMenuLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ export const StickyMenuLink = forwardRef<HTMLAnchorElement, StickMenuLinkProps>(
return (
<BaseLink className={classNames} ref={ref} href={href} {...rest}>
{isDownloadable && <TransformableIcon iconData={library_pdf} className="mr-1" />}
<span className={contentClassNames}>{children}</span>
<div className={contentClassNames}>{children}</div>
{isDownloadable && (
<TransformableIcon
iconData={arrow_down}
className="text-energy-red-100
dark:text-white-100 h-[22px] border-energy-red-100 border-b-[2px]
ml-2"
dark:text-white-100 h-[22px] border-energy-red-100 border-b-2 ml-4"
/>
)}
{!isDownloadable && (
<TransformableIcon
iconData={arrow_down}
className="text-energy-red-100
dark:text-white-100
ml-2"
ml-4"
/>
)}
</BaseLink>
Expand Down
3 changes: 2 additions & 1 deletion web/lib/queries/common/stickyMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ content->stickyMenu{
"links": links[]{
${downloadableFileFields},
${anchorLinkReferenceFields}
}
},
"background": coalesce(backgroundColor.key, 'white-100'),
}
`
11 changes: 8 additions & 3 deletions web/pageComponents/shared/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getAllSitesLink } from '../../common/helpers/getAllSitesLink'
import { Icon } from '@equinor/eds-core-react'
import { ButtonLink, LogoLink, StickyMenuLink } from '@core/Link'
import SiteMenu from '@sections/SiteMenu/SiteMenu'
import { ColorKeyTokens, colorKeyToUtilityMap } from '../../styles/colorKeyToUtilityMap'

const TopbarOffset = createGlobalStyle`
body {
Expand Down Expand Up @@ -109,6 +110,9 @@ const Header = ({ slugs, menuData, stickyMenuData }: HeaderProps) => {
const anchorReference = stickyMenuData?.links.find((it) => it.type == 'anchorLinkReference')
const resourceLink = stickyMenuData?.links.find((it) => it.type == 'downloadableFile')

const stickyMenuKey = (stickyMenuData?.background as keyof ColorKeyTokens) || ('white-100' as keyof ColorKeyTokens)
const twBg = colorKeyToUtilityMap[stickyMenuKey]?.background

return (
<div className="sticky top-0 z-10">
<HeadTags slugs={slugs} />
Expand Down Expand Up @@ -154,14 +158,15 @@ const Header = ({ slugs, menuData, stickyMenuData }: HeaderProps) => {
</Topbar.InnerContainer>
</Topbar>
{stickyMenuData && (
<div className="w-full items-center bg-moss-green-50 p-4 grid grid-cols-2 lg:grid-cols-5 gap-2 lg:px-16 lg:gap-16 shadow-top-bar z-40">
<div className="text-center font-bold lg:col-span-3 text-md col-span-2"> {stickyMenuData?.title}</div>
<div
className={`hidden lg:grid w-full items-center ${twBg} p-4 grid-cols-2 lg:grid-cols-5 gap-2 lg:px-16 lg:gap-16 shadow-top-bar z-40`}
>
<div className="text-center font-medium lg:col-span-3 text-md col-span-2"> {stickyMenuData?.title}</div>
<StickyMenuLink className="mr-4 place-self-end self-center" href={`#${anchorReference?.anchorReference}`}>
{anchorReference?.title}
</StickyMenuLink>
{resourceLink && (
<StickyMenuLink href={resourceLink.href} isDownloadable>
{' '}
{resourceLink.label}
</StickyMenuLink>
)}
Expand Down
1 change: 1 addition & 0 deletions web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,5 @@ export type StickyMenuData = {
type: 'stickyMenu'
title: string
links: StickyMenuLinkType[]
background: string
}

0 comments on commit 6c84287

Please sign in to comment.