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 custom styles functionality, and padding to Pagination select #5322

Merged
merged 10 commits into from
Apr 6, 2021
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