From 7f9aff2cfb7661354cf346c740cee15937ad7901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Mon, 16 Oct 2023 14:49:01 +0800 Subject: [PATCH] enhance: auto layout hasSider (#45361) * enhance: auto layout hasSider * test: update snapshot --- components/layout/Sider.tsx | 6 ++--- .../__tests__/__snapshots__/demo.test.ts.snap | 14 ++++++------ components/layout/__tests__/index.test.tsx | 16 +++++++++++++- components/layout/context.ts | 15 +++++++++++++ components/layout/hooks/useHasSider.ts | 22 +++++++++++++++++++ components/layout/layout.tsx | 22 ++++++------------- 6 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 components/layout/context.ts create mode 100644 components/layout/hooks/useHasSider.ts diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index 3a015f2b5c..669450e3dd 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -1,14 +1,14 @@ +import * as React from 'react'; +import { useContext, useEffect, useRef, useState } from 'react'; import BarsOutlined from '@ant-design/icons/BarsOutlined'; import LeftOutlined from '@ant-design/icons/LeftOutlined'; import RightOutlined from '@ant-design/icons/RightOutlined'; import classNames from 'classnames'; import omit from 'rc-util/lib/omit'; -import * as React from 'react'; -import { useContext, useEffect, useRef, useState } from 'react'; import isNumeric from '../_util/isNumeric'; import { ConfigContext } from '../config-provider'; -import { LayoutContext } from './layout'; +import { LayoutContext } from './context'; const dimensionMaxMap = { xs: '479.98px', diff --git a/components/layout/__tests__/__snapshots__/demo.test.ts.snap b/components/layout/__tests__/__snapshots__/demo.test.ts.snap index 0f1323d240..75d0807d75 100644 --- a/components/layout/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/layout/__tests__/__snapshots__/demo.test.ts.snap @@ -115,7 +115,7 @@ exports[`renders components/layout/demo/basic.tsx correctly 1`] = ` class="ant-space-item" >