playbook_ui 10.26.0.pre.alpha.display1 → 10.26.0.pre.alpha.sticky1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) 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_caption/{_caption.tsx → _caption.jsx} +8 -7
  7. data/app/pb_kits/playbook/pb_card/_card.jsx +1 -3
  8. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +0 -1
  9. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +0 -37
  10. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.js +0 -37
  11. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +1 -1
  12. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -1
  13. data/app/pb_kits/playbook/pb_kit/dateTime.js +2 -1
  14. data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_table/_table.jsx +3 -0
  16. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +83 -0
  17. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +94 -0
  18. data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +10 -0
  19. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  20. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  22. data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +23 -0
  23. data/app/pb_kits/playbook/pb_table/table.rb +7 -1
  24. data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
  25. data/app/pb_kits/playbook/pb_title/{_title.tsx → _title.jsx} +12 -10
  26. data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
  27. data/app/pb_kits/playbook/playbook-doc.js +0 -2
  28. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +0 -2
  29. data/app/pb_kits/playbook/plugins/pb_chart.js +0 -34
  30. data/app/pb_kits/playbook/tokens/_screen_sizes.scss +5 -21
  31. data/app/pb_kits/playbook/utilities/_display.scss +2 -60
  32. data/app/pb_kits/playbook/utilities/globalProps.ts +16 -31
  33. data/lib/playbook/display.rb +7 -21
  34. data/lib/playbook/version.rb +1 -1
  35. metadata +10 -27
  36. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +0 -79
  37. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +0 -5
  38. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +0 -37
  39. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +0 -48
  40. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +0 -2
  41. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +0 -37
  42. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +0 -47
  43. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +0 -3
  44. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +0 -79
  45. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +0 -90
  46. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +0 -1
  47. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +0 -54
  48. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +0 -65
  49. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +0 -3
  50. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +0 -37
  51. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +0 -48
  52. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +0 -3
  53. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +0 -15
  54. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +0 -5
  55. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +0 -1
  56. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +0 -43
  57. data/app/pb_kits/playbook/tokens/_display.scss +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4f47a9244130b0b201a8a8bfff26b8cda3de6efd934e0cbe2094c4a4a26bf56
4
- data.tar.gz: 9c4edb754d6fae9fbef2c6d6511f5e75cfb7972c0981eaef7c6e1cdba514d87f
3
+ metadata.gz: cf78ed906a18245b33919539767b4548820b23c2e88196f790cc4cc3c928dde4
4
+ data.tar.gz: f4619a7704a66989d2dbc5221d904e0fe3bec27d6908ea8349247de683fc68b2
5
5
  SHA512:
6
- metadata.gz: d8a99fee564a9f31533369b6ee239271b919aca58a965bf50c94fa6ad962e2e363454a3653404157848649269e3556da7cd79a73eaa4454ee38781f121af0beb
7
- data.tar.gz: e41bcf582fc5d536d489dd09a841c896bf69bdd4f0efbe8500ac9f63fa0a0fa39f7082450a9c25cfbe5cd70d323563af877ef02ad0f8c999f1b32646650c0586
6
+ metadata.gz: 27b1b9f29f502c1fb95cb03b6bd623ecd0a0c90cb3aad20b95fb687c9048f37c3a3e7737f27d14f54719f1dd0afa3455cfc46f2fdd0470e70b1879db59cdb615
7
+ data.tar.gz: 9d7a07450758941dc3c1427723d94508bfef0a9db8ebc227d5ad12af04556fc4fe2a5d0aaa12d7f273bcd3658b8c2733581b24ca4dba3ac4fed359fb2965ef56
@@ -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, GlobalProps } from '../utilities/globalProps'
5
+ import { 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
- } & GlobalProps
21
+ }
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): React.ReactElement => {
28
+ const Avatar = (props: AvatarProps) => {
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, GlobalProps } from '../utilities/globalProps'
5
+ import { 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
- } & GlobalProps
23
+ }
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
@@ -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,4 +1,3 @@
1
- /* eslint-disable react/no-multi-comp */
2
1
  /* @flow */
3
2
 
4
3
  import React from 'react'
@@ -30,7 +29,7 @@ type CardHeaderProps = {
30
29
  headerColor?: BackgroundColors | ProductColors | CategoryColors | "none",
31
30
  children: array<React.ReactNode> | React.ReactNode,
32
31
  className?: string,
33
- padding?: string
32
+ padding?: string,
34
33
  }
35
34
 
36
35
  type CardBodyProps = {
@@ -57,7 +56,6 @@ const Header = (props: CardHeaderProps) => {
57
56
  const Body = (props: CardBodyProps) => {
58
57
  const { children, padding = 'md', className } = props
59
58
  const bodyCSS = buildCss('pb_card_body_kit')
60
-
61
59
  const bodySpacing = globalProps(props, { padding })
62
60
 
63
61
  return (
@@ -4,7 +4,6 @@
4
4
  @import "../tokens/colors";
5
5
  @import "../tokens/transition";
6
6
  @import "../tokens/animation-curves";
7
- @import "../tokens/display";
8
7
 
9
8
  $pb_card_border_width: 1px;
10
9
  $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): React.ReactElement => {
19
+ const Image = (props: ImageType) => {
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,10 @@
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.
4
+
5
+ If the table header is not sticking in the right place you will need to pass a inline `top` style to the `thead`.
6
+ React Example: `<thead style={{ top: "-16px" }}>`
7
+ Rails Example: `<thead style="top: -16px">`
8
+
9
+ ### Troubleshooting CSS Problems
10
+ Sticky may not work if any parent/ancestor of the sticky element has any of the `overflow` properties set. Additionally, specifying a height on the overflowing container provides measurement for this feature to work properly. In some cases, it may be necessary to set the same parent/ancestor container to `position: static` as well.
@@ -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,23 @@
1
+ @import "../../tokens/colors";
2
+
3
+ [class^="pb_table"] {
4
+ &.sticky-header {
5
+ thead {
6
+ background: $white;
7
+ position: sticky;
8
+ top: 0;
9
+ z-index: 1;
10
+ }
11
+ }
12
+
13
+ &.dark {
14
+ &.sticky-header {
15
+ thead {
16
+ background: $bg_dark;
17
+ position: sticky;
18
+ top: 0;
19
+ z-index: 1;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -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