Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchGuide: Fixing issue with selected/focus and shrinking image #3799

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 4 additions & 34 deletions packages/gestalt/src/SearchGuide.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ a.searchguideVr {
}

.searchguideVr {
background: transparent;
border-color: transparent;
border-radius: var(--rounding-400);
box-sizing: border-box;
Expand All @@ -33,6 +34,7 @@ a.searchguideVr {
composes: flex from "./Layout.css";
composes: xsItemsCenter from "./Layout.css";
composes: justifyCenter from "./Layout.css";
border-radius: var(--rounding-400);
eniomoura marked this conversation as resolved.
Show resolved Hide resolved
min-height: 44px;
}

Expand All @@ -46,41 +48,9 @@ a.searchguideVr {
.imageDivVr {
border-end-start-radius: calc(var(--rounding-400) - 2px);
border-start-start-radius: calc(var(--rounding-400) - 2px);
height: 48px;
margin-block-end: -2px;
margin-block-start: -2px;
margin-inline-start: -2px;
overflow: hidden;
width: 48px;
}

.searchguideVr:focus-visible .imageDivVr {
border: solid;
border-block-start-width: 2px;
border-color: var(--sema-color-border-focus-inner-default);
border-inline-end-width: 0;
border-inline-start-width: 2px;
border-inline-start-width: 2px;
box-sizing: border-box;
}

.searchguideVr:not(:focus-visible) .selectedImageDivVr {
border: solid;
border-block-end-width: 2px;
border-block-start-width: 1px;
border-color: var(--color-background-button-selected-default);
border-end-start-radius: calc(var(--rounding-400) - 2px);
border-inline-end-width: 0;
border-inline-start-width: 2px;
border-inline-start-width: 1px;
border-start-start-radius: calc(var(--rounding-400) - 2px);
box-sizing: border-box;
height: 48px;
margin-block-end: -2px;
margin-block-start: -1px;
margin-inline-start: -1px;
height: 44px;
overflow: hidden;
width: 48px;
width: 44px;
}

/* STATES */
Expand Down
29 changes: 24 additions & 5 deletions packages/gestalt/src/SearchGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,38 @@ const SearchGuideWithForwardRef = forwardRef<HTMLButtonElement, Props>(function
useImperativeHandle(ref, () => innerRef.current);
const { isFocusVisible } = useFocusVisible();

const colorClass: { [key: string]: keyof typeof styles } = {
'01': 'color01',
'02': 'color02',
'03': 'color03',
'04': 'color04',
'05': 'color05',
'06': 'color06',
'07': 'color07',
'08': 'color08',
'09': 'color09',
'10': 'color10',
'11': 'color11',
};

const buttonClasses = isInVRExperiment
? classnames(styles.searchguideVr, touchableStyles.tapTransition, {
[styles[`color${color}`]]: !selected,
[focusStyles.hideOutline]: !isFocusVisible,
[styles.vrFocused]: isFocusVisible,
[styles.selectedVr]: selected,
})
: classnames(styles.searchguide, touchableStyles.tapTransition, [styles[`color${color}`]], {
: classnames(styles.searchguide, touchableStyles.tapTransition, [styles[colorClass[color]!]], {
[styles.selected]: selected,
[focusStyles.hideOutline]: !isFocusVisible && !selected,
[focusStyles.accessibilityOutline]: isFocusVisible,
});
const childrenDivClasses = classnames(styles.childrenDiv);
const childrenDivClasses = classnames(
styles.childrenDiv,
isInVRExperiment && {
[styles[`color${color}`]]: !selected,
eniomoura marked this conversation as resolved.
Show resolved Hide resolved
[styles.selectedVr]: selected,
},
);

const textComponent =
text.length > 0 ? (
Expand All @@ -131,12 +150,12 @@ const SearchGuideWithForwardRef = forwardRef<HTMLButtonElement, Props>(function
<Box marginEnd={3}>
<Flex alignItems="center" gap={{ row: 2, column: 0 }} justifyContent="center">
{'avatar' in thumbnail && (
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={40}>
<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={40}>
<Box aria-hidden marginStart={isInVRExperiment ? 2 : undefined} minWidth={32}>
{cloneElement(thumbnail.avatarGroup, { size: 'sm' })}
</Box>
)}
Expand Down
Loading