Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implemented some Animo colors #54

Merged
merged 9 commits into from
Jan 11, 2023
3 changes: 2 additions & 1 deletion packages/toolbox-electron/src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ contextBridge.exposeInMainWorld('nodeFetch', async (endpoint, request) => {

const getConfigDirForPlatform = (platform, homeDir, appDataDir) => {
switch (platform) {
case 'linux' || 'darwin':
case 'darwin':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You switched it back 👀 that's fine haha :).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it wasn't working and javascript doesn't support the || operator in a switch or it wasn't working as expected. Darwin didn't work with this switch so idk It's stranngeeee. So when I switched it back it started working again on my macbook.

case 'linux':
return `${homeDir}/.config/siera/ui/config.json`
case 'win32':
return `${appDataDir}\\siera\\ui\\config.json`
Expand Down
20 changes: 2 additions & 18 deletions packages/toolbox-ui/src/ToolboxApp.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ColorScheme, MantineThemeOverride } from '@mantine/core'
import type { ColorScheme } from '@mantine/core'
import type { RouterProviderProps } from 'react-router-dom'

import { ColorSchemeProvider, MantineProvider } from '@mantine/core'
Expand All @@ -7,6 +7,7 @@ import { NotificationsProvider } from '@mantine/notifications'
import React from 'react'
import { RouterProvider } from 'react-router-dom'

import { toolboxTheme } from './ToolboxTheme'
import { GlobalErrorHandler } from './components/GlobalErrorHandler'
import { useConfigUnsafe } from './contexts/ConfigProvider'
import { PresentInviteModal } from './modals/PresentInviteModal'
Expand All @@ -15,23 +16,6 @@ interface ToolboxAppProps {
router: RouterProviderProps['router']
}

const toolboxTheme = (colorScheme: ColorScheme): MantineThemeOverride => ({
colorScheme: colorScheme,
colors: {
neutral: ['#333333'],
secondary: ['#557EBA'],
background: ['#F5F5F4'],
animoWhite: ['#F5F5F4'],
animoCoral: ['#EA6767'],
animoBlue: ['#557EBA'],
animoBlack: ['#202223'],
animoLightgrey: ['#E5E5E5'],
animoDarkgrey: ['#3A3B3B'],
},

fontFamily: 'Montserrat, sans-serif',
})

export const ToolboxApp = ({ router }: ToolboxAppProps) => {
const { config, setColorScheme } = useConfigUnsafe()

Expand Down
42 changes: 42 additions & 0 deletions packages/toolbox-ui/src/ToolboxTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { AnimoVariantTheme } from './layout/themes'
import type { ColorScheme, MantineThemeOverride, Tuple } from '@mantine/core'

import { animoLightTheme, animoDarkTheme } from './layout/themes'

export const toolboxTheme = (colorScheme: ColorScheme): MantineThemeOverride => ({
colorScheme: colorScheme,
colors: colorScheme === 'dark' ? animoDarkTheme : animoLightTheme,

defaultRadius: '0.25rem',

white: '#F5F5F4',
black: '#202223',

primaryColor: 'primaryOne',

fontFamily: 'Montserrat, sans-serif',

components: {
Title: {
styles: (theme) => ({
root: {
color: theme.colors.textOne[7],
},
}),
},

Modal: {
styles: () => ({
title: {
fontWeight: 700,
},
}),
},
},
})

declare module '@mantine/core' {
export interface MantineThemeColorsOverride {
colors: Record<keyof AnimoVariantTheme, Tuple<string, 10>>
}
}
11 changes: 9 additions & 2 deletions packages/toolbox-ui/src/components/BackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { UnstyledButton } from '@mantine/core'
import { createStyles, UnstyledButton } from '@mantine/core'
import { IconChevronLeft } from '@tabler/icons'
import React from 'react'

import { useNavigation } from '../hooks/useNavigation'

const useStyles = createStyles((theme) => ({
button: {
color: theme.colors.primaryOne[7],
},
}))

export const BackButton = () => {
const { classes } = useStyles()
const navigation = useNavigation()

return (
<UnstyledButton onClick={() => navigation.goBack()}>
<UnstyledButton className={classes.button} onClick={() => navigation.goBack()}>
<IconChevronLeft size={32} />
</UnstyledButton>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/toolbox-ui/src/components/GlobalErrorHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const GlobalErrorHandler = ({ children }: GlobalErrorHandlerProps) => {
if (!(reason instanceof AriesFrameworkError)) return

showNotification({
color: 'red',
color: 'error',
title: reason.name,
message: reason.message,
})
Expand Down
18 changes: 9 additions & 9 deletions packages/toolbox-ui/src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { Center, createStyles, Flex, Loader, Text } from '@mantine/core'
import { Center, createStyles, Flex, Loader, Text, useMantineTheme } from '@mantine/core'
import React from 'react'

const useStyles = createStyles({
const useStyles = createStyles((theme) => ({
spinnerCentering: {
height: '100vh',
},
})
descriptionText: {
color: theme.colors.textOne[0],
},
}))

interface LoadingProps {
description?: string
}

export const Loading = ({ description }: LoadingProps) => {
const { classes } = useStyles()
const { colors } = useMantineTheme()

return (
<Center className={classes.spinnerCentering}>
<Flex direction="column" align="center" gap="sm">
<Loader size="xl" />
{description && (
<Text align="center" c="dimmed">
{description}
</Text>
)}
<Loader size="xl" stroke={colors.primaryTwo[0]} />
{description && <Text align="center">{description}</Text>}
</Flex>
</Center>
)
Expand Down
24 changes: 16 additions & 8 deletions packages/toolbox-ui/src/components/RecordActions.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ActionIcon, Group, Loader } from '@mantine/core'
import { ActionIcon, createStyles, 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 @@ -11,29 +11,37 @@ interface RecordActionsProps {
isLoading?: boolean
}

const useStyles = createStyles((theme) => ({
trashIcon: {
color: theme.colors.danger[6],
},
}))

export const RecordActions = ({ onAccept, onDecline, onDelete, isLoading }: RecordActionsProps) => {
const { classes } = useStyles()

const actions = [
onAccept && (
<PrimaryButton key="accept" size="xs" onClick={onAccept}>
<PrimaryButton key="accept" size="xs" variant="light" onClick={onAccept}>
Accept
</PrimaryButton>
),

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

onDelete && (
<ActionIcon key="delete" color="red" onClick={onDelete}>
<IconTrash size={16} stroke={1.5} />
<ActionIcon key="delete" onClick={onDelete} variant="transparent">
<IconTrash size={16} stroke={1.5} className={classes.trashIcon} />
</ActionIcon>
),
].filter(Boolean)

return (
<Group spacing={0} position="right">
<Group spacing={4} position="right">
{isLoading ? <Loader size={20} /> : actions}
</Group>
)
Expand Down
22 changes: 20 additions & 2 deletions packages/toolbox-ui/src/components/SmartAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import type { AvatarProps } from '@mantine/core'

import { Avatar } from '@mantine/core'
import { Avatar, createStyles } from '@mantine/core'
import React from 'react'

type SmartAvatarProps = AvatarProps

const useStyles = createStyles((theme) => ({
placeholder: {
backgroundColor: theme.fn.rgba(theme.colors.primaryOne[7], 0.1),
color: theme.colors.primaryOne[7],
},
}))

export const SmartAvatar = ({ children, ...props }: SmartAvatarProps) => {
const { classes, cx } = useStyles()
const label = children
? children
.toString()
Expand All @@ -16,5 +24,15 @@ export const SmartAvatar = ({ children, ...props }: SmartAvatarProps) => {
.toUpperCase()
: undefined

return <Avatar {...props}>{label}</Avatar>
return (
<Avatar
{...props}
classNames={{
...props.classNames,
placeholder: cx(classes.placeholder, props.classNames?.placeholder),
}}
>
{label}
</Avatar>
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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 { EmptyState } from '../generic/table/EmptyState'
import { StatusBadge } from '../generic/table/StatusBadge'

interface ConnectionsTableProps {
records: ConnectionRecord[]
Expand Down Expand Up @@ -36,20 +38,26 @@ const useStyles = createStyles(() => ({

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

return (
<ScrollArea>
<Table verticalSpacing="sm" className={classes.table}>
<thead>
<tr>
<th className={classes.labelSize}>Connection</th>
<th className={classes.idSize}>Connection Id</th>
<th className={classes.idSize}>Connection</th>
<th className={classes.stateSize}>State</th>
<th className={classes.actionsSize} />
</tr>
</thead>
<tbody>
{records.length === 0 && (
<tr>
<td colSpan={4}>
<EmptyState message="No connections found" />
</td>
</tr>
)}
{records.map((record: ConnectionRecord) => {
const isLoading = ConnectionsUtil.isConnectionWaitingForResponse(record)
const isWaitingForAccept = ConnectionsUtil.isConnectionWaitingForAcceptInput(record)
Expand All @@ -73,7 +81,7 @@ export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: Con
</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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ 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 { EmptyState } from '../generic/table/EmptyState'
import { StatusBadge } from '../generic/table/StatusBadge'

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

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

return (
Expand All @@ -50,6 +51,13 @@ export const CredentialsTable = ({ records, connections, onDelete, onAccept, onD
</tr>
</thead>
<tbody>
{records.length === 0 && (
<tr>
<td colSpan={3}>
<EmptyState message="No credentials found" />
</td>
</tr>
)}
{records.map((record) => {
const connection = connections.find((connection) => connection.id == record.connectionId)
const formattedCredential = formattedData.find((data) => data.id === record.id)
Expand All @@ -70,7 +78,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
Loading