Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(containers): fix SidebarSemanticPusherStyled max-width from SSR
Browse files Browse the repository at this point in the history
fix(containers): fix SidebarSemanticPusherStyled max-width from SSR
  • Loading branch information
Metnew committed Nov 10, 2017
1 parent 8df5ff4 commit b2e136b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/common/containers/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Props = {
checkAuthLogic: Function,
toggleSidebar: Function,
// IsMobile can force component to re-render
isMobile: string,
isMobile: boolean,
isMobileXS: boolean,
isMobileSM: boolean
}
Expand Down Expand Up @@ -147,22 +147,14 @@ class App extends Component {
// page: true,
onClick: closeSidebar
}

// {/* XXX: There is an issue with props and styled-components, so we use .extend and re-render the component when isMobile/isLoggedIn change triggered. Using `style` attribute isn't a good solution.
// Please, check: https://github.com/styled-components/styled-components/issues/439 */}
// {/* <SidebarSemanticPusherStyled style={SidebarSemanticPusherStyleProps}> */}
const SidebarSemanticPusherStyledPatch =
!isMobile && isLoggedIn
? SidebarSemanticPusherStyled.extend`
max-width: calc(100% - 150px);
`
: SidebarSemanticPusherStyled
// XXX: There is an issue with props and styled-components, so we use custom attributes and handle them inside styled component
/** {@link: https://github.com/styled-components/styled-components/issues/439} */

return (
<PageLayout>
<SidebarSemanticPushableStyled>
{isLoggedIn && <Sidebar {...sidebarProps} />}
<SidebarSemanticPusherStyledPatch>
<SidebarSemanticPusherStyled isloggedin={isLoggedIn ? 'y' : ''} ismobile={isMobile ? 'y' : ''}>
<StyledDimmer {...dimmerProps} />
<Header {...headerProps} />
<MainLayout>
Expand All @@ -173,7 +165,7 @@ class App extends Component {
<Footer />
</MainContent>
</MainLayout>
</SidebarSemanticPusherStyledPatch>
</SidebarSemanticPusherStyled>
</SidebarSemanticPushableStyled>
</PageLayout>
)
Expand Down
3 changes: 2 additions & 1 deletion src/common/containers/App/style.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'styled-components'
import styled, {css} from 'styled-components'
import {Dimmer, Sidebar, Container} from 'semantic-ui-react'

export const PageLayout = styled.div`height: 100%;`
Expand All @@ -18,6 +18,7 @@ export const MainContent = styled.main`

export const SidebarSemanticPusherStyled = styled(Sidebar.Pusher)`
-webkit-overflow-scrolling: touch;
${({isloggedin, ismobile}) => isloggedin && !ismobile && css`max-width: calc(100% - 150px);`}}
`

export const SidebarSemanticPushableStyled = styled(Sidebar.Pushable)`
Expand Down

0 comments on commit b2e136b

Please sign in to comment.