Skip to content
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

Lubega / Fix dropdown UI discrepancies #222

Merged
merged 6 commits into from
Jul 1, 2024
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
1 change: 1 addition & 0 deletions src/components/Dropdown/Dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
box-shadow: 0 32px 64px 0 rgba(14, 14, 14, 0.14);
overflow-y: auto;
width: 328px;
margin-top: 8px;

&--full {
width: 100%;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Dropdown = ({
},
onIsOpenChange({ isOpen }) {
if (!isOpen && !emptyResultMessage) {
clearFilter();
clearFilter();
}
},
onSelectedItemChange({ selectedItem }) {
Expand Down Expand Up @@ -160,8 +160,8 @@ export const Dropdown = ({
<Input
disabled={disabled}
label={reactNodeToString(label)}
leftPlaceholder={icon || undefined}
message={errorMessage}
leftPlaceholder={icon}
message={isOpen ? " " : errorMessage}
name={name}
onClickCapture={handleInputClick}
onKeyUp={() => setShouldFilterList(true)}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Input/Input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ $input-placement: 16px;
}
}

&__left-content {
margin-right: 8px;
}

&__right-content {
margin-left: $input-placement;
}
Expand Down
16 changes: 10 additions & 6 deletions src/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const Input = forwardRef(
hideMessage,
id,
isFullWidth = false,
islabelAnimationDisabled=false,
islabelAnimationDisabled = false,
label,
leftPlaceholder,
message,
Expand Down Expand Up @@ -126,7 +126,11 @@ export const Input = forwardRef(
)}
<input
placeholder={label}
className={islabelAnimationDisabled? "deriv-input--label-animation-disabled" : "deriv-input__field" }
className={
islabelAnimationDisabled
? "deriv-input--label-animation-disabled"
: "deriv-input__field"
lubega-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
id={id}
disabled={disabled}
ref={ref}
Expand All @@ -150,16 +154,16 @@ export const Input = forwardRef(
</div>
)}
</div>
{!hideMessage && message && (
<div className="deriv-input__helper-message">
{!hideMessage && message && (
<div className="deriv-input__helper-message">
<HelperMessage
message={message}
variant={variant}
error={error}
disabled={disabled}
/>
</div>
)}
</div>
)}
</div>
);
},
Expand Down
9 changes: 5 additions & 4 deletions stories/Dropdown.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dropdown } from "../src/components/Dropdown";
const meta = {
title: "Components/Dropdown",
component: Dropdown,
tags: ["autodocs"],
args: {
disabled: false,
dropdownIcon: "",
Expand All @@ -23,6 +24,7 @@ const meta = {
onSelect: (value: string) => console.log(`Selected value: ${value}`),
value: "option1",
variant: "comboBox",
islabelAnimationDisabled: false,
},
} satisfies Meta<typeof Dropdown>;

Expand Down Expand Up @@ -63,7 +65,6 @@ export const PromptNoResults: Story = {
{ text: "Option C", value: "optionC" },
],
label: "Choose an option",
emptyResultMessage: "No search results"
}

}
emptyResultMessage: "No search results",
},
};