-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reader: Pass header content to Stream components (#98045)
* ➖ REMOVE: remove extra localize function from ReaderAvatar * UPDATE: jsconfig for improving TS speed * UPDATE: migrate ReaderAuthorLink to TypeScript * REFACTOR: Update ReaderFollowButton to use TypeScript * REFACTOR: Update AuthorCompactProfile to functional component and use TypeScript * ➕ ADDS: author info and improve styling * ➖ REMOVE: extra user tabs * 👌 IMPROVE: selector namings and section alignments * ➕ ADDS: empty content placeholders in user profile * 🔨 REFACTOR: update EmptyContent to functional component and use TypeScript * 💫 UPDATE: only keep code related to refactor * FIX: actionURL in EmptyContent * ➖ REMOVE: code related to refactoring * Reader: Pass header content to Stream components * Remove reducer update from this PR * Remove optional modifier and rename children to headerContent * Create UserProfileHeader component * Move nav into header and use header directly in views * IMPROVE: spacing and remove extra properties * 🔨 REFACTOR: move header styles to its dedicated file * Move UserProfileHeader to own folder and scope CSS --------- Co-authored-by: Mehmood Ahmad <[email protected]>
- Loading branch information
1 parent
52aefdf
commit bde75ca
Showing
6 changed files
with
136 additions
and
118 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
client/reader/user-stream/components/user-profile-header/index.tsx
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,66 @@ | ||
import page from '@automattic/calypso-router'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import ReaderAuthorLink from 'calypso/blocks/reader-author-link'; | ||
import ReaderAvatar from 'calypso/blocks/reader-avatar'; | ||
import SectionNav from 'calypso/components/section-nav'; | ||
import NavItem from 'calypso/components/section-nav/item'; | ||
import NavTabs from 'calypso/components/section-nav/tabs'; | ||
import { UserData } from 'calypso/lib/user/user'; | ||
|
||
import './style.scss'; | ||
|
||
interface UserProfileHeaderProps { | ||
user: UserData; | ||
} | ||
|
||
const UserProfileHeader = ( { user }: UserProfileHeaderProps ): JSX.Element => { | ||
const translate = useTranslate(); | ||
const currentPath = page.current; | ||
const userId = user.ID; | ||
|
||
const navigationItems = [ | ||
{ | ||
label: translate( 'Posts' ), | ||
path: `/read/users/${ userId }`, | ||
selected: currentPath === `/read/users/${ userId }`, | ||
}, | ||
{ | ||
label: translate( 'Lists' ), | ||
path: `/read/users/${ userId }/lists`, | ||
selected: currentPath === `/read/users/${ userId }/lists`, | ||
}, | ||
]; | ||
|
||
const selectedTab = navigationItems.find( ( item ) => item.selected )?.label || ''; | ||
|
||
return ( | ||
<div className="user-profile-header"> | ||
<header className="user-profile-header__main"> | ||
<ReaderAvatar author={ { ...user, has_avatar: !! user.avatar_URL } } /> | ||
<div className="user-profile-header__details"> | ||
<div className="user-profile-header__display-name"> | ||
<ReaderAuthorLink author={ { name: user.display_name } }> | ||
{ user.display_name } | ||
</ReaderAuthorLink> | ||
</div> | ||
{ user.bio && ( | ||
<div className="user-profile-header__bio"> | ||
<p className="user-profile-header__bio-desc">{ user.bio }</p> | ||
</div> | ||
) } | ||
</div> | ||
</header> | ||
<SectionNav selectedText={ selectedTab }> | ||
<NavTabs> | ||
{ navigationItems.map( ( item ) => ( | ||
<NavItem key={ item.path } path={ item.path } selected={ item.selected }> | ||
{ item.label } | ||
</NavItem> | ||
) ) } | ||
</NavTabs> | ||
</SectionNav> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserProfileHeader; |
48 changes: 48 additions & 0 deletions
48
client/reader/user-stream/components/user-profile-header/style.scss
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,48 @@ | ||
.is-section-reader { | ||
.user-profile-header { | ||
max-width: 768px; | ||
margin: 0 auto; | ||
|
||
&__main { | ||
align-items: center; | ||
display: flex; | ||
padding: 36px 0 24px; | ||
|
||
.reader-avatar { | ||
margin: 0 24px 0 0; | ||
} | ||
} | ||
|
||
&__display-name { | ||
font-family: Recoleta, sans-serif; | ||
font-size: 2rem; | ||
line-height: 1.5; | ||
} | ||
|
||
&__bio { | ||
/* stylelint-disable-next-line scales/font-sizes */ | ||
font-size: 1.125rem; | ||
} | ||
|
||
&__bio-desc { | ||
margin-bottom: 0; | ||
} | ||
|
||
.section-nav { | ||
box-shadow: none; | ||
border-bottom: 1px solid var( --color-border-subtle ); | ||
height: auto !important; | ||
} | ||
|
||
.section-nav-tab__link { | ||
&:hover { | ||
background: none; | ||
} | ||
} | ||
|
||
.section-nav-tab__text { | ||
font-weight: 500; | ||
color: var( --studio-black ); | ||
} | ||
} | ||
} |
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
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