Skip to content

Commit

Permalink
Added horizontal padding to Select field filter dropdown (#2832)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed May 5, 2020
1 parent 5e20df8 commit d7eb260
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/witty-dodos-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@arch-ui/options': patch
'@keystonejs/fields': patch
---

Added horizontal padding to Select field filter dropdown.
3 changes: 2 additions & 1 deletion packages/arch/packages/options/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export const CheckMark = ({ isDisabled, isFocused, isSelected }) => {
);
};

export const OptionPrimitive = ({ children, isDisabled, innerProps, innerRef }) => {
export const OptionPrimitive = ({ children, isDisabled, innerProps, innerRef, className }) => {
return (
<div
ref={innerRef}
className={className}
css={{
alignItems: 'center',
color: isDisabled ? colors.N40 : null,
Expand Down
21 changes: 18 additions & 3 deletions packages/fields/src/types/Select/views/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const SelectFilterView = ({ innerRef, field, value, onChange }) => {

const radioValue = value.inverted ? 'does_not_match' : 'does_match';
const selectProps = {
components: { Option: CheckMarkOption },
innerRef: innerRef,
onChange: handleSelectChange,
options: field.options,
Expand All @@ -51,10 +50,18 @@ const SelectFilterView = ({ innerRef, field, value, onChange }) => {
<SelectWrapper>
{field.options.length > 8 ? (
<EventCatcher>
<Select menuPortalTarget={document.body} {...selectProps} />
<Select
menuPortalTarget={document.body}
{...selectProps}
components={{ Option: CheckMarkOptionSelect }}
/>
</EventCatcher>
) : (
<Options displaySearch={false} {...selectProps} />
<Options
displaySearch={false}
{...selectProps}
components={{ Option: CheckMarkOption }}
/>
)}
</SelectWrapper>
</Fragment>
Expand All @@ -68,4 +75,12 @@ const CheckMarkOption = ({ children, ...props }) => (
</OptionPrimitive>
);

// TODO: figure out a better way to give options padding in the the dropdown
const CheckMarkOptionSelect = props => (
<CheckMarkOption
{...props}
css={{ paddingLeft: `${gridSize}px`, paddingRight: `${gridSize}px` }}
/>
);

export default SelectFilterView;

0 comments on commit d7eb260

Please sign in to comment.