-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve example app layout and loading experience
- Improved the layout by making the content fill enough space so footer appears at the bottom. - Improved the loading experience by reading the signed in user resource inside a component that is deeper in the header so that it can be wrapped in a suspense boundary and we can render the header as soon as the code loads even though the signed in user might still be loading.
- Loading branch information
Showing
6 changed files
with
61 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Content = styled.main` | ||
min-height: calc(100vh - 192px); | ||
padding-bottom: 32px; | ||
overflow: hidden; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NavLink } from 'pre-router'; | ||
import styled from 'styled-components'; | ||
|
||
export const HeaderLink = styled(NavLink)` | ||
color: black; | ||
font-size: 20px; | ||
text-decoration: none; | ||
&.active { | ||
color: indigo; | ||
} | ||
& ~ & { | ||
padding-left: 16px; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { Resource } from 'suspendable'; | ||
import { SignedInUser } from '~/types'; | ||
import { HeaderLink } from '../HeaderLink'; | ||
|
||
interface Props { | ||
signedInUserResource: Resource<SignedInUser>; | ||
} | ||
|
||
export const HeaderUser: React.VFC<Props> = ({ signedInUserResource }) => { | ||
const signedInUser = signedInUserResource.read(); | ||
|
||
return ( | ||
<div> | ||
{signedInUser ? ( | ||
<span>Welcome {signedInUser.name}</span> | ||
) : ( | ||
<HeaderLink to="/sign-in">Sign in</HeaderLink> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters