forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrate TextArea component to SCSS and add Storybook * Move Input styles to SCSS, add Storybook * Fix Input stylelint issues * Fix hover selector on Input container to avoid hovering on focus * Fix Input focus test by using style file * Add missing & to Textarea style * Fix styleint inssue in Input * Move input testid before props
- Loading branch information
Showing
7 changed files
with
215 additions
and
119 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
airbyte-webapp/src/components/base/Input/Input.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@use "../../../scss/colors"; | ||
|
||
.container { | ||
width: 100%; | ||
position: relative; | ||
background-color: colors.$grey-50; | ||
border: 1px solid colors.$grey-50; | ||
border-radius: 4px; | ||
|
||
&.light { | ||
background-color: colors.$white; | ||
} | ||
|
||
&.error { | ||
background-color: colors.$grey-100; | ||
border-color: colors.$red; | ||
} | ||
|
||
&:not(.disabled, .focused):hover { | ||
background-color: colors.$grey-100; | ||
border-color: colors.$grey-100; | ||
|
||
&.light { | ||
background-color: colors.$white; | ||
} | ||
|
||
&.error { | ||
border-color: colors.$red; | ||
} | ||
} | ||
|
||
&.focused { | ||
background-color: colors.$primaryColor12; | ||
border-color: colors.$blue; | ||
|
||
&.light { | ||
background-color: colors.$white; | ||
} | ||
} | ||
} | ||
|
||
.input { | ||
outline: none; | ||
width: 100%; | ||
padding: 7px 8px; | ||
font-size: 14px; | ||
line-height: 20px; | ||
font-weight: normal; | ||
border: none; | ||
background: none; | ||
color: colors.$dark-blue; | ||
caret-color: colors.$blue; | ||
|
||
&:not(.disabled).password { | ||
width: calc(100% - 22px); | ||
} | ||
|
||
&::placeholder { | ||
color: colors.$grey-300; | ||
} | ||
|
||
&.disabled { | ||
pointer-events: none; | ||
color: colors.$grey-400; | ||
} | ||
} | ||
|
||
button.visibilityButton { | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
display: flex; | ||
height: 100%; | ||
width: 30px; | ||
align-items: center; | ||
justify-content: center; | ||
border: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
airbyte-webapp/src/components/base/Input/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
|
||
import Input from "./Input"; | ||
|
||
export default { | ||
title: "Ui/Input", | ||
component: Input, | ||
argTypes: { | ||
disabled: { control: "boolean" }, | ||
type: { control: { type: "select", options: ["text", "number", "password"] } }, | ||
}, | ||
} as ComponentMeta<typeof Input>; | ||
|
||
const Template: ComponentStory<typeof Input> = (args) => <Input {...args} />; | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
placeholder: "Enter text here...", | ||
}; |
52 changes: 52 additions & 0 deletions
52
airbyte-webapp/src/components/base/TextArea/TextArea.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@use "../../../scss/colors"; | ||
@use "../../../scss/variables"; | ||
|
||
.textarea { | ||
outline: none; | ||
resize: none; | ||
width: 100%; | ||
padding: 7px 8px; | ||
border-radius: 4px; | ||
font-size: 14px; | ||
line-height: 20px; | ||
font-weight: normal; | ||
border: 1px solid colors.$grey-50; | ||
background-color: colors.$grey-50; | ||
color: colors.$dark-blue; | ||
caret-color: colors.$blue; | ||
|
||
&.error { | ||
border-color: colors.$red; | ||
} | ||
|
||
&::placeholder { | ||
color: colors.$grey-300; | ||
} | ||
|
||
&:hover { | ||
background-color: colors.$grey-100; | ||
border-color: colors.$grey-100; | ||
|
||
&.light { | ||
background-color: colors.$white; | ||
} | ||
|
||
&.error { | ||
border-color: colors.$red; | ||
} | ||
} | ||
|
||
&:focus { | ||
background-color: colors.$primaryColor12; | ||
border-color: colors.$blue; | ||
|
||
&.light { | ||
background-color: colors.$white; | ||
} | ||
} | ||
|
||
&:disabled { | ||
pointer-events: none; | ||
color: colors.$grey-400; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,25 @@ | ||
import classNames from "classnames"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
type TextAreaProps = { | ||
import styles from "./TextArea.module.scss"; | ||
|
||
interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { | ||
error?: boolean; | ||
light?: boolean; | ||
} & React.TextareaHTMLAttributes<HTMLTextAreaElement>; | ||
|
||
const TextArea = styled.textarea<TextAreaProps>` | ||
outline: none; | ||
resize: none; | ||
width: 100%; | ||
padding: 7px 8px; | ||
border-radius: 4px; | ||
font-size: 14px; | ||
line-height: 20px; | ||
font-weight: normal; | ||
border: 1px solid ${(props) => (props.error ? props.theme.dangerColor : props.theme.greyColor0)}; | ||
background: ${({ theme }) => theme.greyColor0}; | ||
color: ${({ theme }) => theme.textColor}; | ||
caret-color: ${({ theme }) => theme.primaryColor}; | ||
&::placeholder { | ||
color: ${({ theme }) => theme.greyColor40}; | ||
} | ||
&:hover { | ||
background: ${({ theme, light }) => (light ? theme.whiteColor : theme.greyColor20)}; | ||
border-color: ${(props) => (props.error ? props.theme.dangerColor : props.theme.greyColor20)}; | ||
} | ||
&:focus { | ||
background: ${({ theme, light }) => (light ? theme.whiteColor : theme.primaryColor12)}; | ||
border-color: ${({ theme }) => theme.primaryColor}; | ||
} | ||
&:disabled { | ||
pointer-events: none; | ||
color: ${({ theme }) => theme.greyColor55}; | ||
} | ||
`; | ||
} | ||
|
||
export { TextArea }; | ||
export type { TextAreaProps }; | ||
export const TextArea: React.FC<TextAreaProps> = ({ error, light, children, className, ...textAreaProps }) => ( | ||
<textarea | ||
{...textAreaProps} | ||
className={classNames( | ||
styles.textarea, | ||
{ | ||
[styles.error]: error, | ||
[styles.light]: light, | ||
}, | ||
className | ||
)} | ||
> | ||
{children} | ||
</textarea> | ||
); |
Oops, something went wrong.