Skip to content

Commit

Permalink
fix: issues in the core package
Browse files Browse the repository at this point in the history
- change the image to src in avatar component
- add new animation utils to the core package
- fix issue in the skeleton component
  • Loading branch information
HamzaAmar committed Nov 23, 2024
1 parent ba17a27 commit bf484eb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/pillar-core/src/core/avatar/avatar.type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactElement, ReactNode } from 'react'
import type { Color, Corner, CornerBlob, CornerHand, Size, Variant } from '../../types'

type Animate = 'zoom' | 'jump-y' | 'jump-x'
type Animate = 'zoom' | 'jump-y' | 'jump-x' | 'jump--y' | 'jump--x' | 'zoom-in'

interface AvatarBase {
size?: Size
Expand All @@ -14,7 +14,7 @@ interface AvatarBase {

export interface AvatarProps extends AvatarBase {
title?: string
image?: string
src?: string
}

export interface AvatarGroupProps extends AvatarBase {
Expand Down
6 changes: 3 additions & 3 deletions packages/pillar-core/src/core/avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ export const Avatar = forwardRef((props, forwardRef) => {
corner = ctx?.corner,
color = ctx?.color ?? 'p',
fallback = ctx?.fallback ?? <User strokeWidth="1.5" width="max(1.5em, 10px)" />,
image = '',
src = '',
className,
title,
onError,
...rest
} = props

const [isError, setIsError] = useState(!image)
const [isError, setIsError] = useState(!src)

const classNames = cx(`av- av-${variant} C-${color} S-e F-c`, {
[`A-${animate}`]: animate,
Expand All @@ -93,7 +93,7 @@ export const Avatar = forwardRef((props, forwardRef) => {
className="av-I"
ref={(node) => {
if (node) {
node.src = image
node.src = src
node.onerror = () => {
setIsError(true)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pillar-core/src/core/skeleton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SkeletonButton.displayName = 'SkeletonButton'
*/

export const Skeleton = forwardRef((props, ref) => {
const { height, as: Tag = 'div', className, isLoading, children, ...rest } = props
const { height, as: Tag = 'div', className = '', isLoading, children, ...rest } = props

const classNames = cx(`sk- sk-B ${className}`, { [`Sh-${height}`]: height })

Expand Down
18 changes: 15 additions & 3 deletions packages/pillar-core/src/css/utilities/_animation.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
.A-zoom,
.A-jump-x,
.A-jump-y {
.A-jump--x,
.A-jump-y,
.A-jump--y,
.A-zoom-in {
transition: transform 0.3s;
}

.A-zoom:hover {
transform: scale(1.1);
}
.A-jump-y:hover {
transform: translateY(2px);
transform: translateY(3px);
}
.A-jump-x:hover {
transform: translateX(2px);
transform: translateX(3px);
}
.A-jump--x:hover {
transform: translateX(-3px);
}
.A-jump--y:hover {
transform: translateY(-3px);
}
.A-zoom-in:hover {
transform: scale(0.9);
}

0 comments on commit bf484eb

Please sign in to comment.