playbook_ui 10.26.0.pre.alpha1 → 10.26.0.pre.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/data/menu.yml +0 -1
  3. data/app/pb_kits/playbook/index.js +1 -2
  4. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +3 -3
  5. data/app/pb_kits/playbook/pb_body/_body.tsx +8 -8
  6. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +0 -1
  7. data/app/pb_kits/playbook/pb_caption/{_caption.tsx → _caption.jsx} +8 -7
  8. data/app/pb_kits/playbook/pb_card/_card.jsx +3 -1
  9. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -0
  10. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +0 -37
  11. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +0 -37
  12. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
  14. data/app/pb_kits/playbook/pb_kit/dateTime.js +2 -1
  15. data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
  16. data/app/pb_kits/playbook/pb_table/_table.jsx +3 -0
  17. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +83 -0
  18. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +94 -0
  19. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +3 -0
  20. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  23. data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +21 -0
  24. data/app/pb_kits/playbook/pb_table/table.rb +7 -1
  25. data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
  26. data/app/pb_kits/playbook/pb_title/{_title.tsx → _title.jsx} +12 -10
  27. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  28. data/app/pb_kits/playbook/playbook-doc.js +0 -2
  29. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +0 -2
  30. data/app/pb_kits/playbook/plugins/pb_chart.js +0 -34
  31. data/app/pb_kits/playbook/tokens/_display.scss +13 -0
  32. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +21 -5
  33. data/app/pb_kits/playbook/utilities/_display.scss +58 -1
  34. data/app/pb_kits/playbook/utilities/_flex_direction.scss +15 -28
  35. data/app/pb_kits/playbook/utilities/globalProps.ts +134 -103
  36. data/app/pb_kits/playbook/utilities/text.js +15 -0
  37. data/dist/reset.css +1 -60
  38. data/lib/playbook/display.rb +20 -6
  39. data/lib/playbook/flex_direction.rb +1 -7
  40. data/lib/playbook/version.rb +1 -1
  41. metadata +12 -27
  42. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +0 -79
  43. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +0 -5
  44. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +0 -37
  45. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +0 -48
  46. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +0 -2
  47. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +0 -37
  48. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +0 -47
  49. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +0 -3
  50. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +0 -79
  51. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +0 -90
  52. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +0 -1
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +0 -54
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +0 -65
  55. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +0 -3
  56. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +0 -37
  57. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +0 -48
  58. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +0 -3
  59. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +0 -15
  60. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +0 -5
  61. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +0 -1
  62. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +0 -43
  63. data/app/pb_kits/playbook/utilities/text.ts +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2189d1ada1c39446fecca8e67776e0e5b086e79d842fbfaf5ed800313c81f5df
4
- data.tar.gz: 4640c10e464c670714c67a3875412fcda9c79f06edbbea2a50cdd5ab330889ed
3
+ metadata.gz: eec4050a38ffdbc91288fa4d1ebe864edc0485bf814f1569b50a4df569e6c666
4
+ data.tar.gz: 5967691eccad475c60406d60b9aca79ee520a2736bfde034b48e6db8c1de3316
5
5
  SHA512:
6
- metadata.gz: 6d133f2ab6121d7f7a3895fe907a51f3713c48d1463a80cba165ae6c5fc6e1f64d6bf9ccb2b368f7f17304eee8e8a36a40c02a00b456044f4199e15c698e9d80
7
- data.tar.gz: 9515dbe37dab4c9d0a5a6e90c7074a3641ec9e31669b4fdd502e3b12e5ca6bf541ecf36eea0ec711c52710f3bd1cec017b3be76d68cb36b6e15aeb690c7185f9
6
+ metadata.gz: 8ea97fd90f89882ee7e54d80b46e468fa5beffa6ee2e9dc64475e14ebfe4cdcfef43dcf6b3dd0ab06db030da9fb04f4e35fae1e35dcba93a8009a80200d24fd5
7
+ data.tar.gz: edbf22cf4988bf3ddc4f7872dce6fe51041dd8a8a657bd8b118196fe42c8a0c06428fbc5a1efcec55525d6ae4b769279a3438b12ad174d2e52497b7610e2260d
@@ -20,7 +20,6 @@ kits:
20
20
  - gauge
21
21
  - legend
22
22
  - line_graph
23
- - treemap_chart
24
23
  - dialog
25
24
  - filter
26
25
  - fixed_confirmation_toast
@@ -4,6 +4,7 @@ import 'lazysizes/plugins/attrchange/ls.attrchange'
4
4
  import 'lazysizes'
