-
Notifications
You must be signed in to change notification settings - Fork 55
fix(Avatar): alignment of status icon on size changes #828
Conversation
…ttps://github.com/stardust-ui/react into feat/add-ts-support-to-screener-interaction-tests
Co-Authored-By: kuzhelov <deckster@mail.ru>
Codecov Report
@@ Coverage Diff @@
## master #828 +/- ##
=======================================
Coverage 93.54% 93.54%
=======================================
Files 21 21
Lines 728 728
Branches 69 69
=======================================
Hits 681 681
Misses 47 47 Continue to review full report at Codecov.
|
} | ||
|
||
export const getSizeStyles = (sizeInPx: number, variables: StatusVariables) => { | ||
const sizeInRem = pxToRem(sizeInPx + 2 * ((variables.borderColor && variables.borderWidth) || 0)) |
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.
const sizeInRem = pxToRem(sizeInPx + 2 * ((variables.borderColor && variables.borderWidth) || 0)) | |
const borderWidth = (variables.borderColor && variables.borderWidth) || 0 | |
const sizeInRem = pxToRem(sizeInPx + 2 * borderWidth) |
One line will not save us 😸 Can we make it more readable?
import { getStyle as getSvgStyle } from './svg' | ||
import { IconVariables, IconSizeModifier } from './iconVariables' | ||
|
||
const sizes: { [key in IconSize]: number } = { | ||
const sizes: { [key in SizeValue]: number } = { |
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.
const sizes: { [key in SizeValue]: number } = { | |
const sizes: Record<SizeValue, number> = { |
As I remember this should work
@@ -35,16 +35,33 @@ const getTextColor = (state: string, variables: StatusVariables) => { | |||
} | |||
} | |||
|
|||
const statusStyles: ComponentSlotStylesInput<StatusPropsWithDefaults, StatusVariables> = { | |||
export const sizeToPxValue = { |
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.
Can we introduce a type there, i.e.:
export const sizeToPxValue = { | |
export const sizeToPxValue: Record<SizeValue, number> = { |
@@ -120,7 +120,7 @@ export { | |||
export { default as Ref, RefProps } from './components/Ref/Ref' | |||
export { default as Segment, SegmentProps } from './components/Segment/Segment' | |||
|
|||
export { default as Status, StatusPropsWithDefaults, StatusProps } from './components/Status/Status' | |||
export { default as Status, StatusProps } from './components/Status/Status' |
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.
StatusPropsWithDefaults
was part of public API, so this is a breaking change, too
@@ -23,10 +24,10 @@ export interface AvatarProps extends UIComponentProps { | |||
name?: string | |||
|
|||
/** Size multiplier. */ | |||
size?: number | |||
size?: SizeValue |
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.
Can you check if there are some usages in the prototypes (I am pretty sure there is employee card prototype that has bigger Avatar)
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.
sure, thanks for heads up!
|
||
/** Shorthand for the status of the user. */ | ||
status?: ShorthandValue | ||
status?: ShorthandValue<StatusProps> |
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.
👍
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.
LGTM please just check the prototypes if there are some miss-usages of the size props after these changes.
TODO
Breaking Change
This PR unifies the set of values that could be provided to
size
prop ofAvatar
andStatus
components: instead ofnumber
s that were originally used, now there is a finite set of string values that could be provided assize
:Necessary changes on the client side
This PR requires the following changes to be made on the client side at places where
size
values were provided to eitherAvatar
component, or to thesize
prop of itsstatus
slot. No changes should be introduced in case if no any value was provided tosize
prop.sizes
of Avatar andstatus
slot originally were not in syncSize of status icon was always remained the same and haven't responded to
Avatar
's size changes - now size ofstatus
slot changes alongside with changes toAvatar
's size:Was
Now
In order to preserve original behavior size of
status
slot must be set explicitly:Avatar
, value was provided tosize
propAvatar
,size
value is provided tostatus
slotRemoved types
AvatarPropsWithDefaults
andStatusPropsWithDefaults
types were removed from public API. Client should replace them withAvatarProps
andStatusProps
at places of usage, accordingly.Description
This PR unifies size values for Avatar component - now those values are taken from common Stardust dictionary (
smallest
-> ... ->largest
).Related styles of Teams theme were adjusted accordingly.
Fix: unresponsiveness of
status
slot to size changesWas
Now