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

fix: Grid initial gutter #20762

Merged
merged 1 commit into from Jan 8, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/_util/responsiveObserve.ts
@@ -1,5 +1,6 @@
export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
export type BreakpointMap = Partial<Record<Breakpoint, string>>;
export type ScreenMap = Partial<Record<Breakpoint, boolean>>;

export const responsiveArray: Breakpoint[] = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];

Expand All @@ -12,7 +13,7 @@ export const responsiveMap: BreakpointMap = {
xxl: '(min-width: 1600px)',
};

type SubscribeFunc = (screens: BreakpointMap) => void;
type SubscribeFunc = (screens: ScreenMap) => void;

let subscribers: Array<{
token: string;
Expand All @@ -23,7 +24,7 @@ let screens = {};

const responsiveObserve = {
matchHandlers: {},
dispatch(pointMap: BreakpointMap) {
dispatch(pointMap: ScreenMap) {
screens = pointMap;
if (subscribers.length < 1) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions components/descriptions/index.tsx
Expand Up @@ -4,7 +4,7 @@ import toArray from 'rc-util/lib/Children/toArray';
import warning from '../_util/warning';
import ResponsiveObserve, {
Breakpoint,
BreakpointMap,
ScreenMap,
responsiveArray,
} from '../_util/responsiveObserve';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
Expand Down Expand Up @@ -168,7 +168,7 @@ const defaultColumnMap = {
class Descriptions extends React.Component<
DescriptionsProps,
{
screens: BreakpointMap;
screens: ScreenMap;
}
> {
static defaultProps: DescriptionsProps = {
Expand All @@ -179,7 +179,7 @@ class Descriptions extends React.Component<
static Item: typeof DescriptionsItem = DescriptionsItem;

state: {
screens: BreakpointMap;
screens: ScreenMap;
} = {
screens: {},
};
Expand Down
10 changes: 5 additions & 5 deletions components/grid/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -487,11 +487,11 @@ exports[`renders ./components/grid/demo/gutter.md correctly 1`] = `
</div>
<div
class="ant-row"
style="margin-top:-10px;margin-bottom:10px"
style="margin-left:-16px;margin-right:-16px;margin-top:-10px;margin-bottom:10px"
>
<div
class="ant-col ant-col-6 gutter-row"
style="padding-top:10px;padding-bottom:10px"
style="padding-left:16px;padding-right:16px;padding-top:10px;padding-bottom:10px"
>
<div
class="gutter-box"
Expand All @@ -501,7 +501,7 @@ exports[`renders ./components/grid/demo/gutter.md correctly 1`] = `
</div>
<div
class="ant-col ant-col-6 gutter-row"
style="padding-top:10px;padding-bottom:10px"
style="padding-left:16px;padding-right:16px;padding-top:10px;padding-bottom:10px"
>
<div
class="gutter-box"
Expand All @@ -511,7 +511,7 @@ exports[`renders ./components/grid/demo/gutter.md correctly 1`] = `
</div>
<div
class="ant-col ant-col-6 gutter-row"
style="padding-top:10px;padding-bottom:10px"
style="padding-left:16px;padding-right:16px;padding-top:10px;padding-bottom:10px"
>
<div
class="gutter-box"
Expand All @@ -521,7 +521,7 @@ exports[`renders ./components/grid/demo/gutter.md correctly 1`] = `
</div>
<div
class="ant-col ant-col-6 gutter-row"
style="padding-top:10px;padding-bottom:10px"
style="padding-left:16px;padding-right:16px;padding-top:10px;padding-bottom:10px"
>
<div
class="gutter-box"
Expand Down
13 changes: 10 additions & 3 deletions components/grid/row.tsx
Expand Up @@ -5,7 +5,7 @@ import RowContext from './RowContext';
import { tuple } from '../_util/type';
import ResponsiveObserve, {
Breakpoint,
BreakpointMap,
ScreenMap,
responsiveArray,
} from '../_util/responsiveObserve';

Expand All @@ -21,7 +21,7 @@ export interface RowProps extends React.HTMLAttributes<HTMLDivElement> {
}

export interface RowState {
screens: BreakpointMap;
screens: ScreenMap;
}

export default class Row extends React.Component<RowProps, RowState> {
Expand All @@ -30,7 +30,14 @@ export default class Row extends React.Component<RowProps, RowState> {
};

state: RowState = {
screens: {},
screens: {
xs: true,
sm: true,
md: true,
lg: true,
xl: true,
xxl: true,
},
};

token: string;
Expand Down