Skip to content

Commit

Permalink
feat: Changed the color usage of the action buttons and made the stat…
Browse files Browse the repository at this point in the history
…us badge generic

Signed-off-by: Tom Lanser <[email protected]>
  • Loading branch information
Tommylans committed Jan 4, 2023
1 parent 3644dab commit 226c506
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/toolbox-ui/src/components/RecordActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ActionIcon, Group, Loader } from '@mantine/core'
import { IconTrash } from '@tabler/icons'
import React from 'react'

import { DangerButton, PrimaryButton } from './generic'
import { PrimaryButton, SecondaryButton } from './generic'

interface RecordActionsProps {
onDelete?: () => void
Expand All @@ -20,9 +20,9 @@ export const RecordActions = ({ onAccept, onDecline, onDelete, isLoading }: Reco
),

onDecline && (
<DangerButton key="reject" size="xs" variant="light" onClick={onDecline}>
<SecondaryButton key="reject" size="xs" onClick={onDecline}>
Decline
</DangerButton>
</SecondaryButton>
),

onDelete && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ConnectionRecord } from '@aries-framework/core'

import { ConnectionsUtil } from '@animo/toolbox-core/src/utils/records/ConnectionsUtil'
import { Badge, createStyles, Group, ScrollArea, Table, Text, useMantineTheme } from '@mantine/core'
import { createStyles, Group, ScrollArea, Table, Text } from '@mantine/core'
import React from 'react'

import { RecordActions } from '../RecordActions'
import { SmartAvatar } from '../SmartAvatar'
import { StatusBadge } from '../generic/table/StatusBadge'

