Skip to content

Commit

Permalink
feat: add skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWaldschmidt committed Jun 14, 2024
1 parent d5d193b commit 40bb0c3
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v2.0.73

- Add `Skeleton` component

## v2.0.72

- Add `Panel` component
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lob/ui-components",
"version": "2.0.72",
"version": "2.0.73",
"engines": {
"node": ">=20.2.0",
"npm": ">=10.2.0"
Expand Down
10 changes: 10 additions & 0 deletions src/components/Skeleton/Skeleton.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Canvas, ArgTypes, PRIMARY_STORY } from '@storybook/addon-docs';
import { Primary } from './Skeleton.stories';

# Skeleton

<Canvas of={Primary} />

## Props

<ArgTypes story={PRIMARY_STORY} />
37 changes: 37 additions & 0 deletions src/components/Skeleton/Skeleton.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Meta, StoryFn } from '@storybook/vue3';
import mdx from './Skeleton.mdx';
// @ts-ignore No types from Vue file
import Skeleton from './Skeleton.vue';

const meta: Meta<typeof Skeleton> = {
title: 'Components/Skeleton',
component: Skeleton,
parameters: {
docs: {
page: mdx
}
}
};

export default meta;

const Template: StoryFn = (args, { argTypes }) => ({
components: { Skeleton },
setup: () => ({ args }),
template: `
<div style="width: 500px;">
<Skeleton v-bind="args">
<template #header>Metadata</template>
<template #default>
<ul>
<li>City: Chicago</li>
<li>State: Illinois</li>
<li>Country: United States</li>
</ul>
</template>
</Panel>
</div>
`
});

export const Primary = Template.bind({});
44 changes: 44 additions & 0 deletions src/components/Skeleton/Skeleton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<Skeleton
:class="`uic-skeleton color-${color}`"
data-testid="uic-skeleton"
:height
:width
/>
</template>

<script setup lang="ts">
import Skeleton from 'primevue/skeleton';
import { SkeletonColor } from './constants';
withDefaults(
defineProps<{
color?: SkeletonColor;
width?: string;
height?: string;
}>(),
{
color: SkeletonColor.NEUTRAL,
width: undefined,
height: undefined
}
);
</script>

<style>
.uic-skeleton {
@apply overflow-hidden;
@apply animate-pulse;
@apply rounded-lg;
&.color-error {
@apply bg-error;
}
&.color-neutral {
@apply bg-gray-200;
}
&.color-success {
@apply bg-success;
}
}
</style>
10 changes: 10 additions & 0 deletions src/components/Skeleton/__tests__/Skeleton.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/vue';
import Skeleton from '../Skeleton.vue';

describe('Skeleton', () => {
it('renders', () => {
const { getByTestId } = render(Skeleton);
expect(getByTestId('uic-skeleton')).toBeVisible();
});
});
8 changes: 8 additions & 0 deletions src/components/Skeleton/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Color } from '@/types';

export const SkeletonColor = {
ERROR: Color.ERROR,
NEUTRAL: Color.NEUTRAL,
SUCCESS: Color.SUCCESS
} as const;
export type SkeletonColor = (typeof SkeletonColor)[keyof typeof SkeletonColor];
2 changes: 2 additions & 0 deletions src/components/Skeleton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './constants';
export { default as Skeleton } from './Skeleton.vue';
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export * from './components/Modal';
export * from './components/Overlay';
export * from './components/Panel';
export * from './components/Pagination';
export * from './components/Skeleton';
export * from './components/Steps';
export * from './components/Table';
export * from './components/Tile';
Expand Down

0 comments on commit 40bb0c3

Please sign in to comment.