Skip to content

Commit

Permalink
RWD/my profile and members (#4577)
Browse files Browse the repository at this point in the history
* fix Accounts list to be scrollable

* fix Statistics gap to be 16px when smaller than lg

* fix Profile/Mymemberships header responsive

* fix Mymembershiplist scrollable

* fix invite/add member modal

* fix members page filter

* fix modals responsive, disable some

* fix sidebarSlider

* fix Pagination responsiveness

* fix memberlistitem min-width

* fix width and padding of memberlistfilter box

* fix modals

* replace window.innerWidth with screen.width

* mock width of the screen

* hide modal when decreasing the width of the window

* hide My Profile in the navigation slider in mobile

* update responsive provider, add not support mobile modal

* Update packages/ui/src/app/GlobalModals.tsx

Co-authored-by: Theophile Sandoz <[email protected]>

* update GlobalModal

---------

Co-authored-by: Theophile Sandoz <[email protected]>
  • Loading branch information
eshark9312 and thesan authored Oct 23, 2023
1 parent 528ed99 commit 7481d71
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 65 deletions.
1 change: 1 addition & 0 deletions packages/ui/src/accounts/components/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ interface HeaderProps {
}

const AccountsWrap = styled.div`
overflow: auto;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 16px auto;
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/app/GlobalModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import { TransferModal, TransferModalCall } from '@/accounts/modals/TransferModa
import { FailureModal } from '@/common/components/FailureModal'
import { Loading } from '@/common/components/Loading'
import { ModalGlass } from '@/common/components/Modal'
import { NotSupportMobileModal } from '@/common/components/NotSupportMobileModal'
import { SearchResultsModal, SearchResultsModalCall } from '@/common/components/Search/SearchResultsModal'
import { SuccessModal } from '@/common/components/SuccessModal'
import { useModal } from '@/common/hooks/useModal'
import { useResponsive } from '@/common/hooks/useResponsive'
import { useTransactionStatus } from '@/common/hooks/useTransactionStatus'
import { ConfirmModal } from '@/common/modals/ConfirmModal/ConfirmModal'
import { OnBoardingModal, OnBoardingModalCall } from '@/common/modals/OnBoardingModal'
Expand Down Expand Up @@ -203,10 +205,13 @@ export const MODAL_WITH_CLOSE_CONFIRMATION: ModalNames[] = [
'VoteForProposalModal',
]

const NON_TRANSACTIONAL_MODALS: ModalNames[] = ['Member', 'ApplicationDetails', 'VoteRationaleModal', 'SearchResults']

export const GlobalModals = () => {
const { modal, hideModal, currentModalMachine, showModal, modalData, isClosing } = useModal()
const { active: activeMember } = useMyMemberships()
const { status } = useTransactionStatus()
const { supportTransactions } = useResponsive()
const Modal = useMemo(() => (modal && modal in modals ? memo(() => modals[modal as ModalNames]) : null), [modal])

const [container, setContainer] = useState(document.body)
Expand All @@ -217,6 +222,10 @@ export const GlobalModals = () => {

const potentialFallback = useGlobalModalHandler(currentModalMachine, hideModal)

if (modal && !supportTransactions && !NON_TRANSACTIONAL_MODALS.includes(modal as ModalNames)) {
return <NotSupportMobileModal onClose={hideModal} />
}

if (modal && !GUEST_ACCESSIBLE_MODALS.includes(modal as ModalNames) && !activeMember) {
showModal<SwitchMemberModalCall>({
modal: 'SwitchMember',
Expand Down
14 changes: 9 additions & 5 deletions packages/ui/src/app/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { NavigationHeader } from '@/common/components/page/Sidebar/NavigationHea
import { NAVIGATION_LINK_GAP, NavigationLink } from '@/common/components/page/Sidebar/NavigationLink'
import { Colors, RemoveScrollbar } from '@/common/constants'
import { useNetworkEndpoints } from '@/common/hooks/useNetworkEndpoints'
import { useResponsive } from '@/common/hooks/useResponsive'
import { useToggle } from '@/common/hooks/useToggle'
import { CouncilRoutes, ElectionRoutes } from '@/council/constants'
import { useElectionStage } from '@/council/hooks/useElectionStage'
Expand Down Expand Up @@ -59,6 +60,7 @@ export const SideBar = () => {
}

export const SideBarContent = () => {
const { supportTransactions } = useResponsive()
const [comingSoonListActive, toggleComingSoonListActive] = useToggle(false)
const { stage: electionStage } = useElectionStage()
const [endpoints] = useNetworkEndpoints()
Expand All @@ -75,11 +77,13 @@ export const SideBarContent = () => {
{/* Overview*/}
{/* </NavigationLink>*/}
{/*</NavigationLinksItem>*/}
<NavigationLinksItem>
<NavigationLink to={ProfileRoutes.profile} icon={<MyProfileIcon />}>
My profile
</NavigationLink>
</NavigationLinksItem>
{supportTransactions && (
<NavigationLinksItem>
<NavigationLink to={ProfileRoutes.profile} icon={<MyProfileIcon />}>
My profile
</NavigationLink>
</NavigationLinksItem>
)}
<NavigationLinksItem>
<NavigationLink to={WorkingGroupsRoutes.groups} icon={<WorkingGroupsIcon />}>
Working Groups
Expand Down
10 changes: 8 additions & 2 deletions packages/ui/src/app/components/SideBarSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SideBarSlider = React.memo(({ setOpen }: Props) => {
useEscape(() => hideSideBarSlider())

return (
<SidePaneGlass onClick={onBackgroundClick}>
<SidePaneGlassWrapper onClick={onBackgroundClick}>
<SideBarWarpper>
<NavigationInnerWrapper>
<SliderHeader>
Expand All @@ -36,7 +36,7 @@ export const SideBarSlider = React.memo(({ setOpen }: Props) => {
<SideBarContent />
</NavigationInnerWrapper>
</SideBarWarpper>
</SidePaneGlass>
</SidePaneGlassWrapper>
)
})

Expand Down Expand Up @@ -72,3 +72,9 @@ const CloseIconWrapper = styled.div`
background-color: ${Colors.Black[600]};
}
`

const SidePaneGlassWrapper = styled(SidePaneGlass)`
@media (max-width: 767px) {
display: flex;
}
`
27 changes: 25 additions & 2 deletions packages/ui/src/app/pages/Profile/MyMemberships.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import styled from 'styled-components'

import { PageLayout, PageHeaderWrapper, PageHeaderRow } from '@/app/components/PageLayout'
import { ButtonsGroup } from '@/common/components/buttons'
Expand All @@ -14,7 +15,7 @@ export const MyMemberships = () => (
<PageLayout
header={
<PageHeaderWrapper>
<PageHeaderRow>
<MyMembershipsHeaderWrapper>
<PageTitle>My Profile</PageTitle>
<ButtonsGroup>
<InviteMemberButton size="medium">Invite a member</InviteMemberButton>
Expand All @@ -23,10 +24,32 @@ export const MyMemberships = () => (
Add Membership
</AddMembershipButton>
</ButtonsGroup>
</PageHeaderRow>
</MyMembershipsHeaderWrapper>
<MyProfileTabs />
</PageHeaderWrapper>
}
main={<Memberships />}
/>
)

const MyMembershipsHeaderWrapper = styled(PageHeaderRow)`
@media (max-width: 768px) {
display: flex;
flex-direction: column;
gap: 16px;
${ButtonsGroup} {
grid-auto-flow: row;
grid-row-gap: 8px;
width: 100%;
button {
width: 100%;
display: flex;
justify-content: center;
align-items: center:
gap: 4px;
}
}
}
`
2 changes: 1 addition & 1 deletion packages/ui/src/common/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const ModalWrap = styled.section<ModalWrapProps>`
'modalfooter';
grid-area: modal;
background-color: ${Colors.White};
width: 100%;
width: calc(100% - 64px);
max-width: ${({ modalMaxSize }) => {
switch (modalMaxSize) {
case 'xs':
Expand Down
17 changes: 17 additions & 0 deletions packages/ui/src/common/components/NotSupportMobileModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

import { Modal, ModalBody, ModalHeader } from '@/common/components/Modal'
import { TextMedium } from '@/common/components/typography'

interface Props {
onClose: () => void
}

export const NotSupportMobileModal = ({ onClose }: Props) => (
<Modal onClose={onClose} modalSize="xs">
<ModalHeader onClick={onClose} title="" />
<ModalBody>
<TextMedium>This action requires a browser extension, please visit this page from a desktop browser.</TextMedium>
</ModalBody>
</Modal>
)
6 changes: 4 additions & 2 deletions packages/ui/src/common/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styled from 'styled-components'

import { Arrow } from '@/common/components/icons'
import { BorderRad, Colors, Fonts, Transitions } from '@/common/constants/styles'
import { useResponsive } from '@/common/hooks/useResponsive'

interface PaginationProps {
pageCount?: number
Expand All @@ -14,6 +15,7 @@ interface PaginationProps {

export const Pagination: FC<PaginationProps> = ({ pageCount = 0, handlePageChange, page }) => {
const history = useHistory()
const { size } = useResponsive()

if (pageCount < 2) {
return null
Expand All @@ -27,8 +29,8 @@ export const Pagination: FC<PaginationProps> = ({ pageCount = 0, handlePageChang
<StyledPaginateContainer>
<ReactPaginate
pageCount={pageCount}
marginPagesDisplayed={3}
pageRangeDisplayed={3}
marginPagesDisplayed={size === 'xxs' || size === 'xs' ? 1 : 3}
pageRangeDisplayed={size === 'xxs' ? 1 : 3}
containerClassName="pagination"
pageLinkClassName="pagination__link"
pageClassName="page"
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/common/components/statistics/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ interface StatisticsLayoutProps {
export const Statistics = styled.div<StatisticsLayoutProps>`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: ${({ gapSize }) => (gapSize === 's' ? '16px' : '24px')};
gap: 16px;
width: 100%;
max-width: 100%;
${({ withMargin }) => (withMargin ? 'margin-top: 8px;' : null)};
@media (min-width: 1440px) {
gap: ${({ gapSize }) => (gapSize === 's' ? '16px' : '24px')};
}
`

export const StatisticsThreeColumns = styled.div<StatisticsLayoutProps>`
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/common/providers/responsive/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { createContext } from 'react'
export interface UseResponsive {
size: 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
isMobile: boolean
supportTransactions: boolean
}

export const ResponsiveContext = createContext<UseResponsive>({
size: 'lg',
isMobile: false,
supportTransactions: true,
})
1 change: 1 addition & 0 deletions packages/ui/src/common/providers/responsive/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ResponsiveProvider = (props: Props) => {
? 'xs'
: 'xxs',
isMobile: windowWidth < 1024,
supportTransactions: screen.width >= 768,
}),
[windowWidth]
)
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/src/memberships/components/MemberList/Members.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import styled from 'styled-components'

import { MembershipOrderByInput } from '@/common/api/queries'
import { List, ListItem } from '@/common/components/List'
Expand Down Expand Up @@ -30,7 +31,7 @@ export const MemberList = ({ isLoading, members, getSortProps, searchFilter }: M
}

return (
<div>
<MemberListWrapper>
<ListHeaders $colLayout={colLayoutByType('Member')}>
<SortHeader {...getSortProps('handle')}>Memberships</SortHeader>
<ListHeader>Roles</ListHeader>
Expand All @@ -48,6 +49,10 @@ export const MemberList = ({ isLoading, members, getSortProps, searchFilter }: M
</ListItem>
))}
</List>
</div>
</MemberListWrapper>
)
}

const MemberListWrapper = styled.div`
overflow: auto;
`
Loading

0 comments on commit 7481d71

Please sign in to comment.