diff --git a/src/base-field/base-field.module.css b/src/base-field/base-field.module.css index e50898cf..31ae3dba 100644 --- a/src/base-field/base-field.module.css +++ b/src/base-field/base-field.module.css @@ -2,68 +2,29 @@ --reactist-field-label-padding-bottom: 6px; --reactist-field-label-line-height: inherit; } + .container { font-family: var(--reactist-font-family); + display: flex; + flex-direction: column; } .container label { letter-spacing: -0.15px; + padding-bottom: var(--reactist-field-label-padding-bottom); + line-height: var(--reactist-field-label-line-height); } -.container label, .container .auxiliaryLabel { + text-align: right; padding-bottom: var(--reactist-field-label-padding-bottom); line-height: var(--reactist-field-label-line-height); } -.container.bordered { - border-radius: var(--reactist-border-radius-large); - border: 1px solid var(--reactist-inputs-idle); - padding: var(--reactist-spacing-small); - padding-bottom: var(--reactist-spacing-xsmall); - overflow: clip; -} - -.container.bordered label { - /* so that clicking in blank areas to the right of the label will focus the field element */ - flex-grow: 1; - /* to convey that clicking in blank area to the right of the label places focus on the text field */ - cursor: text; -} - -.container.bordered label span { - /* overrides the cursor set above, so that hovering over the non-blank parts of the label stay unaffected */ - cursor: default; -} - -.container.bordered:hover { - border-color: var(--reactist-inputs-hover) !important; -} - -.container.bordered:focus-within { - border-color: var(--reactist-inputs-focus) !important; -} - -.container.bordered.error { - border-color: var(--reactist-inputs-alert) !important; -} - -.container.bordered .primaryLabel { - font-weight: 500; -} - -.container.bordered .auxiliaryLabel { - font-size: var(--reactist-font-size-caption); -} - -.container:not(.bordered) .primaryLabel { +.container .primaryLabel { font-weight: var(--reactist-font-weight-strong); } -.container:not(.bordered) .auxiliaryLabel { - font-size: var(--reactist-font-size-body); -} - .container input, .container textarea, .container select { @@ -75,7 +36,7 @@ } .auxiliaryLabel { - text-align: right; + font-size: var(--reactist-font-size-body); } .loadingIcon { diff --git a/src/base-field/base-field.tsx b/src/base-field/base-field.tsx index 08c253d6..1e270f8e 100644 --- a/src/base-field/base-field.tsx +++ b/src/base-field/base-field.tsx @@ -12,8 +12,6 @@ import styles from './base-field.module.css' import type { BoxProps } from '../box' import type { WithEnhancedClassName } from '../utils/common-types' -// Define the remaining characters before the character count turns red -// See: https://twist.com/a/1585/ch/765851/t/6664583/c/93631846 for latest spec const MAX_LENGTH_THRESHOLD = 0 type FieldTone = 'neutral' | 'success' | 'error' | 'loading' @@ -74,25 +72,16 @@ function validateInputLength({ maxLength, }: ValidateInputLengthProps): ValidateInputLengthResult { if (!maxLength) { - return { - count: null, - tone: 'neutral', - } + return { count: null, tone: 'neutral' } } - const currentLength = String(value || '').length const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD - return { count: `${currentLength}/${maxLength}`, tone: isNearMaxLength ? 'error' : 'neutral', } } -// -// BaseField -// - type ChildrenRenderProps = { id: string value?: React.InputHTMLAttributes['value'] @@ -107,144 +96,29 @@ type HtmlInputProps = React.DetailedHTMLProps< T > -type BaseFieldVariant = 'default' | 'bordered' -type BaseFieldVariantProps = { - /** - * Provides alternative visual layouts or modes that the field can be rendered in. - * - * Namely, there are two variants supported: - * - * - the default one - * - a "bordered" variant, where the border of the field surrounds also the labels, instead - * of just surrounding the actual field element - * - * In both cases, the message and description texts for the field lie outside the bordered - * area. - */ - variant?: BaseFieldVariant -} - export type BaseFieldProps = WithEnhancedClassName & Pick, 'id' | 'hidden' | 'maxLength' | 'aria-describedby'> & { - /** - * The main label for this field element. - * - * This prop is not optional. Consumers of field components must be explicit about not - * wanting a label by passing `label=""` or `label={null}`. In those situations, consumers - * should make sure that fields are properly labelled semantically by other means (e.g using - * `aria-labelledby`, or rendering a `