-
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.
Browse files
Browse the repository at this point in the history
* ✨ Modal transcript - initial version #2236 * ✨ Modal transcript initial version #2236 * Some more * ✨ Add transcript for iframe #2236 * ♿️ Aria labels #2236
- Loading branch information
Showing
23 changed files
with
448 additions
and
62 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
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,32 @@ | ||
import { defineType, defineField } from 'sanity' | ||
import { configureBlockContent } from '../editors/blockContentType' | ||
import CompactBlockEditor from '../components/CompactBlockEditor' | ||
|
||
const blockConfig = { | ||
h2: false, | ||
h3: false, | ||
h4: false, | ||
smallText: false, | ||
internalLink: false, | ||
externalLink: false, | ||
attachment: false, | ||
lists: true, | ||
} | ||
|
||
const blockContentType = configureBlockContent({ ...blockConfig }) | ||
|
||
export default { | ||
name: 'transcript', | ||
title: 'Transcript', | ||
type: 'object', | ||
fields: [ | ||
{ | ||
name: 'text', | ||
type: 'array', | ||
components: { | ||
input: CompactBlockEditor, | ||
}, | ||
of: [blockContentType], | ||
}, | ||
], | ||
} |
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
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,50 @@ | ||
import { forwardRef, Ref, SVGProps } from 'react' | ||
import { IconData } from '@equinor/eds-icons' | ||
|
||
/** | ||
* Use this to transform an icon for example arrow right can be rotated to | ||
* 45 deg/-90 deg to use it as external link icon or download icon. | ||
* Similarly the + and close | ||
*/ | ||
export type TransformableIconProps = { | ||
iconData: IconData | ||
/** Size, use if you need large icon resolutions | ||
* @default 24 | ||
*/ | ||
size?: 16 | 18 | 24 | 32 | 40 | 48 | ||
/** @ignore */ | ||
ref?: Ref<SVGSVGElement> | ||
} & SVGProps<SVGSVGElement> | ||
|
||
export const TransformableIcon = forwardRef<SVGSVGElement, TransformableIconProps>(function ArrowRight( | ||
{ iconData, size = 24, className = '', ...rest }, | ||
ref, | ||
) { | ||
let icon = iconData | ||
if (size < 24) { | ||
// fallback to normal icon if small is not made yet | ||
icon = icon.sizes?.small || icon | ||
} | ||
return ( | ||
<svg | ||
ref={ref} | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={size} | ||
height={size} | ||
viewBox={`0 0 ${size} ${size}`} | ||
fill="currentColor" | ||
aria-hidden | ||
className={className} | ||
{...rest} | ||
> | ||
{Array.isArray(icon.svgPathData) ? ( | ||
icon.svgPathData.map((pathData) => { | ||
return <path key={pathData} fillRule="evenodd" clipRule="evenodd" d={pathData} /> | ||
}) | ||
) : ( | ||
<path fillRule="evenodd" clipRule="evenodd" d={icon.svgPathData} /> | ||
)} | ||
</svg> | ||
) | ||
}) | ||
export default TransformableIcon |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { LinkData } from '../../types' | ||
import { getUrlFromAction } from '../../common/helpers' | ||
import { useState } from 'react' | ||
import { PortableTextBlock } from '@portabletext/types' | ||
import { ButtonLink } from '@core/Link' | ||
import { commonButtonStyling, getVariant } from '@core/Button' | ||
import { getLocaleFromName } from '../../lib/localization' | ||
import Modal from '@sections/Modal/Modal' | ||
import RichText from './portableText/RichText' | ||
import { add_circle_filled } from '@equinor/eds-icons' | ||
import { twMerge } from 'tailwind-merge' | ||
import { TransformableIcon } from '../../icons/TransformableIcon' | ||
import { useIntl } from 'react-intl' | ||
import { title } from 'process' | ||
|
||
type TranscriptAndActionsProps = { | ||
className?: string | ||
action?: LinkData | ||
transcript?: PortableTextBlock[] | ||
ariaTitle: string | ||
} | ||
const TranscriptAndActions = ({ action, transcript, className, ariaTitle }: TranscriptAndActionsProps) => { | ||
const [isOpen, setIsOpen] = useState(false) | ||
const actionUrl = action ? getUrlFromAction(action) : '' | ||
const intl = useIntl() | ||
const readTranscript = intl.formatMessage({ id: 'read_transcript', defaultMessage: 'Read transcript' }) | ||
const handleOpen = () => { | ||
setIsOpen(true) | ||
} | ||
const handleClose = () => { | ||
setIsOpen(false) | ||
} | ||
return ( | ||
<div className={twMerge(`grid md:grid-cols-2 md:gap-x-4 md:pt-11 pt-8`, className)}> | ||
{action && action.label && ( | ||
<ButtonLink | ||
href={actionUrl || ''} | ||
aria-label={action?.ariaLabel} | ||
variant="outlined" | ||
className={`w-full md:mb-8 mb-4 justify-center ${getVariant('outlined-secondary')}`} | ||
locale={action?.type === 'internalUrl' ? getLocaleFromName(action?.link?.lang) : undefined} | ||
> | ||
{action.label} | ||
</ButtonLink> | ||
)} | ||
|
||
{transcript && ( | ||
<> | ||
<button | ||
onClick={handleOpen} | ||
aria-label={`${readTranscript} ${ariaTitle}`} | ||
className={`w-full mb-8 ${commonButtonStyling} ${getVariant('contained-secondary')}`} | ||
> | ||
<span className="grow">{readTranscript}</span> | ||
<TransformableIcon className={'scale-90 lg:scale-100'} iconData={add_circle_filled} /> | ||
</button> | ||
<Modal isOpen={isOpen} onClose={handleClose} title={ariaTitle}> | ||
<RichText value={transcript} /> | ||
</Modal> | ||
</> | ||
)} | ||
</div> | ||
) | ||
} | ||
export default TranscriptAndActions |
Oops, something went wrong.