-
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.
- Loading branch information
Showing
15 changed files
with
211 additions
and
77 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,33 @@ | ||
import { Rule } from 'sanity' | ||
|
||
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), | ||
}, | ||
{ | ||
title: 'Color', | ||
description: 'Default is white.', | ||
name: 'backgroundColor', | ||
type: 'colorlist', | ||
}, | ||
], | ||
} |
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 { forwardRef } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
import { BaseLink, BaseLinkProps } from './BaseLink' | ||
import { TransformableIcon } from '../../icons/TransformableIcon' | ||
import { arrow_down, download, 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> | ||
<TransformableIcon | ||
iconData={isDownloadable ? download : 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
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
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.