5
5
 
6
6
  // vvv React Component JSX Imports from the React Kits vvv
7
+ export { default as Walkthrough } from './pb_walkthrough/_walkthrough'
7
8
  export { default as Avatar } from './pb_avatar/_avatar'
8
9
  export { default as AvatarActionButton } from './pb_avatar_action_button/_avatar_action_button'
9
10
  export { default as Background } from './pb_background/_background'
@@ -97,11 +98,9 @@ export { default as Title } from './pb_title/_title'
97
98
  export { default as TitleCount } from './pb_title_count/_title_count'
98
99
  export { default as TitleDetail } from './pb_title_detail/_title_detail'
99
100
  export { default as Toggle } from './pb_toggle/_toggle'
100
- export { default as TreemapChart } from './pb_treemap_chart/_treemap_chart'
101
101
  export { default as Typeahead } from './pb_typeahead/_typeahead'
102
102
  export { default as User } from './pb_user/_user'
103
103
  export { default as UserBadge } from './pb_user_badge/_user_badge'
104
- export { default as Walkthrough } from './pb_walkthrough/_walkthrough'
105
104
  export { default as WeekdayStacked } from './pb_weekday_stacked/_weekday_stacked'
106
105
  // ^^^ React Component JSX Imports from the React Kits ^^^
107
106
 
@@ -2,7 +2,7 @@ import React, { useState } from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Image from '../pb_image/_image'
8
8
  import OnlineStatus from '../pb_online_status/_online_status'
@@ -18,14 +18,14 @@ type AvatarProps = {
18
18
  name: string,
19
19
  size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
20
20
  status: "away" | "offline" | "online",
21
- }
21
+ } & GlobalProps
22
22
 
23
23
  const firstTwoInitials = (name: string) =>
24
24
  name.split(/\s/).map((name) => name[0])
25
25
  .join('')
26
26
  .substring(0, 2)
27
27
 
