Просмотр исходного кода

feat: Refactor style management for inner padding in layout components

- Updated HeaderBar, PageLayout, and SiderBar components to manage inner padding state based on selected items.
- Replaced `isChatPage` state with `shouldInnerPadding` in Style context for better clarity and functionality.
- Enhanced user experience by dynamically adjusting content padding based on navigation selections.
CalciumIon 1 год назад
Родитель
Сommit
28fa77cc92

+ 2 - 0
web/src/components/HeaderBar.js

@@ -118,8 +118,10 @@ const HeaderBar = () => {
               return (
               return (
                 <div onClick={(e) => {
                 <div onClick={(e) => {
                   if (props.itemKey === 'home') {
                   if (props.itemKey === 'home') {
+                    styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
                     styleDispatch({ type: 'SET_SIDER', payload: true });
                     styleDispatch({ type: 'SET_SIDER', payload: true });
                   } else {
                   } else {
+                    styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
                     styleDispatch({ type: 'SET_SIDER', payload: false });
                     styleDispatch({ type: 'SET_SIDER', payload: false });
                   }
                   }
                 }}>
                 }}>

+ 1 - 1
web/src/components/PageLayout.js

@@ -23,7 +23,7 @@ const PageLayout = () => {
         </Sider>
         </Sider>
         <Layout>
         <Layout>
           <Content
           <Content
-            style={{ overflowY: 'auto', padding: styleState.isChatPage? '0': '24px' }}
+            style={{ overflowY: styleState.shouldInnerPadding?'hidden':'auto', padding: styleState.shouldInnerPadding? '0': '24px' }}
           >
           >
             <App />
             <App />
           </Content>
           </Content>

+ 2 - 2
web/src/components/SiderBar.js

@@ -280,9 +280,9 @@ const SiderBar = () => {
         items={headerButtons}
         items={headerButtons}
         onSelect={(key) => {
         onSelect={(key) => {
           if (key.itemKey.toString().startsWith('chat')) {
           if (key.itemKey.toString().startsWith('chat')) {
-            styleDispatch({ type: 'SET_CHAT_PAGE', payload: true });
+            styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
           } else {
           } else {
-            styleDispatch({ type: 'SET_CHAT_PAGE', payload: false });
+            styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
           }
           }
           setSelectedKeys([key.itemKey]);
           setSelectedKeys([key.itemKey]);
         }}
         }}

+ 3 - 3
web/src/context/Style/index.js

@@ -11,7 +11,7 @@ export const StyleProvider = ({ children }) => {
   const [state, setState] = useState({
   const [state, setState] = useState({
     isMobile: false,
     isMobile: false,
     showSider: false,
     showSider: false,
-    isChatPage: false,
+    shouldInnerPadding: false,
   });
   });
 
 
   const dispatch = (action) => {
   const dispatch = (action) => {
@@ -26,8 +26,8 @@ export const StyleProvider = ({ children }) => {
         case 'SET_MOBILE':
         case 'SET_MOBILE':
           setState(prev => ({ ...prev, isMobile: action.payload }));
           setState(prev => ({ ...prev, isMobile: action.payload }));
           break;
           break;
-        case 'SET_CHAT_PAGE':
-          setState(prev => ({ ...prev, isChatPage: action.payload }));
+        case 'SET_INNER_PADDING':
+          setState(prev => ({ ...prev, shouldInnerPadding: action.payload }));
           break;
           break;
         default:
         default:
           setState(prev => ({ ...prev, ...action }));
           setState(prev => ({ ...prev, ...action }));