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
15 changes: 13 additions & 2 deletions src/design-system/form-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
-webkit-box-shadow: var(--input-shadow);
transition: background-color 5000s ease-in-out 0s;
}
&::placeholder {
color: token('color-text-formcontrol_placeholder');
font-size: token('font-size-formcontrol_placeholder');
font-weight: token('font-weight-formcontrol_placeholder');
}
}

&:has(.dcx-form-input__suffix) {
Expand Down Expand Up @@ -313,7 +318,10 @@
*/

.dcx-form-input--filled.dcx-floating-label,
.dcx-floating-label:has(input:focus) {
.dcx-floating-label:has(input:focus),
.dcx-floating-label.dcx-form-input--placeholder:has(
input:not(:placeholder-shown)
) {
& input {
color: token('color-text-formcontrol-floating');
}
Expand Down Expand Up @@ -393,7 +401,10 @@
}

.dcx-form-input--filled.dcx-floating-label-filled,
.dcx-floating-label.dcx-floating-label-filled:has(input:focus) {
.dcx-floating-label.dcx-floating-label-filled:has(input:focus),
.dcx-floating-label.dcx-form-input--placeholder.dcx-floating-label-filled:has(
input:not(:placeholder-shown)
) {
& label {
top: 0;
margin-left: calc(token('spacing-x-formcontrol-floating') / 2);
Expand Down
3 changes: 3 additions & 0 deletions src/design-system/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"color-text-formcontrol_label": "#000",
"color-text-formcontrol_label-error": "#f44336",
"color-text-formcontrol_label-floating": "#000",
"color-text-formcontrol_placeholder": "#666",
"color-text-heading-level_1": "#000",
"color-text-heading-level_2": "#000",
"color-text-heading-level_3": "#000",
Expand Down Expand Up @@ -128,11 +129,13 @@
"font-size-body": "16px",
"font-size-formcontrol_label": "16px",
"font-size-formcontrol_label-floating": "16px",
"font-size-formcontrol_placeholder": "16px",
"font-size-highlight_body": "12px",
"font-size-paragraph": "12px",
"font-size-pre_body": "16px",
"font-weight-body": "normal",
"font-weight-formcontrol_label": "normal",
"font-weight-formcontrol_placeholder": "normal",
"font-weight-highlight_body": "normal",
"font-weight-paragraph": "bold",
"font-weight-pre_body": "normal",
Expand Down
9 changes: 6 additions & 3 deletions src/formInput/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ type FormInputProps = {
/**
* allow to customise the input with all the properites needed
**/
inputDivProps?: React.AllHTMLAttributes<HTMLDivElement>;
inputDivProps?: React.HTMLAttributes<HTMLDivElement>;
/**
/**
* allow to customise the input with all the properites needed
**/
inputProps?: React.AllHTMLAttributes<HTMLInputElement>;
inputProps?: React.HTMLAttributes<HTMLInputElement> & {
ref?: React.RefObject<HTMLInputElement>;
};
/**
* allow to customise the label with all the properites needed
*/
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement>;
labelProps?: React.HTMLAttributes<HTMLLabelElement>;
/**
* generic parameter to pass whatever element before the input
**/
Expand Down Expand Up @@ -256,6 +258,7 @@ export const FormInput = ({
containerClassName,
{
'dcx-form-input--filled': !!value,
'dcx-form-input--placeholder': !!inputProps?.placeholder,
'dcx-error-bottom': errorPosition === ErrorPosition.BOTTOM,
'dcx-hint-bottom': hint && hint.position !== 'above',
'dcx-floating-label': floatVariants.includes(variant),
Expand Down