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

Add feedback prop to Select to get it up to speed with Input #1205

Merged
merged 1 commit into from
Aug 25, 2023
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
9 changes: 8 additions & 1 deletion src/components/input/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import InputRoot from './InputRoot';

type ComponentProps = {
children?: ComponentChildren;
feedback?: 'error' | 'warning';

/**
* @deprecated Use feedback="error" instead
*/
hasError?: boolean;
};
export type SelectProps = PresentationalProps &
Expand All @@ -22,8 +27,9 @@ const arrowImage = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000
const Select = function Select({
children,
classes,
hasError,
type = 'text',
feedback,
hasError,

...htmlAttributes
}: SelectProps) {
Expand All @@ -40,6 +46,7 @@ const Select = function Select({
)}
element="select"
type={type}
feedback={feedback}
hasError={hasError}
style={{
backgroundImage: arrowImage,
Expand Down
43 changes: 37 additions & 6 deletions src/pattern-library/components/patterns/input/SelectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function SelectPage() {
title="Previous student"
variant="dark"
/>
<SelectWrapper aria-label="Example input" />
<SelectWrapper aria-label="Example select" />
<IconButton
icon={ArrowRightIcon}
title="Next student"
Expand All @@ -76,15 +76,15 @@ export default function SelectPage() {
</Library.Demo>
<Library.Demo title="Setting Select width" withSource>
<div className="w-[250px]">
<SelectWrapper aria-label="Example input" />
<SelectWrapper aria-label="Example select" />
</div>
</Library.Demo>
</Library.Example>

<Library.Example title="Disabled Selects">
<Library.Demo title="disabled Select" withSource>
<div className="w-[350px]">
<SelectWrapper aria-label="Example input" disabled />
<SelectWrapper aria-label="Example select" disabled />
</div>
</Library.Demo>
</Library.Example>
Expand All @@ -96,11 +96,42 @@ export default function SelectPage() {
presentational component props
</Library.Link>
.
<Library.Example title="feedback">
<Library.Info>
<Library.InfoItem label="description">
Set <code>feedback</code> to indicate that there is an
associated error or warning for the <code>Select</code>.
</Library.InfoItem>
<Library.InfoItem label="type">
<code>
{`"error"`} | {`"warning"`}
</code>
</Library.InfoItem>
<Library.InfoItem label="default">
<code>{`undefined`}</code>
</Library.InfoItem>
</Library.Info>

<Library.Demo withSource>
<div className="w-[350px]">
<SelectWrapper
aria-label="Select with error"
feedback="error"
/>
</div>
<div className="w-[350px]">
<SelectWrapper
aria-label="Select with warning"
feedback="warning"
/>
</div>
</Library.Demo>
</Library.Example>
<Library.Example title="hasError">
<Library.Info>
<Library.InfoItem label="description">
Set <code>hasError</code> to indicate that there is an
associated error for the <code>Select</code>.
<Library.StatusChip status="deprecated" />
Use <code>{`feedback="error"`}</code> instead.
</Library.InfoItem>
<Library.InfoItem label="type">
<code>{`boolean`}</code>
Expand All @@ -112,7 +143,7 @@ export default function SelectPage() {

<Library.Demo withSource>
<div className="w-[350px]">
<SelectWrapper aria-label="Example input" hasError />
<SelectWrapper aria-label="Example select" hasError />
</div>
</Library.Demo>
</Library.Example>
Expand Down