-
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.
* ✨ Sticky Menu Component * 💄 Remove additional classes #2736 * Miised commit * ♻️ Add validations and exclude colors #2736 * ♻️ Changes after review #2736 * 💄 Fix bg in tw #2736 * ♻️ Fix after comments #2736 * 🐛 Handle error #2736 * 🐛 After 2 nd review #2736 * 💄 Use tailwind #2736
- Loading branch information
Showing
15 changed files
with
241 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,56 @@ | ||
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" />} | ||
<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-2 ml-4" | ||
/> | ||
)} | ||
{!isDownloadable && ( | ||
<TransformableIcon | ||
iconData={arrow_down} | ||
className="text-energy-red-100 | ||
dark:text-white-100 | ||
ml-4" | ||
/> | ||
)} | ||
</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,14 @@ | ||
import downloadableFileFields from './actions/downloadableFileFields' | ||
import { anchorLinkReferenceFields } from './anchorLinkReferenceFields' | ||
|
||
export const stickyMenu = /* groq */ `"stickyMenu": | ||
content->stickyMenu{ | ||
title, | ||
"type": _type, | ||
"links": links[]{ | ||
${downloadableFileFields}, | ||
${anchorLinkReferenceFields} | ||
}, | ||
"background": coalesce(backgroundColor.key, 'white-100'), | ||
} | ||
` |
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.