playbook_ui 14.7.0.pre.rc.17 → 14.7.0.pre.rc.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -1
  3. data/app/pb_kits/playbook/pb_card/_card.tsx +11 -4
  4. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -1
  5. data/app/pb_kits/playbook/pb_flex/_flex.tsx +3 -1
  6. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +8 -2
  7. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +3 -6
  8. data/app/pb_kits/playbook/pb_flex/flex_item.rb +7 -2
  9. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  10. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss +37 -0
  11. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx +67 -0
  12. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss +40 -0
  13. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx +51 -0
  14. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md +1 -0
  15. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx +26 -0
  16. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md +1 -0
  17. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb +1 -0
  18. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx +11 -0
  19. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +59 -0
  20. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md +3 -0
  21. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx +20 -0
  22. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +3 -0
  23. data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +13 -0
  24. data/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js +5 -0
  25. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb +12 -0
  26. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb +8 -0
  27. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx +81 -0
  28. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +3 -0
  29. data/app/pb_kits/playbook/utilities/globalProps.ts +39 -2
  30. data/dist/chunks/_typeahead-DhLic2Fe.js +22 -0
  31. data/dist/chunks/_weekday_stacked-Mx8TYP5I.js +45 -0
  32. data/dist/chunks/vendor.js +1 -1
  33. data/dist/menu.yml +4 -1
  34. data/dist/playbook-doc.js +1 -1
  35. data/dist/playbook-rails-react-bindings.js +1 -1
  36. data/dist/playbook-rails.js +1 -1
  37. data/dist/playbook.css +1 -1
  38. data/lib/playbook/kit_base.rb +43 -5
  39. data/lib/playbook/version.rb +1 -1
  40. metadata +22 -4
  41. data/dist/chunks/_typeahead-5m7Pr_Rh.js +0 -22
  42. data/dist/chunks/_weekday_stacked-B4YQ6Z-d.js +0 -45
