Skip to content

Commit

Permalink
add type="account" to <ContextTag /> (#619)
Browse files Browse the repository at this point in the history
* u

* Create lemon-houses-develop.md
  • Loading branch information
prichodko authored Oct 16, 2024
1 parent e9979fd commit bf14368
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-houses-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@status-im/components": patch
---

add `type="account"` to `<ContextTag />`
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ContextTagVariant = (props: Props) => {
/>
}
/>
<ContextTag {...props} type="account" label="Account name" emoji="🐷" />
<ContextTag
{...props}
type="icon"
Expand Down
30 changes: 28 additions & 2 deletions packages/components/src/context-tag/context-tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { cloneElement, forwardRef } from 'react'
import { cva, cx } from 'cva'
import { match } from 'ts-pattern'

import { Avatar } from '../avatar'

import type { IconElement } from '../types'
import type { VariantProps } from 'cva'

Expand All @@ -15,10 +17,10 @@ type Props = {
| { type: 'community'; label: string; icon: IconElement }
| { type: 'token'; label: string; icon: IconElement }
| { type: 'network'; label: string; icon: IconElement }
| { type: 'account'; label: string; emoji: string }
| { type: 'icon'; label: string; icon: IconElement }
)
// | { type: 'user'; user: { name: string; src: string } }
// | { type: 'account'; account: { name: string; emoji: string } }
// | {
// type: 'group'
// group: {
Expand All @@ -36,7 +38,7 @@ type Props = {

const baseStyles = cva({
base: [
'inline-flex w-fit cursor-default items-center rounded-full',
'inline-flex w-fit cursor-default items-center',
'font-medium text-neutral-100 dark:text-white-100',
'bg-neutral-10 blur:bg-neutral-80/5 dark:bg-neutral-90 blur:dark:bg-white-5',
],
Expand All @@ -50,6 +52,13 @@ const baseStyles = cva({
selected: {
true: 'border border-customisation-50',
},
rounded: {
'8': 'rounded-8',
full: 'rounded-full',
},
},
defaultVariants: {
rounded: 'full',
},
})

Expand Down Expand Up @@ -116,6 +125,23 @@ const ContextTag = (props: Props, ref: React.Ref<HTMLDivElement>) => {
</div>
)
})
.with({ type: 'account' }, ({ label, emoji }) => {
return (
<div {...rest} ref={ref} className={baseStyles({ size, rounded: '8' })}>
<span className={iconStyles({ size, rounded: '6', offset: size })}>
<Avatar
type="account"
size={match(size)
.with('32', () => '28' as const)
.otherwise(() => '20' as const)}
name={label}
emoji={emoji}
/>
</span>
<span>{label}</span>
</div>
)
})
.with({ type: 'icon' }, ({ icon, label }) => {
return (
<div {...rest} ref={ref} className={baseStyles({ size })}>
Expand Down

0 comments on commit bf14368

Please sign in to comment.