Repository navigation
Feat/redesign avatar #832
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/redesign avatar #832
Changes from 9 commits
062f7d2
8486814
1d8eb90
70e11c2
8daf5bb
89beaa0
0edd1b8
d485cf4
286a5fa
b00948a
4c1f7e0
8fe68e6
5d07ebc
2c4dde2
21d5435
72e20de
b9ea605
8b03763
0ccdd11
1670a4c
626d77a
0bef69e
a0143f8
6384104
9bb39a6
c9fe6e2
832485a
912570f
de2ce6b
61979fe
99a0d12
cd90953
ef6e6c4
55b4d20
7d53d50
4732249
ae2ab26
ad5fd61
b12fac5
f0736e3
77b5721
bdf8684
c24471a
f36de38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { CSSProperties } from 'react' | ||
| import type { Ref } from 'react' | ||
|
|
||
| import type { BoxProps } from './interfaces.js' | ||
|
|
||
| import { assignInlineVars } from '@vanilla-extract/dynamic' | ||
| import { clsx } from 'clsx' | ||
|
|
||
| import { avatarAnimationStyles } from '../styles/animation.css.js' | ||
| import { boxAppearanceStyles } from './styles/appearance/styles.css.js' | ||
| import { boxAppearanceVariables } from './styles/appearance/styles.css.js' | ||
| import { boxBaseStyles } from './styles/base.css.js' | ||
| import { boxBorderWidth } from './styles/base.css.js' | ||
| export const Box = ({ | ||
| shape, | ||
| appearance, | ||
| clickable, | ||
| disabled, | ||
| children, | ||
| className, | ||
| style, | ||
| ref, | ||
| ...props | ||
| }: BoxProps) => { | ||
| const boxProps = { | ||
| ...props, | ||
| 'data-clickable': clickable ? '' : undefined, | ||
| 'data-disabled': disabled ? '' : undefined, | ||
| className: clsx(boxBaseStyles, boxAppearanceStyles, avatarAnimationStyles, className), | ||
| style: { | ||
| ...assignInlineVars(boxAppearanceVariables, appearance), | ||
| ...assignInlineVars({ | ||
| [boxBorderWidth]: | ||
| typeof shape.borderWidth === 'number' ? `${shape.borderWidth}px` : shape.borderWidth, | ||
| }), | ||
| width: shape.size, | ||
| height: shape.size, | ||
| borderRadius: shape.radius, | ||
| ...style, | ||
| } satisfies CSSProperties, | ||
| } | ||
| if (clickable) { | ||
| return ( | ||
| <button ref={ref as Ref<HTMLButtonElement>} {...boxProps} disabled={disabled} type='button'> | ||
| {children} | ||
| </button> | ||
| ) | ||
| } | ||
| return ( | ||
| <span ref={ref} {...boxProps}> | ||
| {children} | ||
| </span> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { DOMAttributes } from 'react' | ||
| import type { HTMLAttributes } from 'react' | ||
| import type { ReactNode } from 'react' | ||
| import type { Ref } from 'react' | ||
|
|
||
| import type { BoxAppearance } from './styles/appearance/interfaces.js' | ||
| import type { BoxShape } from './styles/shape/interfaces.js' | ||
|
|
||
| export interface BoxProps extends Omit< | ||
| HTMLAttributes<HTMLSpanElement>, | ||
| keyof DOMAttributes<HTMLSpanElement> | 'accessKey' | 'autoFocus' | 'contentEditable' | 'tabIndex' | ||
| > { | ||
| shape: BoxShape | ||
| appearance: BoxAppearance | ||
| clickable?: boolean | ||
| disabled?: boolean | ||
| children?: ReactNode | ||
| ref?: Ref<HTMLButtonElement | HTMLSpanElement> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const DISABLED_OPACITY = 0.6 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export interface BoxAppearanceValues { | ||
| borderColor: string | ||
| shadow: string | ||
| opacity: string | ||
| } | ||
| export interface BoxAppearance { | ||
| default: BoxAppearanceValues | ||
| hover: BoxAppearanceValues | ||
| focused: BoxAppearanceValues | ||
| pressed: BoxAppearanceValues | ||
| disabled: BoxAppearanceValues | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
При clickable=false те же props попадают на span. В Chromium статичный Avatar с tabIndex=0 получил фокус по Tab, а при disabled клик всё равно вызвал onClick, несмотря на aria-disabled=true. Раздели props статичного и интерактивного вариантов и проверь переключение clickable с сохранённым обработчиком.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2c4dde2