Skip to content

Commit

Permalink
Select QA (#91)
Browse files Browse the repository at this point in the history
* Select QA

* Add TypeScript types

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
chriszarate and actions-user authored Dec 17, 2020
1 parent 7a4c7aa commit 39fe6c9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 43 deletions.
2 changes: 1 addition & 1 deletion dist/Select/Select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Select(props: {
/**
* A function that will be called when the user's selection changes.
*/
onChange: (event: React.ChangeEvent) => void;
onChange?: (event: React.ChangeEvent) => void;
/**
* The options to display in the dropdown. Each has a label, which will display
* to the user, and a value, which can be different than the label. For
Expand Down
2 changes: 1 addition & 1 deletion dist/Select/Select.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/components/Select/Select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
@include fonts.maison;

display: block;
}

.select-container {
position: relative;
}

.select {
@include resets.select;

color: color-scheme.$typography;
display: inline-block;
height: 45px;
width: 100%;
Expand Down
84 changes: 43 additions & 41 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Select ( props: {
/**
* A function that will be called when the user's selection changes.
*/
onChange: ( event: React.ChangeEvent ) => void,
onChange?: ( event: React.ChangeEvent ) => void,

/**
* The options to display in the dropdown. Each has a label, which will display
Expand Down Expand Up @@ -85,46 +85,48 @@ export default function Select ( props: {
return (
<label className={styles.container}>
<FormLabel required={required}>{props.label}</FormLabel>
<select
aria-invalid={props.invalid}
className={styles.select}
disabled={disabled}
onChange={props.onChange}
ref={props.inputRef}
required={required}
value={props.value}
>
{
props.placeholder &&
<option disabled value="">
{props.placeholder}
</option>
}
{
props.options.map( item => (
<option
key={item.value}
value={item.value}
>
{item.label}
</option>
) )
}
</select>
<svg
aria-hidden="true"
className={cx( 'down-arrow', { invalid: props.invalid } )}
height="6"
width="11"
viewBox="15 20 11 6"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.027 26l.016-.016 1.088-1.062 3.887-3.859L23.932 20l-3.894 3.852L16.104 20l-1.086 1.064 3.964 3.881z"
fill="var(--color, #4C4C4C)"
fillRule="evenodd"
/>
</svg>
<div className={styles.selectContainer}>
<select
aria-invalid={props.invalid}
className={styles.select}
disabled={disabled}
onChange={props.onChange}
ref={props.inputRef}
required={required}
value={props.value}
>
{
props.placeholder &&
<option disabled value="">
{props.placeholder}
</option>
}
{
props.options.map( item => (
<option
key={item.value}
value={item.value}
>
{item.label}
</option>
) )
}
</select>
<svg
aria-hidden="true"
className={cx( 'down-arrow', { invalid: props.invalid } )}
height="6"
width="11"
viewBox="15 20 11 6"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.027 26l.016-.016 1.088-1.062 3.887-3.859L23.932 20l-3.894 3.852L16.104 20l-1.086 1.064 3.964 3.881z"
fill="var(--color, #4C4C4C)"
fillRule="evenodd"
/>
</svg>
</div>
{
props.hint &&
<span className={cx( 'hint', { invalid: props.invalid } )}>
Expand Down

0 comments on commit 39fe6c9

Please sign in to comment.