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

feat(action): unify focus state #834

Merged
merged 1 commit into from
Oct 18, 2023
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions src/components/Accordion/AccordionCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ const Header = styled(Padbox)`
&:hover {
background-color: rgb(0 0 0 / 4%);
}

&:focus-visible {
position: relative;
z-index: 1;
outline: 4px solid ${getColor('primary.200')};
border-radius: 4px;
}
`;

const Content = styled.div`
Expand Down
30 changes: 0 additions & 30 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ export const SolidButtons: Story = () => (
<Button className="hover" color="primary" variant="solid">
Hovered Button
</Button>
<Button className="focus" color="primary" variant="solid">
Focused Button
</Button>
<Button className="active" color="primary" variant="solid">
Active Button
</Button>
Expand All @@ -71,9 +68,6 @@ export const SolidButtons: Story = () => (
<Button className="hover" color="success" variant="solid">
Hovered Button
</Button>
<Button className="focus" color="success" variant="solid">
Focused Button
</Button>
<Button className="active" color="success" variant="solid">
Active Button
</Button>
Expand All @@ -88,9 +82,6 @@ export const SolidButtons: Story = () => (
<Button className="hover" color="danger" variant="solid">
Hovered Button
</Button>
<Button className="focus" color="danger" variant="solid">
Focused Button
</Button>
<Button className="active" color="danger" variant="solid">
Active Button
</Button>
Expand All @@ -110,9 +101,6 @@ export const OutlineButtons: Story = () => (
<Button className="hover" color="primary" variant="outline">
Hovered Button
</Button>
<Button className="focus" color="primary" variant="outline">
Focused Button
</Button>
<Button className="active" color="primary" variant="outline">
Active Button
</Button>
Expand All @@ -127,9 +115,6 @@ export const OutlineButtons: Story = () => (
<Button className="hover" color="success" variant="outline">
Hovered Button
</Button>
<Button className="focus" color="success" variant="outline">
Focused Button
</Button>
<Button className="active" color="success" variant="outline">
Active Button
</Button>
Expand All @@ -144,9 +129,6 @@ export const OutlineButtons: Story = () => (
<Button className="hover" color="danger" variant="outline">
Hovered Button
</Button>
<Button className="focus" color="danger" variant="outline">
Focused Button
</Button>
<Button className="active" color="danger" variant="outline">
Active Button
</Button>
Expand All @@ -166,9 +148,6 @@ export const TextButtons: Story = () => (
<Button className="hover" color="primary" variant="text">
Hovered Button
</Button>
<Button className="focus" color="primary" variant="text">
Focused Button
</Button>
<Button className="active" color="primary" variant="text">
Active Button
</Button>
Expand All @@ -183,9 +162,6 @@ export const TextButtons: Story = () => (
<Button className="hover" color="secondary" variant="text">
Hovered Button
</Button>
<Button className="focus" color="secondary" variant="text">
Focused Button
</Button>
<Button className="active" color="secondary" variant="text">
Active Button
</Button>
Expand All @@ -200,9 +176,6 @@ export const TextButtons: Story = () => (
<Button className="hover" color="success" variant="text">
Hovered Button
</Button>
<Button className="focus" color="success" variant="text">
Focused Button
</Button>
<Button className="active" color="success" variant="text">
Active Button
</Button>
Expand All @@ -217,9 +190,6 @@ export const TextButtons: Story = () => (
<Button className="hover" color="danger" variant="text">
Hovered Button
</Button>
<Button className="focus" color="danger" variant="text">
Focused Button
</Button>
<Button className="active" color="danger" variant="text">
Active Button
</Button>
Expand Down
8 changes: 1 addition & 7 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pipe, prop } from 'ramda';
import cls from 'classnames';

import { Padbox, Stack } from '../layout';
import { getColor, getRadii, getShadow, getSpace, getToken } from '../../utils';
import { getColor, getRadii, getShadow, getSpace } from '../../utils';
import { SpaceSize } from '../../theme/space.types';
import { CardProps, CardWrapperProps } from './Card.types';
import { CLX_COMPONENT } from '../../theme/constants';
Expand All @@ -17,12 +17,6 @@ const InteractiveCard = css`
&:hover {
box-shadow: 0px 10px 16px rgba(0, 0, 0, 0.07);
}
&:focus-visible {
outline: 0;
box-shadow: 0px 10px 16px rgba(0, 0, 0, 0.07),
inset 0 0 0 1px ${getToken('color-action-primary')};
border-color: ${getToken('color-action-primary')};
}
&:active {
box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.07);
}
Expand Down
7 changes: 1 addition & 6 deletions src/components/Card/CardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ export const CardIconButton = styled.button<{
props.as !== 'div' &&
css`
cursor: pointer;
&:hover,
&:focus-visible {
&:hover {
background-color: ${getColor('primary.50')};
}
&:focus {
outline: none;
}
`}
`;
export const CardIconWrapper = styled(Padbox)`
Expand Down Expand Up @@ -86,7 +82,6 @@ const StyledIcon = styled(Icon).withConfig<{ color: Color }>({
border-radius: 100%;
color: ${({ color, theme }) =>
isNotUndefined(color) ? getColor(color, { theme }) : 'inherit'};
&:focus-visible,
&:hover {
color: ${({ theme }) => getColor('neutral.700', { theme })};
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/CloseButton/CloseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ const CloseButtonWrapper = styled.button<CloseButtonWrapperProps>`
padding: ${getSpace(SpaceSizes.sm)};
color: ${({ $isInverted, theme }) =>
getColor($isInverted ? 'neutral.0' : 'neutral.1000', { theme })};
outline-offset: ${getNegativeSpace(SpaceSizes.sm)};

&:hover
${/* sc-selector */ IconWrapper},
&:focus
${/* sc-selector */ IconWrapper} {
outline: none;
&:hover ${/* sc-selector */ IconWrapper} {
background-color: ${(props) =>
transparentize(0.96, getColor('neutral.1000', props))};
}
Expand Down
17 changes: 9 additions & 8 deletions src/components/Collapsible/Collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import styled, { css } from 'styled-components';
import { includes } from 'ramda';
import cls from 'classnames';

Expand All @@ -19,17 +19,17 @@ import { CLX_COMPONENT } from '../../theme/constants';
const Header = styled(Padbox)`
width: 100%;
cursor: pointer;
border-radius: ${getRadii('default')};

${({ $isOpen }) =>
$isOpen &&
css`
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
`}
&:hover {
background-color: rgb(0 0 0 / 4%);
}

&:focus-visible {
position: relative;
z-index: 1;
outline: 4px solid ${getColor('primary.200')};
border-radius: ${getRadii('default')};
}
`;

const HeaderContent = styled.div`
Expand Down Expand Up @@ -73,6 +73,7 @@ const Collapsible: React.FC<CollapsibleProps> = ({
return (
<Container className={cls(CLX_COMPONENT, className)}>
<Header
$isOpen={isOpen}
paddingSize={SpaceSizes.mdPlus}
paddingType={PaddingTypes.squish}
tabIndex={0}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DropdownMenu/DropdownMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DropdownMenuProps } from '../_internal/BaseDropdownMenu/DropdownMenu.ty
import { Inline, Padbox } from '../layout';
import { pxToRem } from '../../utils';
import { ActionKinds } from '../../types/action.types';
import { Button } from '../Button';

const Wrapper = styled(Padbox)`
margin-bottom: ${pxToRem(100)};
Expand Down Expand Up @@ -61,7 +62,9 @@ export default {

export const Default: Story<DropdownMenuProps> = (args) => (
<Inline justify="center">
<DropdownMenu {...args}>Dropdown handler</DropdownMenu>
<DropdownMenu {...args}>
<Button>Handler</Button>
</DropdownMenu>
</Inline>
);
Default.args = {
Expand Down
1 change: 0 additions & 1 deletion src/components/HintTooltip/HintTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const StyledIcon = styled(Icon).withConfig<{ color: Color }>({
border-radius: 100%;
color: ${({ color, theme }) =>
isNotUndefined(color) ? getColor(color, { theme }) : 'inherit'};
&:focus-visible,
&:hover {
color: ${({ theme }) => getColor('neutral.700', { theme })};
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/Pagination/PaginationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const StyledPaginationComponent = styled.button<{
&:last-of-type {
margin-right: 0;
}
&:focus {
outline: none;
}
&:disabled {
color: ${getColor('neutral.600')};
cursor: default;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pill/PillRemoveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const PillRemoveButtonWrapper = styled.button`
border-radius: ${getRadii('circle')};

&:hover,
&:focus {
&:focus-visible {
color: ${getColor('neutral.0')};
background-color: ${getColor('error.500')};
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Pill/PillWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ const StyledPillWrapper = styled(Padbox)<StyledPillWrapperProps>`
$isClickable &&
css`
cursor: pointer;
&:hover,
&:focus {
&:hover {
background-color: ${PillColors[$color][1]};
outline: none;
}
`}
`;
Expand Down
14 changes: 5 additions & 9 deletions src/components/Stepper/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import styled, { css } from 'styled-components';
import { isNotUndefined } from 'ramda-adjunct';

import { getColor, getSpace, pxToRem } from '../../utils';
import { getColor, getRadii, getSpace, pxToRem } from '../../utils';
import { SpaceSizes } from '../../theme';
import { Text } from '../typographyLegacy/Text';
import { TextSizes, TextVariants } from '../typographyLegacy/Text/Text.enums';
Expand All @@ -25,18 +25,14 @@ const StepSummary = styled(Text)`
const StepButton = styled.button`
border: 0 none;
background: transparent none;
border-radius: ${getRadii('default')};
&:hover {
cursor: pointer;
}
&:focus {
outline: 0;
}
&:hover
${/* sc-selector */ BulletCircle},
&:focus
${/* sc-selector */ BulletCircle} {
fill: ${getColor('primary.50')};
fill: ${getColor('primary.50')};
}
}
`;

Expand Down
4 changes: 0 additions & 4 deletions src/components/UserAvatar/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ const invertedAvatar = css`
background-color: ${getColor('primary.50')};
color: ${getColor('neutral.900')};
}
&:focus {
background-color: ${getColor('neutral.0')};
color: ${getColor('neutral.900')};
}
&:active {
background-color: ${getColor('primary.200')};
color: ${getColor('neutral.900')};
Expand Down
39 changes: 5 additions & 34 deletions src/components/_internal/BaseButton/BaseStyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { BaseStyledButtonProps } from './BaseButton.types';
import { BaseButtonVariants } from './BaseButton.enums';
import { Padbox } from '../../layout';
import { ButtonColors } from '../../Button/Button.enums';

/*
* BUTTON VARIANTS
Expand All @@ -28,11 +27,6 @@ const ButtonSolid = css<BaseStyledButtonProps>`
color: ${getToken(`color-action-text-solid`)};
background-color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
}
&:focus-visible,
&.focus {
background-color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
outline: 4px solid ${(p) => getToken(`color-action-${p.$color}-focus`, p)};
}

&:disabled,
&.disabled {
Expand All @@ -53,12 +47,6 @@ const ButtonOutline = css<BaseStyledButtonProps>`
color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
border-color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
}
&:focus-visible,
&.focus {
color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
border-color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
outline: 4px solid ${(p) => getToken(`color-action-${p.$color}-focus`, p)};
}

&:disabled,
&.disabled {
Expand All @@ -67,34 +55,19 @@ const ButtonOutline = css<BaseStyledButtonProps>`
}
`;

const isLinkLike = (color) =>
color === ButtonColors.primary || color === ButtonColors.secondary
? 'link-'
: '';
const ButtonText = css<BaseStyledButtonProps>`
background-color: transparent;
border-color: transparent;
padding-left: 0;
padding-right: 0;
font-weight: ${getFontWeight('semibold')};
color: ${(p) =>
getToken(`color-action-${isLinkLike(p.$color)}${p.$color}`, p)};
color: ${(p) => getToken(`color-action-${p.$color}`, p)};

&:hover,
&.hover {
color: ${(p) =>
getToken(`color-action-${isLinkLike(p.$color)}${p.$color}-hover`, p)};
}
&:focus-visible,
&.focus {
background-color: ${(p) =>
getToken(
`color-action-${isLinkLike(p.$color)}background-${p.$color}-focus`,
p,
)};
color: ${(p) =>
getToken(`color-action-${isLinkLike(p.$color)}${p.$color}-hover`, p)};
outline: none;
color: ${(p) => getToken(`color-action-${p.$color}-hover`, p)};
background: ${(p) =>
getToken(`color-action-background-${p.$color}-focus`, p)};
}

&:disabled,
Expand Down Expand Up @@ -139,9 +112,7 @@ const BaseStyledButton = styled(Padbox).withConfig({
css`
width: ${pipe(getToken('size-action-size'), pxToRem)};
`};
&:focus {
outline: 0;
}

${({ $variant }) => buttonVariants[$variant]};

&,
Expand Down
Loading
Loading