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

Button: VR Certification Fixes #3802

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 20 additions & 2 deletions packages/gestalt/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ type Props = {
type?: 'button' | 'submit';
};

function InternalButtonWrapper({ children }: { children: ReactNode }) {
const isInVRExperiment = useInExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

return isInVRExperiment ? (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to not use Flex?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, 6 px?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill bring this to the meeting on tuesday

{children}
</div>
) : (
<Flex alignItems="center" gap={{ row: 2, column: 0 }} justifyContent="center">
{children}
</Flex>
);
}

function InternalButtonContent({
target,
text,
Expand All @@ -137,7 +154,7 @@ function InternalButtonContent({
}) {
return (
<Fragment>
<Flex alignItems="center" gap={{ row: 2, column: 0 }} justifyContent="center">
<InternalButtonWrapper>
{iconStart && (
<Icon
accessibilityLabel=""
Expand All @@ -157,7 +174,7 @@ function InternalButtonContent({
size={SIZE_NAME_TO_PIXEL[size]}
/>
) : null}
</Flex>
</InternalButtonWrapper>
<NewTabAccessibilityLabel target={target} />
</Fragment>
);
Expand Down Expand Up @@ -364,6 +381,7 @@ const ButtonWithForwardRef = forwardRef<HTMLButtonElement, Props>(function Butto
onTouchMove={handleTouchMove}
// @ts-expect-error - TS2322 - Type '(arg1: TouchEvent<HTMLDivElement>) => void' is not assignable to type 'TouchEventHandler<HTMLButtonElement>'.
onTouchStart={handleTouchStart}
style={isInVRExperiment ? compressStyle || undefined : undefined}
// @ts-expect-error - TS2322 - Type '0 | -1 | null' is not assignable to type 'number | undefined'.
tabIndex={disabled ? null : tabIndex}
type="button"
Expand Down
18 changes: 15 additions & 3 deletions packages/gestalt/src/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Children, ReactNode } from 'react';
import Box from './Box';
import useInExperiment from './useInExperiment';

type Props = {
/**
Expand All @@ -16,15 +17,26 @@ type Props = {
*
*/
function ButtonGroup({ children }: Props) {
const isInVRExperiment = useInExperiment({
webExperimentName: 'web_gestalt_visualRefresh',
mwebExperimentName: 'web_gestalt_visualRefresh',
});

if (Children.count(children) === 0) {
return null;
}

return (
<Box display="flex" margin={-1} wrap>
{Children.map(children, (child) =>
child !== null && child !== undefined ? <Box padding={1}>{child}</Box> : null,
)}
{isInVRExperiment
? Children.map(children, (child) =>
child !== null && child !== undefined ? (
<div style={{ padding: 2 }}>{child}</div>
eniomoura marked this conversation as resolved.
Show resolved Hide resolved
) : null,
)
: Children.map(children, (child) =>
child !== null && child !== undefined ? <Box padding={1}>{child}</Box> : null,
)}
</Box>
);
}
Expand Down
Loading