-
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.
- Loading branch information
Showing
39 changed files
with
869 additions
and
198 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"@babylonlabs-io/bbn-core-ui": minor | ||
--- | ||
|
||
add form control component | ||
add Form widget |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ node_modules | |
dist | ||
dist-ssr | ||
*.local | ||
storybook-static | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.bbn-form-control { | ||
@apply flex flex-col; | ||
|
||
&-title { | ||
@apply mb-2 flex items-center text-sm text-primary-light; | ||
} | ||
|
||
&-hint { | ||
@apply mt-1 text-sm; | ||
|
||
&.bbn-form-control-hint-error { | ||
@apply text-error-main; | ||
} | ||
|
||
&.bbn-form-control-hint-warning { | ||
@apply text-warning-main; | ||
} | ||
|
||
&.bbn-form-control-hint-success { | ||
@apply text-success-main; | ||
} | ||
} | ||
} |
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,38 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { FormControl } from "./FormControl"; | ||
import { Input } from "./Input"; | ||
|
||
const meta: Meta<typeof FormControl> = { | ||
component: FormControl, | ||
tags: ["autodocs"], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof FormControl>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
label: "Label", | ||
children: <Input defaultValue="Hello" />, | ||
hint: "Some random hint", | ||
}, | ||
}; | ||
|
||
export const WithoutLabel: Story = { | ||
args: { | ||
children: <Input defaultValue="Hello Error" state="error" />, | ||
hint: "Some random error", | ||
state: "error", | ||
}, | ||
}; | ||
|
||
export const WithError: Story = { | ||
args: { | ||
label: "Label", | ||
children: <Input defaultValue="Hello Error" state="error" />, | ||
hint: "Some random error", | ||
state: "error", | ||
}, | ||
}; |
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,27 @@ | ||
import { type PropsWithChildren } from "react"; | ||
import { twJoin } from "tailwind-merge"; | ||
import "./FormControl.css"; | ||
|
||
export interface FormControlProps extends PropsWithChildren { | ||
label?: string | JSX.Element; | ||
hint?: string | JSX.Element; | ||
state?: "default" | "error" | "warning" | "success"; | ||
className?: string; | ||
} | ||
|
||
export function FormControl({ children, label, hint, state = "default", className }: FormControlProps) { | ||
return ( | ||
<div className={twJoin("bbn-form-control", className)}> | ||
{label ? ( | ||
<label className="bbn-form-control-label"> | ||
<div className="bbn-form-control-title">{label}</div> | ||
{children} | ||
</label> | ||
) : ( | ||
children | ||
)} | ||
|
||
{hint && <div className={twJoin("bbn-form-control-hint", `bbn-form-control-hint-${state}`)}>{hint}</div>} | ||
</div> | ||
); | ||
} |
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
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
Oops, something went wrong.