Skip to content

Commit

Permalink
Merge pull request #97 from alleslabs/styles/text-input
Browse files Browse the repository at this point in the history
style: change input floating label to always afloat
  • Loading branch information
poomthiti authored Jan 18, 2023
2 parents cf4ce89 + 57c419d commit 0673f39
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#97](https://github.com/alleslabs/celatone-frontend/pull/97) Change label style to always afloat
- [#96](https://github.com/alleslabs/celatone-frontend/pull/96) Fix incorrect instantiated block height explorer link
- [#95](https://github.com/alleslabs/celatone-frontend/pull/95) Add network to url path
- [#89](https://github.com/alleslabs/celatone-frontend/pull/89) Update feedback link
Expand Down
13 changes: 2 additions & 11 deletions src/lib/components/forms/ControllerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,9 @@ export const ControllerInput = <T extends FieldValues>({

const isError = !!error;
return (
<FormControl
className={`${size}-form`}
size={size}
isInvalid={isError}
{...componentProps}
{...field}
>
<FormControl size={size} isInvalid={isError} {...componentProps} {...field}>
{label && (
<FormLabel
className={field.value.length ? "floating" : ""}
bgColor={labelBgColor}
>
<FormLabel className={`${size}-label`} bgColor={labelBgColor}>
{label}
</FormLabel>
)}
Expand Down
13 changes: 2 additions & 11 deletions src/lib/components/forms/ControllerTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,9 @@ export const ControllerTextarea = <T extends FieldValues>({
const isError = !!error;

return (
<FormControl
className="textarea-form"
size="md"
isInvalid={isError}
{...componentProps}
{...field}
>
<FormControl size="md" isInvalid={isError} {...componentProps} {...field}>
{label && (
<FormLabel
bgColor={labelBgColor}
className={field.value.length ? "floating" : ""}
>
<FormLabel className="textarea-label" bgColor={labelBgColor}>
{label}
</FormLabel>
)}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/forms/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ export const NumberInput = ({
// Design system size: md = 40px, lg = 56px
return (
<FormControl
className={`${size}-form`}
isInvalid={!!error || status?.state === "error"}
size={size}
{...componentProps}
>
<FormLabel
className={value.length ? "floating" : ""}
backgroundColor={labelBgColor}
>
<FormLabel className={`${size}-label`} backgroundColor={labelBgColor}>
{label}
</FormLabel>

Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/forms/TextAreaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ export const TextAreaInput = ({
}: TextAreaProps) => {
return (
<FormControl
className="textarea-form"
isInvalid={!!error || status?.state === "error"}
size="md"
{...componentProps}
>
{label && (
<FormLabel
bgColor={labelBgColor}
className={value.length ? "floating" : ""}
>
<FormLabel className="textarea-label" bgColor={labelBgColor}>
{label}
</FormLabel>
)}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/forms/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@ export const TextInput = ({
// Design system size: md = 40px, lg = 56px
return (
<FormControl
className={`${size}-form`}
isInvalid={!!error || status?.state === "error"}
size={size}
{...componentProps}
>
{label && (
<FormLabel
className={value.length ? "floating" : ""}
backgroundColor={labelBgColor}
>
<FormLabel className={`${size}-label`} backgroundColor={labelBgColor}>
{label}
</FormLabel>
)}
Expand Down
35 changes: 7 additions & 28 deletions src/lib/styles/theme/components/form.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
import type { ComponentStyleConfig } from "@chakra-ui/react";

const activeLabelStyles = {
"&.md-form, &.textarea-form": {
_focusWithin: {
label: {
transform: "scale(0.75) translateY(-20px)",
lineHeight: "1.2",
},
},
"& .floating": {
transform: "scale(0.75) translateY(-20px)",
lineHeight: "1.2",
},
},
"&.lg-form": {
_focusWithin: {
label: {
lineHeight: "1.2",
transform: "scale(0.75) translateY(-28px)",
},
},
"& .floating": {
transform: "scale(0.75) translateY(-28px)",
lineHeight: "1.2",
},
},
};

export const Form: ComponentStyleConfig = {
baseStyle: {
container: {
Expand All @@ -38,7 +11,6 @@ export const Form: ComponentStyleConfig = {
variants: {
floating: {
container: {
...activeLabelStyles,
label: {
top: 0,
left: 0,
Expand All @@ -47,6 +19,7 @@ export const Form: ComponentStyleConfig = {
px: 1,
position: "absolute",
fontWeight: "400",
lineHeight: "1.2",
pointerEvents: "none",
transformOrigin: "left top",
color: "text.dark",
Expand All @@ -56,6 +29,12 @@ export const Form: ComponentStyleConfig = {
_active: {
color: "primary.main",
},
"&.md-label, &.textarea-label": {
transform: "scale(0.75) translateY(-20px)",
},
"&.lg-label": {
transform: "scale(0.75) translateY(-28px)",
},
},
"div.helper-text, .error-text": {
ml: 3,
Expand Down

1 comment on commit 0673f39

@vercel
Copy link

@vercel vercel bot commented on 0673f39 Jan 18, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.