Skip to content

Commit

Permalink
fixing searchguidelink styling
Browse files Browse the repository at this point in the history
  • Loading branch information
eniomoura committed Oct 25, 2024
1 parent f4003c9 commit 1640747
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/examples/searchguidelink/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function Example() {
href="https://pinterest.com"
text="Avatar"
thumbnail={{
avatar: <Avatar name="Keerthi" src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />,
avatar: <Avatar name="Keerthi" outline src="https://i.ibb.co/ZfCZrY8/keerthi.jpg" />,
}}
/>
<SearchGuideLink
Expand Down
11 changes: 3 additions & 8 deletions packages/gestalt/src/Link/InternalLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,17 @@ const InternalLinkWithForwardRef = forwardRef<HTMLAnchorElement, Props>(function
styles.noUnderline,
touchableStyles.tapTransition,
isSearchGuide && isInVRExperiment
? {
? // TODO: Coalesce these two blocks
{
[searchGuideStyles.searchguideVr]: true,
[touchableStyles.tapTransition]: true,
[searchGuideStyles[colorClass as keyof typeof searchGuideStyles]]: !selected,
[focusStyles.hideOutline]: !isFocusVisible,
[searchGuideStyles.vrFocused]: isFocusVisible,
[searchGuideStyles.selectedVr]: selected,
}
: {},
isSearchGuide && !isInVRExperiment
? {
[searchGuideStyles.searchguide]: true,
[touchableStyles.tapTransition]: true,
[searchGuideStyles[colorClass as keyof typeof searchGuideStyles]]: true,
[searchGuideStyles.selected]: selected,
[focusStyles.hideOutline]: !isFocusVisible && !selected,
[focusStyles.hideOutline]: !isFocusVisible,
[focusStyles.accessibilityOutline]: isFocusVisible,
}
: {},
Expand Down
8 changes: 2 additions & 6 deletions packages/gestalt/src/SearchGuide.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
display: inherit;
}

a.searchguide,
a.searchguideVr {
padding-bottom: var(--g-border-width-lg);
padding-top: var(--g-border-width-lg);
}

.searchguideVr {
background: transparent;
border-color: transparent;
border-radius: calc(var(--rounding-400) + var(--g-border-width-lg));
border-style: solid;
border-width: 2px;
box-sizing: border-box;
display: inherit;
padding: var(--space-0) var(--space-0);
Expand Down
54 changes: 33 additions & 21 deletions packages/gestalt/src/SearchGuideLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,46 @@ const SearchGuideLinkWithForwardRef = forwardRef<HTMLAnchorElement, Props>(funct
// that renders <SearchGuideLink ref={inputRef} /> to call inputRef.current.focus()
// @ts-expect-error - TS2322 - Type 'HTMLButtonElement | null' is not assignable to type 'HTMLButtonElement'.
useImperativeHandle(ref, () => innerRef.current);
const childrenDivClasses = classnames(styles.childrenDiv);

const childrenDivClasses = classnames(
styles.childrenDiv,
isInVRExperiment && {
[styles[`color${color}`]]: true,
},
);
const textComponent = (
<TextUI align="center" color="dark" overflow="noWrap">
{text}
</TextUI>
);
const thumbnailVariant = thumbnail && (
<Flex alignItems="center" gap={{ row: 2, column: 0 }} justifyContent="center">
{'avatar' in thumbnail && (
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={40}>
{cloneElement(thumbnail.avatar, { size: 'fit' })}
</Box>
)}
{'avatarGroup' in thumbnail && (
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={40}>
{cloneElement(thumbnail.avatarGroup, { size: 'sm' })}
</Box>
)}
{'image' in thumbnail && (
<div className={isInVRExperiment ? styles.imageDivVr : styles.imageDiv}>
{cloneElement(thumbnail.image, { fit: 'cover' })}
</div>
)}
{'icon' in thumbnail && <Box marginStart={3}>{cloneElement(thumbnail.icon)}</Box>}
<Box marginEnd={3}>{textComponent}</Box>
</Flex>
<Box marginEnd={3}>
<Flex alignItems="center" gap={{ row: 2, column: 0 }} justifyContent="center">
{'avatar' in thumbnail && (
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={32}>
{cloneElement(thumbnail.avatar, { size: 'fit', outline: true })}
</Box>
)}
{'avatarGroup' in thumbnail && (
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={32}>
{cloneElement(thumbnail.avatarGroup, { size: 'sm' })}
</Box>
)}
{'image' in thumbnail && (
<div className={isInVRExperiment ? styles.imageDivVr : styles.imageDiv}>
{cloneElement(thumbnail.image, { fit: 'cover' })}
</div>
)}
{'icon' in thumbnail && (
<Box marginStart={3}>
{cloneElement(thumbnail.icon, {
color: 'dark',
})}
</Box>
)}
{text.length > 0 && textComponent}
</Flex>
</Box>
);
const defaultVariant = (
<Box paddingX={5}>
Expand Down Expand Up @@ -152,7 +165,6 @@ const SearchGuideLinkWithForwardRef = forwardRef<HTMLAnchorElement, Props>(funct
<InternalLink
ref={innerRef}
aria-label={accessibilityLabel}
colorClass={`color${color}`}
dataTestId={dataTestId}
href={href}
onClick={handleClick}
Expand Down

0 comments on commit 1640747

Please sign in to comment.