Skip to content

Commit

Permalink
add custom styles functionality, and padding to Pagination select (#5322
Browse files Browse the repository at this point in the history
)

* add custom styles functionality, and padding to Pagination select

* changesets

* use merge styles instead

* add more paddding to the right of value

Co-authored-by: Mitchell Hamilton <[email protected]>
  • Loading branch information
gwyneplaine and emmatown authored Apr 6, 2021
1 parent 1886b43 commit d93bab1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-experts-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/admin-ui': patch
---

Added padding to the select input in the Pagination component in @keystone-next/admin-ui.
5 changes: 5 additions & 0 deletions .changeset/witty-parents-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-ui/fields': minor
---

Added styles prop to @keystone-ui/fields select components to enable style customisations to propagate to the underlying reaect-select implementation.
14 changes: 9 additions & 5 deletions design-system/packages/fields/src/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx jsx */
import { jsx, useTheme } from '@keystone-ui/core';
import ReactSelect, { Props, OptionsType } from 'react-select';
import ReactSelect, { Props, OptionsType, mergeStyles } from 'react-select';
import { useInputTokens } from './hooks/inputs';
import { WidthType } from './types';

Expand Down Expand Up @@ -118,20 +118,22 @@ export function Select({
value,
width: widthKey = 'large',
portalMenu,
styles,
...props
}: BaseSelectProps & {
value: Option | null;
portalMenu?: true;
onChange(value: Option | null): void;
}) {
const tokens = useInputTokens({ width: widthKey });
const styles = useStyles({ tokens });
const defaultStyles = useStyles({ tokens });
const composedStyles = styles ? mergeStyles(defaultStyles, styles) : defaultStyles;

return (
<ReactSelect
value={value}
// css={{ width: tokens.width }}
styles={styles}
styles={composedStyles}
onChange={value => {
if (!value) {
onChange(null);
Expand All @@ -151,19 +153,21 @@ export function MultiSelect({
value,
width: widthKey = 'large',
portalMenu,
styles,
...props
}: BaseSelectProps & {
value: OptionsType<Option>;
portalMenu?: true;
onChange(value: OptionsType<Option>): void;
}) {
const tokens = useInputTokens({ width: widthKey });
const styles = useStyles({ tokens, multi: true });
const defaultStyles = useStyles({ tokens, multi: true });
const composedStyles = styles ? mergeStyles(defaultStyles, styles) : defaultStyles;

return (
<ReactSelect
// css={{ width: tokens.width }}
styles={styles}
styles={composedStyles}
value={value}
onChange={value => {
if (!value) {
Expand Down
7 changes: 7 additions & 0 deletions packages-next/admin-ui/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ export function Pagination({ currentPage, total, pageSize, list }: PaginationPro
width="medium"
value={{ label: String(currentPage), value: String(currentPage) }}
options={pages}
styles={{
valueContainer: provided => ({
...provided,
paddingLeft: '12px',
paddingRight: '16px',
}),
}}
menuPortalTarget={document.body}
onChange={onChange}
/>
Expand Down

1 comment on commit d93bab1

@vercel
Copy link

@vercel vercel bot commented on d93bab1 Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.