Skip to content

Commit

Permalink
try on pr env
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamwasp committed Sep 25, 2024
1 parent adaf964 commit bb6348e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/gamut/src/Tip/PreviewTip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useId } from '@reach/auto-id';
import { set } from 'lodash';
import {
ComponentProps,
FocusEvent,
Expand All @@ -18,7 +19,7 @@ import {
tipDefaultProps,
} from '../shared/types';
import { PreviewTipAnchor } from './elements';
import { getPreviewDescription } from './utils';
import { getPreviewDescription, getPreviewLabel } from './utils';

export type PreviewTipProps = ComponentProps<typeof Anchor> &
Pick<TipBaseProps, 'placement'> &
Expand Down Expand Up @@ -61,6 +62,7 @@ export const PreviewTip: React.FC<PreviewTipProps> = ({
const isFloating = placement === 'floating';
const Tip = loaded && isFloating ? FloatingTip : InlineTip;

const label = getPreviewLabel({ avatar, children });
const description = useMemo(
() => getPreviewDescription({ linkDescription, overline, username }),
[linkDescription, overline, username]
Expand All @@ -82,19 +84,20 @@ export const PreviewTip: React.FC<PreviewTipProps> = ({
<Tip {...tipProps} type="preview">
<Text
aria-hidden={!isLive}
aria-live={isLive ? 'polite' : 'off'}
aria-live={isLive ? 'assertive' : 'off'}
aria-busy={loading}
screenreader
id={descriptionId}
>
{loading && !linkDescription
? 'Preview content is loading '
: `${description}`}
<div id={descriptionId}>
{loading && !linkDescription
? 'Preview content is loading '
: `${description}`}
</div>
</Text>

<PreviewTipAnchor
{...rest}
aria-label={avatar ? `Profile Preview:` : `Link Preview:`}
aria-label={label}
aria-describedby={descriptionId}
display={avatar && rest?.display === undefined ? 'flex' : rest?.display}
tipType={avatar ? 'avatar' : 'anchor'}
Expand Down
9 changes: 9 additions & 0 deletions packages/gamut/src/Tip/PreviewTip/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ export const getPreviewDescription = ({
username ? `${username} ` : ''
}${linkDescription}`;
};

export const getPreviewLabel = ({
avatar,
children,
}: Pick<PreviewTipProps, 'avatar' | 'children'>) => {
const textChildren = typeof children === 'string' ? `${children} ` : '';

return avatar ? 'Profile Preview:' : `${textChildren}Link Preview:`;
};

0 comments on commit bb6348e

Please sign in to comment.