interface ConnectionsTableProps {
records: ConnectionRecord[]
Expand Down Expand Up @@ -35,7 +36,6 @@ const useStyles = createStyles(() => ({

export const ConnectionsTable = ({ records, onDelete, onAccept }: ConnectionsTableProps) => {
const { classes } = useStyles()
const theme = useMantineTheme()

return (
<ScrollArea>
Expand Down Expand Up @@ -71,9 +71,7 @@ export const ConnectionsTable = ({ records, onDelete, onAccept }: ConnectionsTab
</Text>
</td>
<td className={classes.stateSize}>
<Badge variant={theme.colorScheme === 'dark' ? 'light' : 'outline'} color="blue">
{record.state}
</Badge>
<StatusBadge>{record.state}</StatusBadge>
</td>
<td className={classes.actionsSize}>
<RecordActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import type { ConnectionRecord, CredentialExchangeRecord } from '@aries-framewor

import { formatSchemaName } from '@animo/toolbox-core/src/utils'
import { CredentialsUtil } from '@animo/toolbox-core/src/utils/records/CredentialsUtil'
import { Badge, createStyles, Group, ScrollArea, Table, Text, useMantineTheme } from '@mantine/core'
import { createStyles, Group, ScrollArea, Table, Text } from '@mantine/core'
import React from 'react'

import { useCredentialsFormatData } from '../../contexts/CredentialFormatDataProvider'
import { RecordActions } from '../RecordActions'
import { SmartAvatar } from '../SmartAvatar'
import { StatusBadge } from '../generic/table/StatusBadge'

interface CredentialsTableProps {
records: CredentialExchangeRecord[]
Expand Down Expand Up @@ -36,7 +37,6 @@ const useStyles = createStyles(() => ({

export const CredentialsTable = ({ records, connections, onDelete, onAccept, onDecline }: CredentialsTableProps) => {
const { classes } = useStyles()
const theme = useMantineTheme()
const { formattedData } = useCredentialsFormatData()

return (
Expand Down Expand Up @@ -70,7 +70,7 @@ export const CredentialsTable = ({ records, connections, onDelete, onAccept, onD
</Group>
</td>
<td className={classes.stateSize}>
<Badge variant={theme.colorScheme === 'dark' ? 'light' : 'outline'}>{record.state}</Badge>
<StatusBadge>{record.state}</StatusBadge>
</td>
<td className={classes.actionsSize}>
<RecordActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const useStyles = createStyles((theme) => ({
secondary: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.animoBlack[0] : theme.colors.animoWhite[0],
color: theme.colorScheme === 'dark' ? theme.colors.animoWhite[0] : theme.colors.animoBlack[0],

'&:hover': {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.animoBlack[1] : theme.colors.animoWhite[1],
},
},
}))

Expand Down
10 changes: 10 additions & 0 deletions packages/toolbox-ui/src/components/generic/table/StatusBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { BadgeProps } from '@mantine/core'

import { Badge, useMantineTheme } from '@mantine/core'
import React from 'react'

export const StatusBadge = (props: BadgeProps) => {
const { colorScheme } = useMantineTheme()

return <Badge variant={colorScheme === 'dark' ? 'light' : 'outline'} color="blue" {...props} />
}
6 changes: 3 additions & 3 deletions packages/toolbox-ui/src/components/proofs/ProofsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { ConnectionRecord, ProofExchangeRecord } from '@aries-framework/core'

import { ProofsUtil } from '@animo/toolbox-core/src/utils/records/ProofsUtil'
import { Badge, createStyles, Group, ScrollArea, Table, Text, useMantineTheme } from '@mantine/core'
import { createStyles, Group, ScrollArea, Table, Text } from '@mantine/core'
import React from 'react'

import { useProofsFormatData } from '../../contexts/ProofsFormatDataProvider'
import { RecordActions } from '../RecordActions'
import { SmartAvatar } from '../SmartAvatar'
import { StatusBadge } from '../generic/table/StatusBadge'

interface ProofsTableProps {
records: ProofExchangeRecord[]
Expand Down Expand Up @@ -38,7 +39,6 @@ const useStyles = createStyles(() => ({

export const ProofsTable = ({ records, connections, onDelete, onAccept, onDecline }: ProofsTableProps) => {
const { classes } = useStyles()
const theme = useMantineTheme()
const { formattedData } = useProofsFormatData()

return (
Expand Down Expand Up @@ -80,7 +80,7 @@ export const ProofsTable = ({ records, connections, onDelete, onAccept, onDeclin
</Text>
</td>
<td className={classes.stateSize}>
<Badge variant={theme.colorScheme === 'dark' ? 'light' : 'outline'}>{record.state}</Badge>
<StatusBadge>{record.state}</StatusBadge>
</td>
<td className={classes.actionsSize}>
<RecordActions
Expand Down
19 changes: 16 additions & 3 deletions packages/toolbox-ui/src/pages/AgentSelectionScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Container, Flex, Group, Space, Text, Title, UnstyledButton } from '@mantine/core'
import { Card, Container, createStyles, Flex, Group, Space, Text, Title, UnstyledButton } from '@mantine/core'
import { IconPlus } from '@tabler/icons'
import React from 'react'

Expand All @@ -7,7 +7,20 @@ import { SmartAvatar } from '../components/SmartAvatar'
import { useAgentManager } from '../contexts/AgentManagerContext'
import { useNavigation } from '../hooks/useNavigation'

const useStyles = createStyles((theme) => ({
card: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[0],
boxShadow: theme.shadows.xs,
transition: 'background-color 0.2s ease',

'&:hover': {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
},
},
}))

export const AgentSelectionScreen = () => {
const { classes } = useStyles()
const navigation = useNavigation()
const { agents, setCurrentAgentId, loading } = useAgentManager()

Expand All @@ -22,12 +35,12 @@ export const AgentSelectionScreen = () => {

return (
<Container mt={20}>
<Title size="h3">Agents</Title>
<Title size="h2">Agents</Title>
<Space h="md" />
<Flex gap="md" wrap="wrap">
{agents.map((agent) => (
<UnstyledButton key={agent.id} onClick={() => switchToAgent(agent.id)}>
<Card h={100} w={220}>
<Card h={100} w={220} className={classes.card}>
<Group noWrap>
<SmartAvatar src={agent.agentConfig.connectionImageUrl} size={64} radius="md">
{agent.agentConfig.label}
Expand Down

0 comments on commit 226c506

Please sign in to comment.