-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Plenum component DropdownWithMultiSelect #90
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import React from "react" | ||
import { TablerIconName } from "./tablerIconNames" | ||
import * as TablerIcons from "@tabler/icons-react" | ||
import { ClassNameWithAutocomplete } from "@/utils/types" | ||
import React from "react"; | ||
import { TablerIconName } from "./tablerIconNames"; | ||
import * as TablerIcons from "@tabler/icons-react"; | ||
import { ClassNameWithAutocomplete } from "@/utils/types"; | ||
|
||
export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> { | ||
icon: TablerIconName | ||
className?: ClassNameWithAutocomplete | ||
icon: TablerIconName; | ||
className?: ClassNameWithAutocomplete; | ||
} | ||
|
||
const TablerIcon: React.FC<ITablerIconProps> = ({ | ||
icon, | ||
className = "w-6 h-6 text-gray-600" | ||
}: ITablerIconProps): JSX.Element => { | ||
const Icon = TablerIcons[icon] | ||
//@ts-ignore | ||
const Icon = TablerIcons[icon]; | ||
return ( | ||
<i> | ||
<Icon className={className} /> | ||
</i> | ||
) | ||
} | ||
export default TablerIcon | ||
); | ||
}; | ||
export default TablerIcon; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
import React, { FC } from "react" | ||
import { default as cn } from "classnames" | ||
import InputLabel from "@/stories/molecules/inputs/InputLabel" | ||
import { useId } from "@/utils/useId" | ||
import React, { FC } from "react"; | ||
import { default as cn } from "classnames"; | ||
import InputLabel from "@/stories/molecules/inputs/InputLabel"; | ||
import { useId } from "@/utils/useId"; | ||
|
||
export interface ICheckboxProps { | ||
/** Checkbox label */ | ||
label: string | ||
label: string; | ||
/** Checkbox ID */ | ||
id?: string | ||
id?: string; | ||
/** Disabled state */ | ||
isDisabled?: boolean | ||
isDisabled?: boolean; | ||
/** value */ | ||
value?: string | ||
value?: string; | ||
/** Check state */ | ||
isChecked?: boolean | ||
isChecked?: boolean; | ||
/** If field is required */ | ||
isRequired?: boolean | ||
isRequired?: boolean; | ||
/** Error state */ | ||
isError?: boolean | ||
isError?: boolean; | ||
/** Message or description */ | ||
message?: string | ||
message?: string; | ||
/** Callback on input change */ | ||
onChange?(value: string, isChecked: boolean): void | ||
onChange?(value: string, isChecked: boolean): void; | ||
/** Has a border around the checkbox and label */ | ||
hasBorder?: boolean | ||
hasBorder?: boolean; | ||
/** any arbitrary classNames to add to the wrapper */ | ||
className?: string | ||
/** Label ClassName */ | ||
labelClassName?: string | ||
className?: string; | ||
/** Truncate label */ | ||
truncateLabel?: boolean; | ||
/** Full width label */ | ||
fullWidthLabel?: boolean; | ||
} | ||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just passing these down from the new component to inputlabel |
||
|
||
/** Comment */ | ||
|
@@ -43,29 +45,30 @@ const Checkbox: FC<ICheckboxProps> = ({ | |
onChange, | ||
hasBorder, | ||
className, | ||
labelClassName, | ||
truncateLabel = false, | ||
fullWidthLabel = false, | ||
...props | ||
}: ICheckboxProps) => { | ||
const uniqueID = useId() | ||
if (!id) id = `cb-${uniqueID}` | ||
const uniqueID = useId(); | ||
if (!id) id = `cb-${uniqueID}`; | ||
|
||
const checkboxStyles = cn( | ||
"rounded-sm border-gray-300 text-sm font-normal leading-5 text-purple-600 focus:ring-purple-600", | ||
{ "border-red-500 shadow-none": isError } | ||
) | ||
); | ||
const wrapperStyles = cn( | ||
"relative flex items-center min-h-[38px]", | ||
{ "opacity-50": isDisabled }, | ||
{ "rounded-sm border border-1 px-3 border-gray-200": hasBorder }, | ||
{ "py-3": hasBorder && message }, | ||
className | ||
) | ||
); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const targetValue = e.target.value | ||
const targetChecked = e.target.checked | ||
typeof onChange === "function" && onChange(targetValue, targetChecked) | ||
} | ||
const targetValue = e.target.value; | ||
const targetChecked = e.target.checked; | ||
typeof onChange === "function" && onChange(targetValue, targetChecked); | ||
}; | ||
|
||
return ( | ||
<div className={wrapperStyles}> | ||
|
@@ -80,14 +83,20 @@ const Checkbox: FC<ICheckboxProps> = ({ | |
disabled={isDisabled} | ||
checked={isChecked} | ||
onChange={(e) => { | ||
handleChange(e) | ||
handleChange(e); | ||
}} | ||
{...props} | ||
/> | ||
</div> | ||
<div className="ml-3 text-sm "> | ||
<div className="ml-3 text-sm flex items-center w-full"> | ||
<> | ||
<InputLabel label={label} isRequired={isRequired} id={id} /> | ||
<InputLabel | ||
label={label} | ||
isRequired={isRequired} | ||
id={id} | ||
truncateLabel={truncateLabel} | ||
fullWidthLabel={fullWidthLabel} | ||
/> | ||
</> | ||
|
||
{message && ( | ||
|
@@ -97,6 +106,6 @@ const Checkbox: FC<ICheckboxProps> = ({ | |
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
export default Checkbox | ||
); | ||
}; | ||
export default Checkbox; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bumping these up to match manager app repo