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

Document and export the inputOutline style mixin #1037

Merged
merged 4 commits into from
Jul 14, 2021
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
5 changes: 5 additions & 0 deletions .changeset/cold-beds-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': minor
---

Added the `inputOutline` style mixin. It can be used to communicate to the user that an element is hovered, focused, or active in the disabled, invalid, and warning states.
1 change: 1 addition & 0 deletions packages/circuit-ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export {
clearfix,
hideScrollbar,
shadow,
inputOutline,
} from './styles/style-mixins';

export { sharedPropTypes, styleHelpers };
Expand Down
19 changes: 19 additions & 0 deletions packages/circuit-ui/styles/style-mixins.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ function focusOutline('inset'): (theme: Theme | { theme: Theme }) => SerializedS

<Story id="features-style-mixins--focus-outline" />

## `inputOutline`

Visually communicates to the user that an element is hovered, focused, or active in the disabled, invalid, and warning states.

```ts
function inputOutline(
theme:
| Theme
| {
theme: Theme;
disabled?: boolean;
invalid?: boolean;
hasWarning?: boolean;
},
): SerializedStyles;
```

<Story id="features-style-mixins--input-outline" />

## `disableVisually`

Visually communicates to the user that an element is disabled and prevents user interactions.
Expand Down
12 changes: 12 additions & 0 deletions packages/circuit-ui/styles/style-mixins.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,18 @@ describe('Style helpers', () => {
`);
});

it('should match the snapshot when disabled', () => {
const { styles } = inputOutline({
theme: light,
disabled: true,
});
expect(styles).toMatchInlineSnapshot(`
"
box-shadow: 0 0 0 1px #999;
"
`);
});

it('should match the snapshot when invalid', () => {
const { styles } = inputOutline({
theme: light,
Expand Down
11 changes: 11 additions & 0 deletions packages/circuit-ui/styles/style-mixins.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import styled from '@emotion/styled';
import { Theme } from '@sumup/design-tokens';

import { Stack } from '../../../.storybook/components';
import Button from '../components/Button';
Expand All @@ -26,6 +27,7 @@ import {
spacing,
shadow,
focusOutline,
inputOutline,
disableVisually,
clearfix,
hideVisually,
Expand Down Expand Up @@ -141,6 +143,15 @@ export const FocusOutline = () => (
</Stack>
);

export const InputOutline = () => (
<Stack>
<Box css={inputOutline} />
<Box css={(theme: Theme) => inputOutline({ theme, disabled: true })} />
<Box css={(theme: Theme) => inputOutline({ theme, invalid: true })} />
<Box css={(theme: Theme) => inputOutline({ theme, hasWarning: true })} />
</Stack>
);

export const DisableVisually = () => (
<div css={disableVisually}>This element is visually disabled.</div>
);
Expand Down
8 changes: 5 additions & 3 deletions packages/circuit-ui/styles/style-mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ export const hideVisually = (): SerializedStyles => css`
/**
* Visually communicates to the user that an element is focused.
*/

export function focusOutline(
options: 'inset',
): (args: ThemeArgs) => SerializedStyles;
Expand Down Expand Up @@ -334,8 +333,8 @@ export const hideScrollbar = (): SerializedStyles => css`
`;

/**
* Visually communicates to the user that an input is hovered, focused,
* or active.
* Visually communicates to the user that an element is hovered, focused, or
* active in the disabled, invalid, and warning states.
*/
export const inputOutline = (
args:
Expand All @@ -345,6 +344,9 @@ export const inputOutline = (
disabled?: boolean;
invalid?: boolean;
hasWarning?: boolean;
/**
* @deprecated
*/
showValid?: boolean;
},
): SerializedStyles => {
Expand Down