From aa2970134276d804c0ba68f7c436d9a3535235f8 Mon Sep 17 00:00:00 2001
From: Elisa Shapiro <83474365+ElisaShapiro@users.noreply.github.com>
Date: Fri, 8 Nov 2024 08:38:28 -0500
Subject: [PATCH] [PBNTR-485] Beta Skeleton Loading Kit- React (#3876)
**What does this PR do?** A clear and concise description with your
runway ticket url.
[PBNTR-485](https://runway.powerhrg.com/backlog_items/PBNTR-485)
introduces a new beta kit, Skeleton Loading, react only for now. It
follows this
[handoff](https://huddle.powerapp.cloud/projects/630/handoffs/1342/) and
[build
plan](https://gist.github.com/nidaqg/70bfdc07132a8cf90ade05f008acf836).
**Screenshots:** Screenshots to visualize your addition/change
**How to test?** Steps to confirm the desired behavior:
1. Go to the beta [Skeleton Loading kit
page](https://pr3876.playbook.beta.px.powerapp.cloud/kits/skeleton_loading/react)
in the review env. Note: as a beta kit, the kit should not be visible on
the Sidebar nor in the State & Progress Indicators kit category page.
2. Scroll through and review each doc example: default, color, layout,
border radius, height & width, square. Check dark mode as well.
#### Checklist:
- [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new
kit`, `deprecated`, or `breaking`. See [Changelog &
Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels)
for details.
- [x] **DEPLOY** I have added the `milano` label to show I'm ready for a
review.
- [x] **TESTS** I have added test coverage to my code.
---
playbook-website/config/menu.yml | 5 +-
playbook/app/entrypoints/playbook-doc.js | 2 +
playbook/app/entrypoints/playbook.scss | 2 +-
playbook/app/javascript/kits.js | 1 +
.../_skeleton_loading.scss | 37 +++++++++
.../pb_skeleton_loading/_skeleton_loading.tsx | 67 +++++++++++++++
.../_skeleton_loading_mixins.scss | 40 +++++++++
.../docs/_skeleton_loading_border_radius.jsx | 51 ++++++++++++
.../docs/_skeleton_loading_border_radius.md | 1 +
.../docs/_skeleton_loading_color.jsx | 26 ++++++
.../docs/_skeleton_loading_color.md | 1 +
.../docs/_skeleton_loading_default.html.erb | 1 +
.../docs/_skeleton_loading_default.jsx | 11 +++
.../docs/_skeleton_loading_height_width.jsx | 59 ++++++++++++++
.../docs/_skeleton_loading_height_width.md | 3 +
.../docs/_skeleton_loading_layout.jsx | 20 +++++
.../docs/_skeleton_loading_layout.md | 3 +
.../pb_skeleton_loading/docs/example.yml | 13 +++
.../pb_skeleton_loading/docs/index.js | 5 ++
.../skeleton_loading.html.erb | 12 +++
.../pb_skeleton_loading/skeleton_loading.rb | 8 ++
.../skeleton_loading.test.jsx | 81 +++++++++++++++++++
.../playbook/kits/skeleton_loading_spec.rb | 11 +++
23 files changed, 458 insertions(+), 2 deletions(-)
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb
create mode 100644 playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx
create mode 100644 playbook/spec/pb_kits/playbook/kits/skeleton_loading_spec.rb
diff --git a/playbook-website/config/menu.yml b/playbook-website/config/menu.yml
index 61f8012c84..a969e5a189 100644
--- a/playbook-website/config/menu.yml
+++ b/playbook-website/config/menu.yml
@@ -44,7 +44,7 @@ kits:
description:
status: stable
- name: drawer
- platforms: *1
+ platforms: *1
status: beta
- category: buttons
description: Buttons are used primarily for actions, such as “Save” and “Cancel”.
@@ -494,6 +494,9 @@ kits:
description: The timeline kit can use two different line styles in the same timeline
- solid and dotted line styles.
status: stable
+ - name: skeleton_loading
+ platforms: *1
+ status: beta
- category: tags
description:
components:
diff --git a/playbook/app/entrypoints/playbook-doc.js b/playbook/app/entrypoints/playbook-doc.js
index c4491a7449..daa9041213 100755
--- a/playbook/app/entrypoints/playbook-doc.js
+++ b/playbook/app/entrypoints/playbook-doc.js
@@ -88,6 +88,7 @@ import * as SelectableCard from 'kits/pb_selectable_card/docs'
import * as SelectableCardIcon from 'kits/pb_selectable_card_icon/docs'
import * as SelectableIcon from 'kits/pb_selectable_icon/docs'
import * as SelectableList from 'kits/pb_selectable_list/docs'
+import * as SkeletonLoading from 'kits/pb_skeleton_loading/docs'
import * as Source from 'kits/pb_source/docs'
import * as StarRating from 'kits/pb_star_rating/docs'
import * as StatChange from 'kits/pb_stat_change/docs'
@@ -197,6 +198,7 @@ WebpackerReact.registerComponents({
...SelectableCardIcon,
...SelectableIcon,
...SelectableList,
+ ...SkeletonLoading,
...Source,
...StarRating,
...StatChange,
diff --git a/playbook/app/entrypoints/playbook.scss b/playbook/app/entrypoints/playbook.scss
index 8ebaa9cf11..b790495672 100755
--- a/playbook/app/entrypoints/playbook.scss
+++ b/playbook/app/entrypoints/playbook.scss
@@ -1,4 +1,3 @@
-
@import 'kits/pb_advanced_table/advanced_table';
@import 'kits/pb_avatar/avatar';
@import 'kits/pb_avatar_action_button/avatar_action_button';
@@ -85,6 +84,7 @@
@import 'kits/pb_selectable_card_icon/selectable_card_icon';
@import 'kits/pb_selectable_icon/selectable_icon';
@import 'kits/pb_selectable_list/selectable_list';
+@import 'kits/pb_skeleton_loading/skeleton_loading';
@import 'kits/pb_source/source';
@import 'kits/pb_star_rating/star_rating';
@import 'kits/pb_stat_change/stat_change';
diff --git a/playbook/app/javascript/kits.js b/playbook/app/javascript/kits.js
index 15de7bb5b1..eab34edecf 100644
--- a/playbook/app/javascript/kits.js
+++ b/playbook/app/javascript/kits.js
@@ -93,6 +93,7 @@ export { default as SelectableCardIcon } from '../pb_kits/playbook/pb_selectable
export { default as SelectableIcon } from '../pb_kits/playbook/pb_selectable_icon/_selectable_icon'
export { default as SelectableList } from '../pb_kits/playbook/pb_selectable_list/_selectable_list'
export { default as SelectableListItem } from '../pb_kits/playbook/pb_selectable_list/_item'
+export { default as SkeletonLoading} from '../pb_kits/playbook/pb_skeleton_loading/_skeleton_loading'
export { default as Source } from '../pb_kits/playbook/pb_source/_source'
export { default as StarRating } from '../pb_kits/playbook/pb_star_rating/_star_rating'
export { default as StatChange } from '../pb_kits/playbook/pb_stat_change/_stat_change'
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss
new file mode 100644
index 0000000000..75f0976224
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss
@@ -0,0 +1,37 @@
+@import 'skeleton_loading_mixins';
+
+.pb_skeleton_loading {
+ display: "flex";
+ flex-direction: "column";
+ height: 100%;
+ .color_default {
+ @include skeleton-shimmer($silver);
+ }
+ .color_white {
+ @include skeleton-shimmer-light($white);
+ }
+ .dark {
+ @include skeleton-shimmer($border_dark);
+ }
+ .gap_xxs {
+ margin-top: 4px;
+ }
+ .gap_xs {
+ margin-top: 8px;
+ }
+ .gap_sm {
+ margin-top: 16px;
+ }
+ .gap_md {
+ margin-top: 24px;
+ }
+ .gap_lg {
+ margin-top: 32px;
+ }
+ .gap_xl {
+ margin-top: 40px;
+ }
+ .gap_xxl {
+ margin-top: 48px;
+ }
+}
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx
new file mode 100644
index 0000000000..f7e155408b
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx
@@ -0,0 +1,67 @@
+
+import React from 'react'
+import classnames from 'classnames'
+import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
+import { globalProps, GlobalProps } from '../utilities/globalProps'
+import { Sizes } from '../types'
+
+
+type SkeletonLoadingProps = {
+ aria?: { [key: string]: string },
+ className?: string,
+ data?: { [key: string]: string },
+ id?: string,
+ htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
+ height?: string,
+ width?: string,
+ borderRadius?: string,
+ gap?: Sizes | "none",
+ stack?: number,
+ color?: "default" | "white",
+ dark?: boolean,
+} & GlobalProps
+
+const SkeletonLoading = (props: SkeletonLoadingProps): React.ReactElement => {
+ const {
+ aria = {},
+ className,
+ data = {},
+ id,
+ htmlOptions = {},
+ height = "16px",
+ width = "100%",
+ borderRadius = "sm",
+ gap = "xxs",
+ stack = 1,
+ color = "default",
+ dark = false,
+ } = props
+
+ const ariaProps = buildAriaProps(aria)
+ const dataProps = buildDataProps(data)
+ const htmlProps = buildHtmlProps(htmlOptions)
+ const skeletonContainerCss = classnames(buildCss('pb_skeleton_loading'), globalProps(props), className)
+ const gapClass = gap !== 'none' ? `gap_${gap}` : ''
+ const innerSkeletonCss = classnames(`border_radius_${borderRadius}`,`color_${color}`, dark && 'dark', )
+ const innerSizeStyle = { height, width }
+
+ return (
+
+ {Array.from({ length: Number(stack) }).map((_, index) => (
+
0 && gapClass)}
+ key={index}
+ style={innerSizeStyle}
+ />
+ ))}
+
+ )
+}
+
+export default SkeletonLoading
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss
new file mode 100644
index 0000000000..2fe5d33376
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss
@@ -0,0 +1,40 @@
+// Animation
+@keyframes wave {
+ 0% {
+ background-position: -468px 0;
+ }
+ 100% {
+ background-position: 468px 0;
+ }
+}
+
+// Shimmer animation and gradient mixin based on color
+@mixin skeleton-shimmer($color) {
+ background: $color;
+ background-color: $color;
+ background-image: linear-gradient(
+ to left,
+ $color 0%,
+ lighten($color, 1%) 50%,
+ lighten($color, 1%) 60%,
+ $color 80%,
+ $color 100%
+ );
+ background-repeat: no-repeat;
+ animation: wave 1.5s linear infinite forwards;
+}
+
+@mixin skeleton-shimmer-light($color) {
+ background: $color;
+ background-color: $color;
+ background-image: linear-gradient(
+ to left,
+ $color 0%,
+ darken($color, 1%) 50%,
+ darken($color, 1%) 60%,
+ $color 80%,
+ $color 100%
+ );
+ background-repeat: no-repeat;
+ animation: wave 1.5s linear infinite forwards;
+}
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx
new file mode 100644
index 0000000000..800685d00a
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx
@@ -0,0 +1,51 @@
+import React from 'react'
+import { Flex, SkeletonLoading } from "playbook-ui"
+
+
+const SkeletonLoadingBorderRadius = (props) => (
+
+
+
+
+
+
+
+
+
+)
+
+export default SkeletonLoadingBorderRadius
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md
new file mode 100644
index 0000000000..52c493272c
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md
@@ -0,0 +1 @@
+The `borderRadius` prop accepts all of our [BorderRadius](https://playbook.powerapp.cloud/visual_guidelines/border_radius) tokens, with `sm` as default.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx
new file mode 100644
index 0000000000..82ad6d3323
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx
@@ -0,0 +1,26 @@
+import React from 'react'
+import { Card, SkeletonLoading } from "playbook-ui"
+
+
+const SkeletonLoadingColor = (props) => (
+
+
+
+
+
+
+
+
+)
+
+export default SkeletonLoadingColor
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md
new file mode 100644
index 0000000000..1837383ba8
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md
@@ -0,0 +1 @@
+The SkeletonLoading component has a default and a white `color` variant.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb
new file mode 100644
index 0000000000..542c88de2a
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb
@@ -0,0 +1 @@
+<%= pb_rails("skeleton_loading") %>
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx
new file mode 100644
index 0000000000..71f7986e57
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx
@@ -0,0 +1,11 @@
+import React from 'react'
+import { SkeletonLoading } from "playbook-ui"
+
+
+const SkeletonLoadingDefault = (props) => (
+
+
+
+)
+
+export default SkeletonLoadingDefault
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx
new file mode 100644
index 0000000000..9760332ca3
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx
@@ -0,0 +1,59 @@
+import React from 'react'
+import { Card, SkeletonLoading } from "playbook-ui"
+
+
+const SkeletonLoadingHeightWidth = (props) => (
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+export default SkeletonLoadingHeightWidth
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md
new file mode 100644
index 0000000000..12b931c066
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md
@@ -0,0 +1,3 @@
+The `height` and `width` props accept pixel and percentage values. If using a percentage for `height`, the parent container must have a set height.
+
+Set the `height` and `width` props to the same value to make a square. A `rounded` borderRadius will make a square a circle. If using percentages to make a square, your parent container must also be a square.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx
new file mode 100644
index 0000000000..babb83e293
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx
@@ -0,0 +1,20 @@
+import React from 'react'
+import { SkeletonLoading } from "playbook-ui"
+
+
+const SkeletonLoadingLayout = (props) => (
+
+
+
+
+)
+
+export default SkeletonLoadingLayout
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md
new file mode 100644
index 0000000000..11d2958cdc
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md
@@ -0,0 +1,3 @@
+Use the `stack` and `gap` props in conjunction to layer multiple Skeleton loading bars on top of each other.
+
+`stack` accepts a number that correlates to the number of rows (1 is default), and `gap` accepts a portion of our [spacing props](https://playbook.powerapp.cloud/visual_guidelines/spacing) (`xxs` as default, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`) to set the pixel distance between each row. `gap` will not do anything if there is no corresponding `stack` prop set.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml
new file mode 100644
index 0000000000..df125288c6
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml
@@ -0,0 +1,13 @@
+examples:
+
+ rails:
+ # - skeleton_loading_default: Default
+
+
+ react:
+ - skeleton_loading_default: Default
+ - skeleton_loading_color: Color
+ - skeleton_loading_layout: Layout
+ - skeleton_loading_border_radius: Border Radius
+ - skeleton_loading_height_width: Height & Width
+
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js
new file mode 100644
index 0000000000..862e8b3742
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js
@@ -0,0 +1,5 @@
+export { default as SkeletonLoadingDefault } from './_skeleton_loading_default.jsx'
+export { default as SkeletonLoadingColor } from './_skeleton_loading_color.jsx'
+export { default as SkeletonLoadingLayout } from './_skeleton_loading_layout.jsx'
+export { default as SkeletonLoadingBorderRadius } from './_skeleton_loading_border_radius.jsx'
+export { default as SkeletonLoadingHeightWidth } from './_skeleton_loading_height_width.jsx'
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb
new file mode 100644
index 0000000000..85230e2574
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb
@@ -0,0 +1,12 @@
+
+
+<%= pb_content_tag(
+ # :div,
+ # aria: object.aria,
+ # class: object.classname,
+ # data: object.data,
+ # id: object.id,
+ # **combined_html_options
+) do %>
+
SKELETON_LOADING CONTENT
+<% end %>
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb
new file mode 100644
index 0000000000..d91d02ea78
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+module Playbook
+ module PbSkeletonLoading
+ class SkeletonLoading < ::Playbook::KitBase
+ end
+ end
+end
diff --git a/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx
new file mode 100644
index 0000000000..57b7215622
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx
@@ -0,0 +1,81 @@
+import React from 'react'
+import { render, screen } from '@testing-library/react'
+import { ensureAccessible } from '../utilities/test-utils'
+import { SkeletonLoading } from 'playbook-ui'
+
+/* See these resources for more testing info:
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
+ - https://jestjs.io/docs/en/using-matchers
+*/
+
+describe('SkeletonLoading', () => {
+ const defaultProps = {
+ data: { testid: 'skeleton-loading' }
+ }
+
+ it('should be accessible', async () => {
+ ensureAccessible(SkeletonLoading, defaultProps)
+ })
+
+ it('renders with default props', () => {
+ const { container } = render(
)
+ const skeleton = screen.getByTestId('skeleton-loading')
+
+ expect(skeleton).toBeInTheDocument()
+ expect(skeleton).toHaveClass('pb_skeleton_loading')
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(1)
+ })
+
+ it('renders multiple skeleton items based on stack prop', () => {
+ const props = {
+ ...defaultProps,
+ stack: 3
+ }
+ const { container } = render(
)
+
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(3)
+ })
+
+ it('applies custom styles correctly', () => {
+ const props = {
+ ...defaultProps,
+ height: '24px',
+ width: '50%',
+ borderRadius: 'lg',
+ color: 'light',
+ dark: true
+ }
+ const { container } = render(
)
+ const skeletonItem = container.querySelector('div[class*="border_radius_"]')
+
+ expect(skeletonItem).toHaveClass('border_radius_lg')
+ expect(skeletonItem).toHaveClass('dark')
+ })
+
+ it('applies gap class to items after first one', () => {
+ const props = {
+ ...defaultProps,
+ stack: 3,
+ gap: 'md'
+ }
+ const { container } = render(
)
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
+
+ expect(skeletonItems[0]).not.toHaveClass('gap_md')
+ expect(skeletonItems[1]).toHaveClass('gap_md')
+ expect(skeletonItems[2]).toHaveClass('gap_md')
+ })
+
+ it('handles no gap properly', () => {
+ const props = {
+ ...defaultProps,
+ stack: 2,
+ gap: 'none'
+ }
+ const { container } = render(
)
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
+
+ expect(skeletonItems[0]).not.toHaveClass('gap_none')
+ expect(skeletonItems[1]).not.toHaveClass('gap_none')
+ })
+})
\ No newline at end of file
diff --git a/playbook/spec/pb_kits/playbook/kits/skeleton_loading_spec.rb b/playbook/spec/pb_kits/playbook/kits/skeleton_loading_spec.rb
new file mode 100644
index 0000000000..d755b171a2
--- /dev/null
+++ b/playbook/spec/pb_kits/playbook/kits/skeleton_loading_spec.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+# require_relative "../../../../app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading"
+
+# RSpec.describe Playbook::PbSkeleton_loading::Skeleton_loading do
+# subject { Playbook::PbSkeleton_loading::Skeleton_loading }
+
+# it { is_expected.to define_partial }
+
+# # Do not leave this file blank. Use other spec files for example tests.
+# end