-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'padms/2736' into staging
- Loading branch information
Showing
15 changed files
with
216 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Rule } from 'sanity' | ||
import { defaultColors } from '../defaultColors' | ||
import { description } from './iframe/sharedIframeFields' | ||
|
||
const chosenColors = ['White', 'Moss Green Light'] | ||
const backgroundColors = defaultColors.filter((color) => chosenColors.includes(color.title)) | ||
|
||
export default { | ||
name: 'stickyMenu', | ||
title: 'Sticky Menu', | ||
type: 'object', | ||
fields: [ | ||
{ | ||
title: 'Title', | ||
name: 'title', | ||
type: 'string', | ||
}, | ||
{ | ||
title: 'Links', | ||
name: 'links', | ||
type: 'array', | ||
of: [ | ||
{ | ||
type: 'anchorLinkReference', | ||
title: 'Anchor reference', | ||
}, | ||
{ type: 'downloadableFile', title: 'Downloadable file' }, | ||
], | ||
validation: (Rule: Rule) => | ||
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' | ||
return true | ||
}), | ||
}, | ||
{ | ||
title: 'Color', | ||
description: 'Default is white.', | ||
name: 'backgroundColor', | ||
type: 'colorlist', | ||
options: { | ||
colors: backgroundColors, | ||
}, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { forwardRef } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
import { BaseLink, BaseLinkProps } from './BaseLink' | ||
import { TransformableIcon } from '../../icons/TransformableIcon' | ||
import { arrow_down, library_pdf } from '@equinor/eds-icons' | ||
|
||
export type StickMenuLinkProps = { | ||
isDownloadable?: boolean | ||
} & BaseLinkProps | ||
|
||
/** Sticky menu link style */ | ||
export const StickyMenuLink = forwardRef<HTMLAnchorElement, StickMenuLinkProps>(function StickyMenuLink( | ||
{ children, type = 'internalUrl', className = '', href = '', isDownloadable = false, ...rest }, | ||
ref, | ||
) { | ||
const classNames = twMerge( | ||
` | ||
group | ||
inline-flex | ||
align-baseline | ||
w-fit | ||
text-slate-80 | ||
leading-0 | ||
`, | ||
className, | ||
) | ||
const contentClassNames = ` | ||
relative | ||
w-fit | ||
hover:underline | ||
no-underline | ||
` | ||
|
||
return ( | ||
<BaseLink className={classNames} ref={ref} href={href} {...rest}> | ||
{isDownloadable && <TransformableIcon iconData={library_pdf} className="mr-1" />} | ||
<span className={contentClassNames}>{children}</span> | ||
{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" | ||
/> | ||
)} | ||
{!isDownloadable && ( | ||
<TransformableIcon | ||
iconData={arrow_down} | ||
className="text-energy-red-100 | ||
dark:text-white-100 | ||
ml-2" | ||
/> | ||
)} | ||
</BaseLink> | ||
) | ||
}) | ||
export default StickyMenuLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const anchorLinkReferenceFields = /* groq */ ` | ||
_type == "anchorLinkReference" =>{ | ||
"type": _type, | ||
"id": _key, | ||
title, | ||
anchorReference, | ||
}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import downloadableFileFields from './actions/downloadableFileFields' | ||
import { anchorLinkReferenceFields } from './anchorLinkReferenceFields' | ||
|
||
export const stickyMenu = /* groq */ `"stickyMenu": | ||
content->stickyMenu{ | ||
title, | ||
"type": _type, | ||
"links": links[]{ | ||
${downloadableFileFields}, | ||
${anchorLinkReferenceFields} | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.