mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-17 07:31:00 +08:00

* feat(masonry): new component * refactor(masonry): housekeeping * refactor(masonry): update props and use transform * refactor(masonry): update calculation logic * refactor(masonry): rename file and add keepAspectRatio props * refactor(masonry): rename file * refactor(masonry): rename file * refactor(masonry): rename file * chore(masonry): update docs * refactor(masonry): change to transform style * feat(masonry): update demo and test * chore(masonry): escape brackets * test(masonry): update snapshots * fix(masonry): handle rtl * chore(masonry): update snapshots * refactor(masonry): remove redundant condition * refactor(masonry): update dependencies * refactor(masonry): use token in transition * refactor: add scope Co-authored-by: lijianan <574980606@qq.com> Signed-off-by: Oyster Lee <oysterd3@gmail.com> * chore: tmp moving * chore: abstract hooks * chore: back of sequential * chore: refactor type * chore: split logic * chore: tmp of it * feat: support sort * chore: support sort logic * chore: clean up * test: simplify test case * test: fix test case * chore: fix lint * docs: update docs * chore: update limit * test: update snapshot * test: fix test case * test: update snapshot * chore: support fresh * test: coverage * chore: ssr render nothing * test: update snapshot * docs: update docs * docs: add SemanticPreview * chore: adjust calc logic * docs: add more info * test: add test case * docs: fix lint * test: update snapshot * test: update snapshot * Update components/masonry/Masonry.tsx Co-authored-by: thinkasany <480968828@qq.com> Signed-off-by: 二货爱吃白萝卜 <smith3816@gmail.com> * chore: rename * chore: fix lint --------- Signed-off-by: Oyster Lee <oysterd3@gmail.com> Signed-off-by: 二货爱吃白萝卜 <smith3816@gmail.com> Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: ice <49827327+coding-ice@users.noreply.github.com> Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: thinkasany <480968828@qq.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { Breakpoint, ScreenMap } from '../../_util/responsiveObserver';
|
|
import { responsiveArray } from '../../_util/responsiveObserver';
|
|
import type { RowProps } from '../row';
|
|
|
|
export type Gap = number | undefined;
|
|
|
|
export default function useGutter(
|
|
gutter: RowProps['gutter'],
|
|
screens: ScreenMap | null,
|
|
): [Gap, Gap] {
|
|
const results: [number | undefined, number | undefined] = [undefined, undefined];
|
|
const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, undefined];
|
|
|
|
// By default use as `xs`
|
|
const mergedScreens = screens || {
|
|
xs: true,
|
|
sm: true,
|
|
md: true,
|
|
lg: true,
|
|
xl: true,
|
|
xxl: true,
|
|
};
|
|
|
|
normalizedGutter.forEach((g, index) => {
|
|
if (typeof g === 'object' && g !== null) {
|
|
for (let i = 0; i < responsiveArray.length; i++) {
|
|
const breakpoint: Breakpoint = responsiveArray[i];
|
|
if (mergedScreens[breakpoint] && g[breakpoint] !== undefined) {
|
|
results[index] = g[breakpoint] as number;
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
results[index] = g;
|
|
}
|
|
});
|
|
return results;
|
|
}
|