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

[system] Improve breakpoints types #20753

Merged
merged 3 commits into from
Apr 27, 2020
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
2 changes: 1 addition & 1 deletion packages/material-ui-system/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
*/
export function breakpoints<Props, Breakpoints extends string = DefaultBreakPoints>(
styleFunction: StyleFunction<Props>
): StyleFunction<Partial<Record<Breakpoints, Props>>>;
): StyleFunction<Partial<Record<Breakpoints, Props>> & Props>;

// compose.js
/**
Expand Down
20 changes: 19 additions & 1 deletion packages/material-ui-system/src/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { compose, css, palette, StyleFunction, spacing, style } from '@material-ui/system';
import {
compose,
css,
palette,
StyleFunction,
spacing,
style,
breakpoints,
} from '@material-ui/system';
import * as React from 'react';
import styled from 'styled-components';

Expand Down Expand Up @@ -66,3 +74,13 @@ function interopTest() {
`;
<SystemSpacingBox m={2} />;
}

function breakpointsTest() {
function styleFunction(props: { color?: string }) {
return {};
}

const styler = breakpoints(styleFunction);
// Allows styleFunction props
styler({ color: 'red' });
}