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

Tweak design of form fields #2101

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ exports[`CurrencyInput Styles should render a currency as a prefix 1`] = `

.circuit-2 {
display: inline-block;
margin-right: 4px;
margin-bottom: 4px;
margin-left: 4px;
font-weight: 700;
}

[disabled] .circuit-2,
Expand Down Expand Up @@ -55,7 +58,7 @@ exports[`CurrencyInput Styles should render a currency as a prefix 1`] = `
background-color: var(--cui-bg-normal);
border: none;
outline: 0;
border-radius: 8px;
border-radius: 12px;
padding: 12px 16px;
-webkit-transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
Expand Down Expand Up @@ -161,7 +164,10 @@ exports[`CurrencyInput Styles should render a currency as a suffix 1`] = `

.circuit-2 {
display: inline-block;
margin-right: 4px;
margin-bottom: 4px;
margin-left: 4px;
font-weight: 700;
}

[disabled] .circuit-2,
Expand All @@ -180,7 +186,7 @@ exports[`CurrencyInput Styles should render a currency as a suffix 1`] = `
background-color: var(--cui-bg-normal);
border: none;
outline: 0;
border-radius: 8px;
border-radius: 12px;
padding: 12px 16px;
-webkit-transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
Expand Down Expand Up @@ -312,7 +318,10 @@ exports[`CurrencyInput Styles should render with default styles and format 1`] =

.circuit-2 {
display: inline-block;
margin-right: 4px;
margin-bottom: 4px;
margin-left: 4px;
font-weight: 700;
}

[disabled] .circuit-2,
Expand Down Expand Up @@ -353,7 +362,7 @@ exports[`CurrencyInput Styles should render with default styles and format 1`] =
background-color: var(--cui-bg-normal);
border: none;
outline: 0;
border-radius: 8px;
border-radius: 12px;
padding: 12px 16px;
-webkit-transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
transition: box-shadow 120ms ease-in-out,padding 120ms ease-in-out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export interface FieldLabelTextProps extends HTMLAttributes<HTMLSpanElement> {

const baseStyles = ({ theme }: StyleProps) => css`
display: inline-block;
margin-right: ${theme.spacings.bit};
margin-bottom: ${theme.spacings.bit};
margin-left: ${theme.spacings.bit};
font-weight: ${theme.fontWeight.bold};

[disabled] &,
.${CLASS_DISABLED} & {
Expand All @@ -58,15 +61,19 @@ const hiddenStyles = ({ hideLabel }: Pick<FieldLabelTextProps, 'hideLabel'>) =>

const Text = styled('span')(baseStyles, hiddenStyles);

const Optional = styled('span')`
const optionalStyles = ({ theme }: StyleProps) => css`
color: var(--cui-fg-subtle);
font-weight: ${theme.fontWeight.regular};
font-style: italic;

[disabled] &,
.${CLASS_DISABLED} & {
color: var(--cui-fg-subtle-disabled);
}
`;

const Optional = styled('span')(optionalStyles);

/**
* @private
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { HTMLAttributes } from 'react';
import { css } from '@emotion/react';
import { Confirm, Notify, Alert } from '@sumup/icons';
import { Confirm, Notify } from '@sumup/icons';

import styled, { StyleProps } from '../../styles/styled';
import { typography } from '../../styles/style-mixins';
Expand All @@ -34,6 +34,8 @@ export interface FieldValidationHintProps
const wrapperStyles = ({ theme }: StyleProps) => css`
display: block;
margin-top: ${theme.spacings.bit};
margin-right: ${theme.spacings.bit};
margin-left: ${theme.spacings.bit};
color: var(--cui-fg-subtle);
transition: color ${theme.transitions.default};

Expand All @@ -43,32 +45,44 @@ const wrapperStyles = ({ theme }: StyleProps) => css`
}
`;

const validStyles = ({ showValid }: FieldValidationHintProps) =>
const validStyles = ({
theme,
showValid,
}: StyleProps & FieldValidationHintProps) =>
showValid &&
css`
color: var(--cui-fg-success);
font-weight: ${theme.fontWeight.bold};

[disabled] &,
.${CLASS_DISABLED} & {
color: var(--cui-fg-success-disabled);
}
`;

const warningStyles = ({ hasWarning }: FieldValidationHintProps) =>
const warningStyles = ({
theme,
hasWarning,
}: StyleProps & FieldValidationHintProps) =>
hasWarning &&
css`
color: var(--cui-fg-warning);
font-weight: ${theme.fontWeight.bold};

[disabled] &,
.${CLASS_DISABLED} & {
color: var(--cui-fg-warning-disabled);
}
`;

const invalidStyles = ({ invalid }: FieldValidationHintProps) =>
const invalidStyles = ({
theme,
invalid,
}: StyleProps & FieldValidationHintProps) =>
invalid &&
css`
color: var(--cui-fg-danger);
font-weight: ${theme.fontWeight.bold};

[disabled] &,
.${CLASS_DISABLED} & {
Expand Down Expand Up @@ -109,7 +123,7 @@ const getIcon = (props: FieldValidationHintProps) => {
case props.invalid: {
return (
<IconWrapper>
<Alert role="presentation" size="16" />
<Notify role="presentation" size="16" />
</IconWrapper>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1985,10 +1985,13 @@ exports[`ImageInput Styles should render with invalid styles and an error messag
line-height: 1.25rem;
display: block;
margin-top: 4px;
margin-right: 4px;
margin-left: 4px;
color: var(--cui-fg-subtle);
-webkit-transition: color 120ms ease-in-out;
transition: color 120ms ease-in-out;
color: var(--cui-fg-danger);
font-weight: 700;
}

[disabled] .circuit-13,
Expand Down Expand Up @@ -2119,8 +2122,10 @@ exports[`ImageInput Styles should render with invalid styles and an error messag
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z"
clip-rule="evenodd"
d="M10.534 1.5c-1.126-2-3.942-2-5.069 0l-5.069 9C-.73 12.5.678 15 2.931 15h10.138c2.253 0 3.661-2.5 2.534-4.5l-5.069-9zm-3.229 8.687a1.25 1.25 0 1 1 1.39 2.08 1.25 1.25 0 0 1-1.39-2.08zM7.293 4.27A1 1 0 0 1 9 4.977v3a1 1 0 0 1-2 0v-3a1 1 0 0 1 .293-.708z"
fill="currentColor"
fill-rule="evenodd"
/>
</svg>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const inputBaseStyles = ({ theme }: StyleProps) => css`
background-color: var(--cui-bg-normal);
border: none;
outline: 0;
border-radius: ${theme.borderRadius.byte};
border-radius: ${theme.borderRadius.kilo};
padding: ${theme.spacings.kilo} ${theme.spacings.mega};
transition: box-shadow ${theme.transitions.default},
padding ${theme.transitions.default};
Expand Down
Loading