Skip to content

Commit

Permalink
Add Skeleton to Snaps UI
Browse files Browse the repository at this point in the history
  • Loading branch information
david0xd committed Jan 16, 2025
1 parent d8ce2c7 commit cb6ae47
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { SnapDelineator } from '../snaps/snap-delineator';
import { SnapUIAddress } from '../snaps/snap-ui-address';
import { SnapUIAvatar } from '../snaps/snap-ui-avatar';
import { SnapUIBanner } from '../snaps/snap-ui-banner';
import { SnapUISkeleton } from '../snaps/snaps-ui-skeleton';
import { SnapUIButton } from '../snaps/snap-ui-button';
import { SnapUICard } from '../snaps/snap-ui-card';
import { SnapUICheckbox } from '../snaps/snap-ui-checkbox';
Expand Down Expand Up @@ -91,6 +92,7 @@ export const safeComponentList = {
SnapUIAddress,
SnapUIAvatar,
SnapUIBanner,
SnapUISkeleton,
SnapUIButton,
SnapUICard,
SnapUICheckbox,
Expand Down
2 changes: 2 additions & 0 deletions ui/components/app/snaps/snap-ui-renderer/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { icon } from './icon';
import { section } from './section';
import { avatar } from './avatar';
import { banner } from './banner';
import { skeleton } from './skeleton';

export const COMPONENT_MAPPING = {
Box: box,
Expand Down Expand Up @@ -60,4 +61,5 @@ export const COMPONENT_MAPPING = {
Selector: selector,
Section: section,
Banner: banner,
Skeleton: skeleton,
};
13 changes: 13 additions & 0 deletions ui/components/app/snaps/snap-ui-renderer/components/skeleton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SkeletonElement } from '@metamask/snaps-sdk/jsx';

Check failure on line 1 in ui/components/app/snaps/snap-ui-renderer/components/skeleton.ts

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

'"@metamask/snaps-sdk/jsx"' has no exported member named 'SkeletonElement'. Did you mean 'SelectorElement'?
import { UIComponentFactory } from './types';

export const skeleton: UIComponentFactory<SkeletonElement> = ({ element }) => {
return {
element: 'SnapUISkeleton',
props: {
width: element.props.width,
height: element.props.height,
borderRadius: element.props.borderRadius,
},
};
};
1 change: 1 addition & 0 deletions ui/components/app/snaps/snaps-ui-skeleton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './snap-ui-skeleton';
17 changes: 17 additions & 0 deletions ui/components/app/snaps/snaps-ui-skeleton/snap-ui-skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { FunctionComponent } from 'react';
import { Skeleton } from '../../../component-library/skeleton';
import { BorderRadius } from '../../../../helpers/constants/design-system';

export type SnapUISkeletonProps = {
width: number | string;
height: number | string;
borderRadius?: BorderRadius;
};

export const SnapUISkeleton: FunctionComponent<SnapUISkeletonProps> = ({
width,
height,
borderRadius,
}) => {
return <Skeleton width={width} height={height} borderRadius={borderRadius} />;
};

0 comments on commit cb6ae47

Please sign in to comment.