@@ -0,0 +1,81 @@
1
+ import React from 'react'
2
+ import { render, screen } from '@testing-library/react'
3
+ import { ensureAccessible } from '../utilities/test-utils'
4
+ import { SkeletonLoading } from 'playbook-ui'
5
+
6
+ /* See these resources for more testing info:
7
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
8
+ - https://jestjs.io/docs/en/using-matchers
9
+ */
10
+
11
+ describe('SkeletonLoading', () => {
12
+ const defaultProps = {
13
+ data: { testid: 'skeleton-loading' }
14
+ }
15
+
16
+ it('should be accessible', async () => {
17
+ ensureAccessible(SkeletonLoading, defaultProps)
18
+ })
19
+
20
+ it('renders with default props', () => {
21
+ const { container } = render(<SkeletonLoading {...defaultProps} />)
22
+ const skeleton = screen.getByTestId('skeleton-loading')
23
+
24
+ expect(skeleton).toBeInTheDocument()
25
+ expect(skeleton).toHaveClass('pb_skeleton_loading')
26
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(1)
27
+ })
28
+
29
+ it('renders multiple skeleton items based on stack prop', () => {
30
+ const props = {
31
+ ...defaultProps,
32
+ stack: 3
33
+ }
34
+ const { container } = render(<SkeletonLoading {...props} />)
35
+
36
+ expect(container.querySelectorAll('div[class*="border_radius_"]')).toHaveLength(3)
37
+ })
38
+
39
+ it('applies custom styles correctly', () => {
40
+ const props = {
41
+ ...defaultProps,
42
+ height: '24px',
43
+ width: '50%',
44
+ borderRadius: 'lg',
45
+ color: 'light',
46
+ dark: true
47
+ }
48
+ const { container } = render(<SkeletonLoading {...props} />)
49
+ const skeletonItem = container.querySelector('div[class*="border_radius_"]')
50
+
51
+ expect(skeletonItem).toHaveClass('border_radius_lg')
52
+ expect(skeletonItem).toHaveClass('dark')
53
+ })
54
+
55
+ it('applies gap class to items after first one', () => {
56
+ const props = {
57
+ ...defaultProps,
58
+ stack: 3,
59
+ gap: 'md'
60
+ }
61
+ const { container } = render(<SkeletonLoading {...props} />)
62
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
63
+
64
+ expect(skeletonItems[0]).not.toHaveClass('gap_md')
65
+ expect(skeletonItems[1]).toHaveClass('gap_md')
66
+ expect(skeletonItems[2]).toHaveClass('gap_md')
67
+ })
68
+
69
+ it('handles no gap properly', () => {
70
+ const props = {
71
+ ...defaultProps,
72
+ stack: 2,
73
+ gap: 'none'
74
+ }
75
+ const { container } = render(<SkeletonLoading {...props} />)
76
+ const skeletonItems = container.querySelectorAll('div[class*="border_radius_"]')
77
+
78
+ expect(skeletonItems[0]).not.toHaveClass('gap_none')
79
+ expect(skeletonItems[1]).not.toHaveClass('gap_none')
80
+ })
81
+ })
@@ -1,4 +1,7 @@
1
1
  export default [
2
+ "minHeight",
3
+ "maxHeight",
4
+ "height",
2
5
  "left",
3
6
  "bottom",
4
7
  "right",
@@ -174,12 +174,24 @@ type ZIndex = {
174
174
  zIndex?: ZIndexType,
175
175
  } | ZIndexResponsiveType
176
176
 
177
+ type Height = {
178
+ height?: string
179
+ }
180
+
181
+ type MaxHeight = {
182
+ maxHeight?: string
183
+ }
184
+
185
+ type MinHeight = {
186
+ minHeight?: string
187
+ }
188
+
177
189
  // keep this as the last type definition
178
190
  export type GlobalProps = AlignContent & AlignItems & AlignSelf &
179
191
  BorderRadius & Cursor & Dark & Display & DisplaySizes & Flex & FlexDirection &
180
192
  FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
181
193
  LineHeight & Margin & MinWidth & MaxWidth & NumberSpacing & Order & Overflow & Padding &
182
- Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & GroupHover & { hover?: string } & Top & Right & Bottom & Left;
194
+ Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & { hover?: string } & Top & Right & Bottom & Left & Height & MaxHeight & MinHeight;
183
195
 
184
196
  const getResponsivePropClasses = (prop: {[key: string]: string}, classPrefix: string) => {
185
197
  const keys: string[] = Object.keys(prop)
@@ -503,7 +515,22 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
503
515
  } else {
504
516
  return verticalAlign ? `vertical_align_${verticalAlign} ` : ''
505
517
  }
506
- }
518
+ },
519
+
520
+ }
521
+
522
+ const PROP_INLINE_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => {[key: string]: any}} = {
523
+ heightProps: ({ height }: Height) => {
524
+ return height ? { height } : {};
525
+ },
526
+
527
+ maxHeightProps: ({ maxHeight }: MaxHeight) => {
528
+ return maxHeight ? { maxHeight } : {};
529
+ },
530
+
531
+ minHeightProps: ({ minHeight }: MinHeight) => {
532
+ return minHeight ? { minHeight } : {};
533
+ },
507
534
  }
508
535
 
509
536
  type DefaultProps = {[key: string]: string} | Record<string, unknown>
@@ -515,6 +542,16 @@ export const globalProps = (props: GlobalProps, defaultProps: DefaultProps = {})
515
542
  }).filter((value) => value?.length > 0).join(" ")
516
543
  }
517
544
 
545
+ // New function for inline styles
546
+ export const globalInlineProps = (props: GlobalProps): React.CSSProperties => {
547
+ const styles = Object.keys(PROP_INLINE_CATEGORIES).reduce((acc, key) => {
548
+ const result = PROP_INLINE_CATEGORIES[key](props);
549
+ return { ...acc, ...(typeof result === 'object' ? result : {}) }; // Ensure result is an object before spreading
550
+ }, {});
551
+
552
+ return styles; // Return the styles object directly
553
+ }
554
+
518
555
 
519
556
  export const deprecatedProps = (): void => {
520
557
  // if (process.env.NODE_ENV === 'development') {