28
- const Avatar = (props: AvatarProps) => {
28
+ const Avatar = (props: AvatarProps): React.ReactElement => {
29
29
  const {
30
30
  aria = {},
31
31
  className,
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Highlight from '../pb_highlight/_highlight'
8
8
 
@@ -20,7 +20,7 @@ type BodyProps = {
20
20
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
21
21
  text?: string,
22
22
  variant: null | 'link',
23
- }
23
+ } & GlobalProps
24
24
 
25
25
  const Body = (props: BodyProps): React.ReactElement => {
26
26
  const {
@@ -56,12 +56,12 @@ const Body = (props: BodyProps): React.ReactElement => {
56
56
  id={id}
57
57
  >
58
58
  { highlighting && (
59
- <Highlight
60
- highlightedText={highlightedText}
61
- text={text}
62
- >
63
- {children}
64
- </Highlight>
59
+ <Highlight
60
+ highlightedText={highlightedText}
61
+ text={text}
62
+ >
63
+ {children}
64
+ </Highlight>
65
65
  ) }
66
66
  { !highlighting && (
67
67
  text || children
@@ -2,4 +2,3 @@
2
2
  <%= pb_rails("button", props: { text: "Button Secondary", variant: "secondary" }) %>
3
3
  <%= pb_rails("button", props: { text: "Button Link", variant: "link" }) %>
4
4
  <%= pb_rails("button", props: { text: "Button Disabled", disabled: true }) %>
5
-
@@ -1,22 +1,24 @@
1
+ /* @flow */
2
+
1
3
  import React from 'react'
2
4
  import classnames from 'classnames'
3
5
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
- import { deprecatedProps, globalProps, GlobalProps } from '../utilities/globalProps'
6
+ import { deprecatedProps, globalProps } from '../utilities/globalProps'
5
7
 
6
8
  type CaptionProps = {
7
- aria?: {[key: string]: string},
8
- children: React.ReactChild[],
9
+ aria?: object,
10
+ children: array<React.ReactNode> | React.ReactNode,
9
11
  className?: string,
10
12
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
11
- data?: {[key: string]: string},
13
+ data?: object,
12
14
  id?: string,
13
15
  size?: "xs" | "sm" | "md" | "lg" | "xl",
14
16
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "caption",
15
17
  text?: string,
16
18
  variant?: null | "link",
17
- } & GlobalProps;
19
+ };
18
20
 
19
- const Caption = (props: CaptionProps): React.ReactElement => {
21
+ const Caption = (props: CaptionProps) => {
20
22
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
21
23
  const {
22
24
  aria = {},
@@ -30,7 +32,6 @@ const Caption = (props: CaptionProps): React.ReactElement => {
30
32
  text,
31
33
  variant = null,
32
34
  } = props
33
-
34
35
  const tagOptions = [
35
36
  'h1',
36
37
  'h2',
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  /* @flow */
2
3
 
3
4
  import React from 'react'
@@ -29,7 +30,7 @@ type CardHeaderProps = {
29
30
  headerColor?: BackgroundColors | ProductColors | CategoryColors | "none",
30
31
  children: array<React.ReactNode> | React.ReactNode,
31
32
  className?: string,
32
- padding?: string,
33
+ padding?: string
33
34
  }
34
35
 
35
36
  type CardBodyProps = {
@@ -56,6 +57,7 @@ const Header = (props: CardHeaderProps) => {
56
57
  const Body = (props: CardBodyProps) => {
57
58
  const { children, padding = 'md', className } = props
58
59
  const bodyCSS = buildCss('pb_card_body_kit')
60
+
59
61
  const bodySpacing = globalProps(props, { padding })
60
62
 
61
63
  return (
@@ -4,6 +4,7 @@
4
4
  @import "../tokens/colors";
5
5
  @import "../tokens/transition";
6
6
  @import "../tokens/animation-curves";
7
+ @import "../tokens/display";
7
8
 
8
9
  $pb_card_border_width: 1px;
9
10
  $pb_card_border_radius: $border_rad_heavier;
@@ -209,43 +209,6 @@ const highchartsDarkTheme = {
209
209
  threshold: null,
210
210
  },
211
211
  },
212
-
213
- //TREEMAP CHART STYLES
214
- treemap: {
215
- layoutAlgorithm: "squarified",
216
- allowTraversingTree: false,
217
- animationLimit: 1000,
218
- colors: [
219
- colors.data_1,
220
- colors.data_2,
221
- colors.data_3,
222
- colors.data_4,
223
- colors.data_5,
224
- colors.data_6,
225
- colors.data_7,
226
- colors.data_8,
227
- ],
228
- colorByPoint: true,
229
- dataLabels: {
230
- enabled: true,
231
- style: {
232
- fontFamily: typography.font_family_base,
233
- fontWeight: typography.bold,
234
- fontSize: typography.heading_4,
235
- },
236
- },
237
- levels: [
238
- {
239
- level: 1,
240
- dataLabels: {
241
- enabled: false,
242
- },
243
- },
244
- ],
245
- traverseUpButton: {
246
- position: { y: -40 },
247
- }
248
- },
249
212
  },
250
213
  }
251
214
 
@@ -209,43 +209,6 @@ const highchartsTheme = {
209
209
  threshold: null,
210
210
  },
211
211
  },
212
-
213
- //TREEMAP CHART STYLES
214
- treemap: {
215
- layoutAlgorithm: "squarified",
216
- allowTraversingTree: false,
217
- animationLimit: 1000,
218
- colors: [
219
- colors.data_1,
220
- colors.data_2,
221
- colors.data_3,
222
- colors.data_4,
223
- colors.data_5,
224
- colors.data_6,
225
- colors.data_7,
226
- colors.data_8,
227
- ],
228
- colorByPoint: true,
229
- dataLabels: {
230
- enabled: true,
231
- style: {
232
- fontFamily: typography.font_family_base,
233
- fontWeight: typography.bold,
234
- fontSize: typography.heading_4,
235
- },
236
- },
237
- levels: [
238
- {
239
- level: 1,
240
- dataLabels: {
241
- enabled: false,
242
- },
243
- },
244
- ],
245
- traverseUpButton: {
246
- position: { y: -40 },
247
- }
248
- },
249
212
  },
250
213
  }
251
214
 
@@ -1,7 +1,7 @@
1
1
  /* @flow */
2
2
  import React from 'react'
3
3
  import classnames from 'classnames'
4
- import Title from '../pb_title/_title'
4
+ import Title from '../pb_title/_title.jsx'
5
5
  import Icon from '../pb_icon/_icon.jsx'
6
6
  import Avatar from '../pb_avatar/_avatar'
7
7
  import { globalProps } from '../utilities/globalProps'
@@ -16,7 +16,7 @@ type ImageType = {
16
16
  url?: string,
17
17
  } & GlobalProps
18
18
 
19
- const Image = (props: ImageType) => {
19
+ const Image = (props: ImageType): React.ReactElement => {
20
20
  const {
21
21
  alt = '',
22
22
  aria = {},
@@ -1,8 +1,9 @@
1
1
  /* @flow */
2
2
  /*eslint-disable flowtype/space-before-type-colon */
3
3
 
4
- import moment from 'moment-timezone'
4
+ import moment from 'moment'
5
5
  import 'moment-strftime'
6
+ import 'moment-timezone'
6
7
 
7
8
  type DateTimeType = {
8
9
  value: String | Date,
@@ -3,7 +3,7 @@
3
3
  import React from 'react'
4
4
 
5
5
  import classnames from 'classnames'
6
- import Title from '../pb_title/_title'
6
+ import Title from '../pb_title/_title.jsx'
7
7
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
8
8
  import { globalProps } from '../utilities/globalProps'
9
9
 
@@ -20,6 +20,7 @@ type TableProps = {
20
20
  responsive: "collapse" | "scroll" | "none",
21
21
  singleLine: boolean,
22
22
  size: "sm" | "md" | "lg",
23
+ sticky?: boolean,
23
24
  }
24
25
 
25
26
  const Table = (props: TableProps) => {
@@ -37,6 +38,7 @@ const Table = (props: TableProps) => {
37
38
  responsive = 'collapse',
38
39
  singleLine = false,
39
40
  size = 'sm',
41
+ sticky = false,
40
42
  } = props
41
43
 
42
44
  const ariaProps = buildAriaProps(aria)
@@ -60,6 +62,7 @@ const Table = (props: TableProps) => {
60
62
  'data_table': dataTable,
61
63
  'single-line': singleLine,
62
64
  'no-hover': disableHover,
65
+ 'sticky-header': sticky,
63
66
  },
64
67
  globalProps(props),
65
68
  tableCollapseCss,
@@ -0,0 +1,83 @@
1
+ <%= pb_rails("table", props: { sticky: true }) do %>
2
+ <thead>
3
+ <tr>
4
+ <th>Column 1</th>
5
+ <th>Column 2</th>
6
+ <th>Column 3</th>
7
+ <th>Column 4</th>
8
+ <th>Column 5</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <tr>
13
+ <td>Value 1</td>
14
+ <td>Value 2</td>
15
+ <td>Value 3</td>
16
+ <td>Value 4</td>
17
+ <td>Value 5</td>
18
+ </tr>
19
+ <tr>
20
+ <td>Value 1</td>
21
+ <td>Value 2</td>
22
+ <td>Value 3</td>
23
+ <td>Value 4</td>
24
+ <td>Value 5</td>
25
+ </tr>
26
+ <tr>
27
+ <td>Value 1</td>
28
+ <td>Value 2</td>
29
+ <td>Value 3</td>
30
+ <td>Value 4</td>
31
+ <td>Value 5</td>
32
+ </tr>
33
+ <tr>
34
+ <td>Value 1</td>
35
+ <td>Value 2</td>
36
+ <td>Value 3</td>
37
+ <td>Value 4</td>
38
+ <td>Value 5</td>
39
+ </tr>
40
+ <tr>
41
+ <td>Value 1</td>
42
+ <td>Value 2</td>
43
+ <td>Value 3</td>
44
+ <td>Value 4</td>
45
+ <td>Value 5</td>
46
+ </tr>
47
+ <tr>
48
+ <td>Value 1</td>
49
+ <td>Value 2</td>
50
+ <td>Value 3</td>
51
+ <td>Value 4</td>
52
+ <td>Value 5</td>
53
+ </tr>
54
+ <tr>
55
+ <td>Value 1</td>
56
+ <td>Value 2</td>
57
+ <td>Value 3</td>
58
+ <td>Value 4</td>
59
+ <td>Value 5</td>
60
+ </tr>
61
+ <tr>
62
+ <td>Value 1</td>
63
+ <td>Value 2</td>
64
+ <td>Value 3</td>
65
+ <td>Value 4</td>
66
+ <td>Value 5</td>
67
+ </tr>
68
+ <tr>
69
+ <td>Value 1</td>
70
+ <td>Value 2</td>
71
+ <td>Value 3</td>
72
+ <td>Value 4</td>
73
+ <td>Value 5</td>
74
+ </tr>
75
+ <tr>
76
+ <td>Value 1</td>
77
+ <td>Value 2</td>
78
+ <td>Value 3</td>
79
+ <td>Value 4</td>
80
+ <td>Value 5</td>
81
+ </tr>
82
+ </tbody>
83
+ <% end %>
@@ -0,0 +1,94 @@
1
+ import React from "react"
2
+
3
+ import Table from "../_table"
4
+
5
+ const TableSticky = (props) => (
6
+ <Table
7
+ sticky
8
+ {...props}
9
+ >
10
+ <thead>
11
+ <tr>
12
+ <th>{'Column 1'}</th>
13
+ <th>{'Column 2'}</th>
14
+ <th>{'Column 3'}</th>
15
+ <th>{'Column 4'}</th>
16
+ <th>{'Column 5'}</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <tr>
21
+ <td>{'Value 1'}</td>
22
+ <td>{'Value 2'}</td>
23
+ <td>{'Value 3'}</td>
24
+ <td>{'Value 4'}</td>
25
+ <td>{'Value 5'}</td>
26
+ </tr>
27
+ <tr>
28
+ <td>{'Value 1'}</td>
29
+ <td>{'Value 2'}</td>
30
+ <td>{'Value 3'}</td>
31
+ <td>{'Value 4'}</td>
32
+ <td>{'Value 5'}</td>
33
+ </tr>
34
+ <tr>
35
+ <td>{'Value 1'}</td>
36
+ <td>{'Value 2'}</td>
37
+ <td>{'Value 3'}</td>
38
+ <td>{'Value 4'}</td>
39
+ <td>{'Value 5'}</td>
40
+ </tr>
41
+ <tr>
42
+ <td>{'Value 1'}</td>
43
+ <td>{'Value 2'}</td>
44
+ <td>{'Value 3'}</td>
45
+ <td>{'Value 4'}</td>
46
+ <td>{'Value 5'}</td>
47
+ </tr>
48
+ <tr>
49
+ <td>{'Value 1'}</td>
50
+ <td>{'Value 2'}</td>
51
+ <td>{'Value 3'}</td>
52
+ <td>{'Value 4'}</td>
53
+ <td>{'Value 5'}</td>
54
+ </tr>
55
+ <tr>
56
+ <td>{'Value 1'}</td>
57
+ <td>{'Value 2'}</td>
58
+ <td>{'Value 3'}</td>
59
+ <td>{'Value 4'}</td>
60
+ <td>{'Value 5'}</td>
61
+ </tr>
62
+ <tr>
63
+ <td>{'Value 1'}</td>
64
+ <td>{'Value 2'}</td>
65
+ <td>{'Value 3'}</td>
66
+ <td>{'Value 4'}</td>
67
+ <td>{'Value 5'}</td>
68
+ </tr>
69
+ <tr>
70
+ <td>{'Value 1'}</td>
71
+ <td>{'Value 2'}</td>
72
+ <td>{'Value 3'}</td>
73
+ <td>{'Value 4'}</td>
74
+ <td>{'Value 5'}</td>
75
+ </tr>
76
+ <tr>
77
+ <td>{'Value 1'}</td>
78
+ <td>{'Value 2'}</td>
79
+ <td>{'Value 3'}</td>
80
+ <td>{'Value 4'}</td>
81
+ <td>{'Value 5'}</td>
82
+ </tr>
83
+ <tr>
84
+ <td>{'Value 1'}</td>
85
+ <td>{'Value 2'}</td>
86
+ <td>{'Value 3'}</td>
87
+ <td>{'Value 4'}</td>
88
+ <td>{'Value 5'}</td>
89
+ </tr>
90
+ </tbody>
91
+ </Table>
92
+ )
93
+
94
+ export default TableSticky
@@ -0,0 +1,3 @@
1
+ React: Use `sticky` on a table to allow the table header to be fixed in place when the user scrolls up and down on the page.
2
+
3
+ Rails: Pass `sticky: true` to props.
@@ -3,6 +3,7 @@ examples:
3
3
  - table_sm: Small
4
4
  - table_md: Medium
5
5
  - table_lg: Large
6
+ - table_sticky: Sticky Header
6
7
  - table_alignment_row: Row Alignment
7
8
  - table_alignment_column: Column Alignment
8
9
  - table_alignment_shift_row: Shift Row
@@ -25,6 +26,7 @@ examples:
25
26
  - table_sm: Small
26
27
  - table_md: Medium
27
28
  - table_lg: Large
29
+ - table_sticky: Sticky Header
28
30
  - table_alignment_row: Row Alignment
29
31
  - table_alignment_column: Column Alignment
30
32
  - table_alignment_shift_row: Shift Row
@@ -1,6 +1,7 @@
1
1
  export { default as TableSm } from './_table_sm.jsx'
2
2
  export { default as TableMd } from './_table_md.jsx'
3
3
  export { default as TableLg } from './_table_lg.jsx'
4
+ export { default as TableSticky } from './_table_sticky.jsx'
4
5
  export { default as TableSideHighlight } from './_table_side_highlight.jsx'
5
6
  export { default as TableContainer } from './_table_container.jsx'
6
7
  export { default as TableDataTable } from './_table_data_table.jsx'
@@ -16,3 +16,4 @@
16
16
  @import "mobile_collapse";
17
17
  @import "tablet_collapse";
18
18
  @import "desktop_collapse";
19
+ @import "sticky_header";
@@ -0,0 +1,21 @@
1
+ @import "../../tokens/colors";
2
+
3
+ [class^="pb_table"] {
4
+ &.sticky-header {
5
+ thead {
6
+ position: sticky;
7
+ background: $white;
8
+ top: -40px;
9
+ }
10
+ }
11
+
12
+ &.dark {
13
+ &.sticky-header {
14
+ thead {
15
+ position: sticky;
16
+ background: #0a0527;
17
+ top: -40px;
18
+ }
19
+ }
20
+ }
21
+ }
@@ -21,11 +21,13 @@ module Playbook
21
21
  values: %w[sm md lg],
22
22
  default: "sm"
23
23
  prop :text
24
+ prop :sticky, type: Playbook::Props::Boolean,
25
+ default: false
24
26
 
25
27
  def classname
26
28
  generate_classname(
27
29
  "pb_table", "table-#{size}", single_line_class, dark_class,
28
- disable_hover_class, container_class, data_table_class, collapse_class,
30
+ disable_hover_class, container_class, data_table_class, sticky_class, collapse_class,
29
31
  "table-responsive-#{responsive}", separator: " "
30
32
  )
31
33
  end
@@ -55,6 +57,10 @@ module Playbook
55
57
  def collapse_class
56
58
  responsive != "none" ? "table-collapse-#{collapse}" : ""
57
59
  end
60
+
61
+ def sticky_class
62
+ sticky ? "sticky-header" : nil
63
+ end
58
64
  end
59
65
  end
60
66
  end
@@ -0,0 +1,17 @@
1
+ import { ensureAccessible, renderKit } from "../utilities/test-utils"
2
+
3
+ import Table from "./_table"
4
+
5
+ const props = {
6
+ data: { testid: "table" },
7
+ sticky: false
8
+ }
9
+
10
+ it("should be accessible", async () => {
11
+ ensureAccessible(Table, props)
12
+ })
13
+
14
+ test("when sticky is true", () => {
15
+ const kit = renderKit(Table, props, { sticky: true })
16
+ expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card sticky-header table-collapse-sm")
17
+ })
@@ -1,22 +1,24 @@
1
+ /* @flow */
2
+
1
3
  import React from 'react'
2
4
  import classnames from 'classnames'
3
5
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
4
- import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalProps'
6
+ import { deprecatedProps, globalProps } from '../utilities/globalProps'
5
7
 
6
8
  type TitleProps = {
7
- aria?: {[key: string]: string},
8
- children?: React.ReactChild[],
9
+ aria?: object,
10
+ children?: array<React.ReactNode> | React.ReactNode,
9
11
  className?: string,
10
12
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
11
- data?: {[key: string]: string},
13
+ data?: object,
12
14
  id?: string,
13
15
  size?: 1 | 2 | 3 | 4,
14
16
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
15
17
  text?: string,
16
18
  variant?: null | "link",
17
- } & GlobalProps
19
+ }
18
20
 
19
- const Title = (props: TitleProps): React.ReactElement => {
21
+ const Title = (props: TitleProps) => {
20
22
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
21
23
  const {
22
24
  aria = {},
@@ -31,14 +33,14 @@ const Title = (props: TitleProps): React.ReactElement => {
31
33
  variant = null,
32
34
  } = props
33
35
 
34
- const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
35
- const dataProps: {[key: string]: string | number} = buildDataProps(data)
36
+ const ariaProps = buildAriaProps(aria)
37
+ const dataProps = buildDataProps(data)
36
38
  const classes = classnames(
37
- buildCss('pb_title_kit', `size_${size}`, variant, color),
39
+ buildCss('pb_title_kit', size, variant, color),
38
40
  globalProps(props),
39
41
  className,
40
42
  )
41
- const Tag: React.ReactElement | any = `${tag}`
43
+ const Tag = `${tag}`
42
44
 
43
45
  return (
44
46
  <Tag