-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basic fellowship redesign according last available mockups
- Loading branch information
1 parent
0105593
commit 2248735
Showing
58 changed files
with
458 additions
and
223 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
23 changes: 23 additions & 0 deletions
23
src/renderer/features/fellowship-evidence/components/EvidenceCard.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,23 @@ | ||
import { memo } from 'react'; | ||
|
||
import { useI18n } from '@/shared/i18n'; | ||
import { Icon } from '@/shared/ui'; | ||
import { Box } from '@/shared/ui-kit'; | ||
|
||
export const EvidenceCard = memo(() => { | ||
const { t } = useI18n(); | ||
|
||
return ( | ||
<button className="rounded-xl border border-filter-border bg-card-background text-button-small"> | ||
<Box direction="row" verticalAlign="center" horizontalAlign="space-between" gap={2} padding={4}> | ||
<Box direction="row" verticalAlign="center" gap={2}> | ||
<Icon name="whitelistVoting" size={16} /> | ||
|
||
{t('fellowship.evidence.cardTitle')} | ||
</Box> | ||
|
||
<Icon name="right" size={16} /> | ||
</Box> | ||
</button> | ||
); | ||
}); |
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,3 @@ | ||
export const ERROR = { | ||
networkDisabled: 'Network disabled', | ||
}; |
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,11 @@ | ||
import { fellowshipHeaderCardsSlot } from '@/pages/Fellowship/ui/Fellowship'; | ||
|
||
import { EvidenceCard } from './components/EvidenceCard'; | ||
import { fellowshipEvidenceFeature } from './model/feature'; | ||
|
||
export { fellowshipEvidenceFeature }; | ||
|
||
fellowshipEvidenceFeature.inject(fellowshipHeaderCardsSlot, { | ||
order: 1, | ||
render: () => <EvidenceCard />, | ||
}); |
49 changes: 49 additions & 0 deletions
49
src/renderer/features/fellowship-evidence/model/feature.ts
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,49 @@ | ||
import { combine, sample } from 'effector'; | ||
|
||
import { $features } from '@/shared/config/features'; | ||
import { createFeature } from '@/shared/feature'; | ||
import { isDev, nullable } from '@/shared/lib/utils'; | ||
import { accountsService } from '@/domains/network'; | ||
import { walletModel } from '@/entities/wallet'; | ||
import { fellowshipNetworkFeature } from '@/features/fellowship-network'; | ||
import { ERROR } from '../constants'; | ||
|
||
const $input = combine( | ||
{ | ||
network: fellowshipNetworkFeature.model.network.$network, | ||
accounts: walletModel.$availableAccounts, | ||
}, | ||
({ network, accounts }) => { | ||
if (nullable(network)) return null; | ||
|
||
return { | ||
api: network.api, | ||
asset: network.asset, | ||
chain: network.chain, | ||
chainId: network.chainId, | ||
palletType: network.palletType, | ||
accounts: accountsService.filterAccountOnChain(accounts, network.chain), | ||
}; | ||
}, | ||
); | ||
|
||
export const fellowshipEvidenceFeature = createFeature({ | ||
name: 'fellowship/evidence', | ||
enable: $features.map(({ fellowship }) => fellowship && isDev()), | ||
input: $input, | ||
filter: input => { | ||
return input.api.isConnected | ||
? null | ||
: { | ||
status: 'failed', | ||
type: 'warning', | ||
error: new Error(ERROR.networkDisabled), | ||
}; | ||
}, | ||
}); | ||
|
||
sample({ | ||
clock: fellowshipNetworkFeature.model.network.$isActive, | ||
filter: fellowshipNetworkFeature.model.network.$isActive, | ||
target: fellowshipEvidenceFeature.restore, | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/renderer/features/fellowship-evidence/model/fellowship.ts
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,20 @@ | ||
import { combine } from 'effector'; | ||
|
||
import { nullable } from '@/shared/lib/utils'; | ||
import { collectiveDomain } from '@/domains/collectives'; | ||
|
||
import { fellowshipEvidenceFeature } from './feature'; | ||
|
||
const $fellowshipStore = collectiveDomain.$store.map(store => store['fellowship'] || null); | ||
|
||
const $store = combine($fellowshipStore, fellowshipEvidenceFeature.state, (fellowshipStore, state) => { | ||
if (nullable(fellowshipStore) || state.status !== 'running') { | ||
return null; | ||
} | ||
|
||
return fellowshipStore[state.data.chainId] ?? null; | ||
}); | ||
|
||
export const fellowshipModel = { | ||
$store, | ||
}; |
42 changes: 16 additions & 26 deletions
42
src/renderer/features/fellowship-members/components/MembersCard.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 |
---|---|---|
@@ -1,45 +1,35 @@ | ||
import { useGate, useUnit } from 'effector-react'; | ||
import { useUnit } from 'effector-react'; | ||
import { memo } from 'react'; | ||
|
||
import { useI18n } from '@/shared/i18n'; | ||
import { FootnoteText, Icon, SmallTitleText } from '@/shared/ui'; | ||
import { Box, Skeleton, Surface } from '@/shared/ui-kit'; | ||
import { Icon } from '@/shared/ui'; | ||
import { Box, Skeleton } from '@/shared/ui-kit'; | ||
import { ERROR } from '../constants'; | ||
import { fellowshipMembersFeature } from '../model/feature'; | ||
import { membersModel } from '../model/members'; | ||
import { membersFeatureStatus } from '../model/status'; | ||
|
||
import { MembersModal } from './MembersModal'; | ||
|
||
type Props = { | ||
// TODO replace with internal modal openning | ||
onClick: () => void; | ||
}; | ||
|
||
export const MembersCard = memo<Props>(({ onClick }) => { | ||
useGate(membersFeatureStatus.gate); | ||
|
||
export const MembersCard = memo(() => { | ||
const { t } = useI18n(); | ||
|
||
const featureState = useUnit(membersFeatureStatus.state); | ||
const featureState = useUnit(fellowshipMembersFeature.state); | ||
const [members, pending, fulfilled] = useUnit([membersModel.$list, membersModel.$pending, membersModel.$fulfilled]); | ||
const isNetworkDisabled = featureState.status === 'failed' && featureState.error.message === ERROR.networkDisabled; | ||
|
||
return ( | ||
<MembersModal> | ||
<Surface as="button" disabled={pending || isNetworkDisabled} onClick={onClick}> | ||
<Box direction="row" verticalAlign="center" horizontalAlign="space-between" padding={[6, 4]}> | ||
<Box gap={2}> | ||
<Box direction="row" gap={1}> | ||
<Icon name="members" size={16} /> | ||
<FootnoteText className="text-text-secondary">{t('fellowship.members.cardTitle')}</FootnoteText> | ||
</Box> | ||
<Skeleton active={pending && !fulfilled && !isNetworkDisabled}> | ||
<SmallTitleText>{t('fellowship.fellow', { count: members.length })}</SmallTitleText> | ||
</Skeleton> | ||
</Box> | ||
<Icon name="arrowRight" /> | ||
<button | ||
className="rounded-xl border border-filter-border bg-card-background text-button-small" | ||
disabled={pending || isNetworkDisabled} | ||
> | ||
<Box direction="row" verticalAlign="center" horizontalAlign="space-between" padding={4} gap={2}> | ||
<Skeleton active={pending && !fulfilled && !isNetworkDisabled}> | ||
{t('fellowship.fellow', { count: members.length })} | ||
</Skeleton> | ||
<Icon name="right" size={16} /> | ||
</Box> | ||
</Surface> | ||
</button> | ||
</MembersModal> | ||
); | ||
}); |
8 changes: 3 additions & 5 deletions
8
src/renderer/features/fellowship-members/components/MembersModal.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
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
import { fellowshipHeaderCardsSlot } from '@/pages/Fellowship/ui/Fellowship'; | ||
|
||
import { MembersCard } from './components/MembersCard'; | ||
import { fellowshipMembersFeature } from './model/feature'; | ||
|
||
export { fellowshipMembersFeature }; | ||
|
||
fellowshipMembersFeature.inject(fellowshipHeaderCardsSlot, { | ||
order: 4, | ||
render: () => <MembersCard />, | ||
}); |
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
Oops, something went wrong.