Commit b071c811 by Calcium-Ion Committed by GitHub

Merge pull request #612 from Calcium-Ion/mobile

feat: Refactor style management for inner padding in layout components
parents 7c67a8d2 430fbefd
......@@ -118,8 +118,10 @@ const HeaderBar = () => {
return (
<div onClick={(e) => {
if (props.itemKey === 'home') {
styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
styleDispatch({ type: 'SET_SIDER', payload: true });
} else {
styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
styleDispatch({ type: 'SET_SIDER', payload: false });
}
}}>
......
......@@ -23,7 +23,7 @@ const PageLayout = () => {
</Sider>
<Layout>
<Content
style={{ overflowY: 'auto', padding: styleState.isChatPage? '0': '24px' }}
style={{ overflowY: styleState.shouldInnerPadding?'hidden':'auto', padding: styleState.shouldInnerPadding? '0': '24px' }}
>
<App />
</Content>
......
......@@ -280,9 +280,9 @@ const SiderBar = () => {
items={headerButtons}
onSelect={(key) => {
if (key.itemKey.toString().startsWith('chat')) {
styleDispatch({ type: 'SET_CHAT_PAGE', payload: true });
styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
} else {
styleDispatch({ type: 'SET_CHAT_PAGE', payload: false });
styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
}
setSelectedKeys([key.itemKey]);
}}
......
......@@ -11,7 +11,7 @@ export const StyleProvider = ({ children }) => {
const [state, setState] = useState({
isMobile: false,
showSider: false,
isChatPage: false,
shouldInnerPadding: false,
});
const dispatch = (action) => {
......@@ -26,8 +26,8 @@ export const StyleProvider = ({ children }) => {
case 'SET_MOBILE':
setState(prev => ({ ...prev, isMobile: action.payload }));
break;
case 'SET_CHAT_PAGE':
setState(prev => ({ ...prev, isChatPage: action.payload }));
case 'SET_INNER_PADDING':
setState(prev => ({ ...prev, shouldInnerPadding: action.payload }));
break;
default:
setState(prev => ({ ...prev, ...action }));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment