Skip to content
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
98 changes: 98 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions packages/buttons/src/styled/StyledButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,14 @@ const colorStyles = ({

if (isNeutral) {
borderColor = getColor({ theme, variable: 'border.default', ...offset100 });
focusBorderColor = getColor(borderOptions);
hoverBorderColor = getColor(borderOptions);
focusBorderColor = hoverBorderColor;
activeBorderColor = getColor({ ...borderOptions, ...offset100 });
} else {
borderColor = getColor(borderOptions);
hoverBorderColor = getColor({ ...borderOptions, ...offset100 });
activeBorderColor = getColor({ ...borderOptions, ...offset200 });
}

hoverBorderColor = getColor({ ...borderOptions, ...offset100 });
activeBorderColor = getColor({ ...borderOptions, ...offset200 });
}

backgroundVariable = 'background.primaryEmphasis';
Expand Down
1 change: 1 addition & 0 deletions packages/forms/demo/fileUpload.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import README from '../README.md';
...commonArgs
}}
argTypes={{
tabIndex: { control: 'number' },
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed (and has parity with File) to observe focus state.

...commonArgTypes
}}
parameters={{
Expand Down
32 changes: 16 additions & 16 deletions packages/forms/demo/input.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ import README from '../README.md';
placeholder: { control: 'text' },
type: {
control: {
type: 'select',
options: [
'date',
'datetime-local',
'email',
'month',
'number',
'password',
'search',
'tel',
'text',
'time',
'url',
'week'
]
}
type: 'select'
},
options: [
'date',
'datetime-local',
'email',
'month',
'number',
'password',
'search',
'tel',
'text',
'time',
'url',
'week'
]
}
}}
parameters={{
Expand Down
11 changes: 4 additions & 7 deletions packages/forms/src/elements/FileUpload.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { getColorV8, DEFAULT_THEME } from '@zendeskgarden/react-theming';
import { PALETTE } from '@zendeskgarden/react-theming';
import { rgba } from 'polished';
import { render, renderRtl } from 'garden-test-utils';
import { FileUpload } from './FileUpload';
Expand Down Expand Up @@ -34,11 +34,8 @@ describe('FileUpload', () => {
it('renders correct styling when isDragging is active', () => {
const { container } = render(<FileUpload isDragging />);

const activeColor = getColorV8('primaryHue', 800, DEFAULT_THEME);
const activeBackgroundColor = rgba(getColorV8('primaryHue', 600, DEFAULT_THEME) as string, 0.2);

expect(container.firstChild).toHaveStyleRule('color', activeColor);
expect(container.firstChild).toHaveStyleRule('background-color', activeBackgroundColor);
expect(container.firstChild).toHaveStyleRule('border-color', activeColor);
expect(container.firstChild).toHaveStyleRule('color', PALETTE.blue[900]);
expect(container.firstChild).toHaveStyleRule('background-color', rgba(PALETTE.blue[700], 0.16));
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.blue[900]);
});
});
1 change: 1 addition & 0 deletions packages/forms/src/elements/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const Select = React.forwardRef<HTMLSelectElement, ISelectProps>(
<StyledSelectWrapper
isCompact={isCompact}
isBare={isBare}
isDisabled={disabled}
validation={validation}
focusInset={focusInset}
>
Expand Down
10 changes: 9 additions & 1 deletion packages/forms/src/elements/faux-input/components/EndIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ import React from 'react';
import { IFauxInputIconProps } from '../../../types';
import { StyledTextMediaFigure } from '../../../styled';

const EndIconComponent = ({ isDisabled, isRotated, ...props }: IFauxInputIconProps) => (
const EndIconComponent = ({
isDisabled,
isFocused,
isHovered,
isRotated,
...props
}: IFauxInputIconProps) => (
<StyledTextMediaFigure
$position="end"
$isDisabled={isDisabled}
$isFocused={isFocused}
$isHovered={isHovered}
$isRotated={isRotated}
{...props}
/>
Expand Down
10 changes: 9 additions & 1 deletion packages/forms/src/elements/faux-input/components/StartIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ import React from 'react';
import { IFauxInputIconProps } from '../../../types';
import { StyledTextMediaFigure } from '../../../styled';

const StartIconComponent = ({ isDisabled, isRotated, ...props }: IFauxInputIconProps) => (
const StartIconComponent = ({
isDisabled,
isFocused,
isHovered,
isRotated,
...props
}: IFauxInputIconProps) => (
<StyledTextMediaFigure
$position="start"
$isDisabled={isDisabled}
$isFocused={isFocused}
$isHovered={isHovered}
$isRotated={isRotated}
{...props}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/elements/file-list/components/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const FileComponent = forwardRef<HTMLDivElement, IFileProps>(
ref={ref}
>
{validationType && (
<StyledFileIcon $isCompact={isCompact}>
<StyledFileIcon $isCompact={isCompact} $validation={validation}>
{isCompact ? fileIconsCompact[validationType] : fileIconsDefault[validationType]}
</StyledFileIcon>
)}
Expand Down
8 changes: 1 addition & 7 deletions packages/forms/src/elements/tiles/components/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ const TileComponent = React.forwardRef<HTMLLabelElement, ITilesTileProps>(
}

return (
<StyledTile
ref={ref}
aria-disabled={disabled}
isDisabled={disabled}
isSelected={tilesContext && tilesContext.value === value}
{...props}
>
<StyledTile ref={ref} aria-disabled={disabled} {...props}>
{children}
<StyledTileInput
{...inputProps}
Expand Down
34 changes: 25 additions & 9 deletions packages/forms/src/styled/checkbox/StyledCheckInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@
*/

import styled, { css, DefaultTheme, ThemeProps } from 'styled-components';
import { getColorV8, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
import { StyledRadioInput } from '../radio/StyledRadioInput';
import { StyledCheckLabel } from './StyledCheckLabel';

const COMPONENT_ID = 'forms.checkbox';

const colorStyles = (props: ThemeProps<DefaultTheme>) => {
const SHADE = 600;
const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
const backgroundOptions = { theme, variable: 'background.primaryEmphasis' };
const borderOptions = { theme, variable: 'border.primaryEmphasis' };

const indeterminateBorderColor = getColorV8('primaryHue', SHADE, props.theme);
const indeterminateBackgroundColor = indeterminateBorderColor;
const indeterminateActiveBorderColor = getColorV8('primaryHue', SHADE + 100, props.theme);
const indeterminateActiveBackgroundColor = indeterminateActiveBorderColor;
const indeterminateDisabledBackgroundColor = getColorV8('neutralHue', SHADE - 400, props.theme);
const indeterminateBackgroundColor = getColor(backgroundOptions);
const indeterminateBorderColor = getColor(borderOptions);

const offset100 = { dark: { offset: -100 }, light: { offset: 100 } };
const offset200 = { dark: { offset: -200 }, light: { offset: 200 } };

const indeterminateHoverBackgroundColor = getColor({ ...backgroundOptions, ...offset100 });
const indeterminateHoverBorderColor = getColor({ ...borderOptions, ...offset100 });
const indeterminateActiveBackgroundColor = getColor({ ...backgroundOptions, ...offset200 });
const indeterminateActiveBorderColor = getColor({ ...borderOptions, ...offset200 });
const indeterminateDisabledBackgroundColor = getColor({
theme,
variable: 'background.disabled',
transparency: theme.opacity[300]
});

return css`
&:indeterminate ~ ${StyledCheckLabel}::before {
Expand All @@ -28,6 +39,11 @@ const colorStyles = (props: ThemeProps<DefaultTheme>) => {
}

/* stylelint-disable selector-max-specificity */
&:enabled:indeterminate ~ ${StyledCheckLabel}:hover::before {
border-color: ${indeterminateHoverBorderColor};
background-color: ${indeterminateHoverBackgroundColor};
}

&:enabled:indeterminate ~ ${StyledCheckLabel}:active::before {
border-color: ${indeterminateActiveBorderColor};
background-color: ${indeterminateActiveBackgroundColor};
Expand All @@ -51,7 +67,7 @@ export const StyledCheckInput = styled(StyledRadioInput).attrs({
border-radius: ${props => props.theme.borderRadii.md};
}

${props => colorStyles(props)};
${colorStyles};

${props => retrieveComponentStyles(COMPONENT_ID, props)};
`;
Expand Down
6 changes: 3 additions & 3 deletions packages/forms/src/styled/file-list/StyledFile.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { render } from 'garden-test-utils';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
import { PALETTE } from '@zendeskgarden/react-theming';
import { StyledFile } from './StyledFile';

describe('StyledFile', () => {
Expand All @@ -28,13 +28,13 @@ describe('StyledFile', () => {
it('renders expected success styling', () => {
const { container } = render(<StyledFile validation="success" />);

expect(container.firstChild).toHaveStyleRule('border-color', PALETTE_V8.green[600]);
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.green[700]);
});

it('renders expected error styling', () => {
const { container } = render(<StyledFile validation="error" />);

expect(container.firstChild).toHaveStyleRule('border-color', PALETTE_V8.red[600]);
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.red[700]);
});
});
});
Loading