playbook_ui 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/playbook/application_controller.rb +1 -0
  3. data/app/controllers/playbook/pages_controller.rb +0 -4
  4. data/app/controllers/playbook/samples_controller.rb +40 -0
  5. data/app/helpers/playbook/pb_doc_helper.rb +7 -1
  6. data/app/helpers/playbook/pb_sample_helper.rb +19 -0
  7. data/app/helpers/playbook/redcarpet_helper.rb +1 -1
  8. data/app/pb_kits/playbook/_playbook.scss +1 -0
  9. data/app/pb_kits/playbook/config/_kit_samples_list.html.erb +3 -0
  10. data/app/pb_kits/playbook/config/_kit_ui.html.slim +9 -5
  11. data/app/pb_kits/playbook/data/menu.yml +4 -0
  12. data/app/pb_kits/playbook/index.js +2 -0
  13. data/app/pb_kits/playbook/kits/pb_flex.js +4 -0
  14. data/app/pb_kits/playbook/kits/pb_highlight.js +4 -0
  15. data/app/pb_kits/playbook/packs/examples.js +4 -0
  16. data/app/pb_kits/playbook/packs/kits/pb_highlight.js +2 -0
  17. data/app/pb_kits/playbook/packs/kits/pb_popover.js +1 -0
  18. data/app/pb_kits/playbook/packs/main.scss +3 -0
  19. data/app/pb_kits/playbook/packs/samples.js +50 -0
  20. data/app/pb_kits/playbook/packs/site_styles/_samples.scss +71 -0
  21. data/app/pb_kits/playbook/packs/site_styles/_site-style.scss +6 -0
  22. data/app/pb_kits/playbook/packs/site_styles/docs/_flex_examples.scss +11 -3
  23. data/app/pb_kits/playbook/pb_body/_body.html.erb +1 -1
  24. data/app/pb_kits/playbook/pb_body/_body.jsx +10 -1
  25. data/app/pb_kits/playbook/pb_body/body.rb +17 -1
  26. data/app/pb_kits/playbook/pb_editor/_editor.html.erb +6 -0
  27. data/app/pb_kits/playbook/pb_hashtag/_hashtag.jsx +2 -1
  28. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_dark.html.erb +4 -0
  29. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_dark.jsx +7 -0
  30. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_default.html.erb +4 -0
  31. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_default.jsx +6 -0
  32. data/app/pb_kits/playbook/pb_hashtag/hashtag.rb +3 -1
  33. data/app/pb_kits/playbook/pb_highlight/_highlight.html.erb +6 -0
  34. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +38 -0
  35. data/app/pb_kits/playbook/pb_highlight/_highlight.scss +6 -0
  36. data/app/pb_kits/playbook/pb_highlight/docs/_highlight_default.html.erb +20 -0
  37. data/app/pb_kits/playbook/pb_highlight/docs/_highlight_default.jsx +26 -0
  38. data/app/pb_kits/playbook/pb_highlight/docs/example.yml +9 -0
  39. data/app/pb_kits/playbook/pb_highlight/docs/index.js +1 -0
  40. data/app/pb_kits/playbook/pb_highlight/highlight.rb +17 -0
  41. data/app/pb_kits/playbook/pb_popover/_popover.html.erb +1 -1
  42. data/app/pb_kits/playbook/pb_popover/_popover.js +13 -22
  43. data/app/pb_kits/playbook/pb_popover/_popover.jsx +121 -0
  44. data/app/pb_kits/playbook/pb_popover/_popover.scss +4 -0
  45. data/app/pb_kits/playbook/pb_popover/docs/_popover_default.jsx +29 -0
  46. data/app/pb_kits/playbook/pb_popover/docs/_popover_list.jsx +46 -0
  47. data/app/pb_kits/playbook/pb_popover/docs/_popover_portal.jsx +36 -0
  48. data/app/pb_kits/playbook/pb_popover/docs/_popover_with_button.jsx +35 -0
  49. data/app/pb_kits/playbook/pb_popover/docs/example.yml +4 -0
  50. data/app/pb_kits/playbook/pb_popover/docs/index.js +4 -0
  51. data/app/pb_kits/playbook/pb_popover/popover.rb +1 -1
  52. data/app/pb_kits/playbook/pb_select/_select.jsx +51 -51
  53. data/app/pb_kits/playbook/pb_select/docs/_select_blank.jsx +8 -14
  54. data/app/pb_kits/playbook/pb_select/docs/_select_dark.jsx +17 -15
  55. data/app/pb_kits/playbook/pb_select/docs/_select_dark_error.jsx +17 -15
  56. data/app/pb_kits/playbook/pb_select/docs/_select_default.jsx +16 -15
  57. data/app/pb_kits/playbook/pb_select/docs/_select_disabled.jsx +8 -14
  58. data/app/pb_kits/playbook/pb_select/docs/_select_disabled_options.jsx +31 -29
  59. data/app/pb_kits/playbook/pb_select/docs/_select_error.jsx +17 -15
  60. data/app/pb_kits/playbook/pb_select/docs/_select_required.jsx +7 -11
  61. data/app/pb_kits/playbook/pb_select/docs/_select_value_text_same.jsx +8 -14
  62. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.jsx +2 -2
  63. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +2 -2
  64. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +3 -3
  65. data/app/pb_kits/playbook/types.js +1 -1
  66. data/app/pb_kits/playbook/vendor.js +2 -2
  67. data/app/views/layouts/playbook/samples.html.erb +37 -0
  68. data/app/views/playbook/pages/kit_show.html.slim +1 -1
  69. data/app/views/playbook/pages/principles.html.slim +1 -1
  70. data/app/views/playbook/samples/dashboards/dashboards.html.erb +82 -0
  71. data/app/views/playbook/samples/dashboards/dashboards.jsx +35 -0
  72. data/app/views/playbook/samples/sample_show.html.erb +25 -0
  73. data/lib/playbook/version.rb +1 -1
  74. metadata +32 -5
  75. data/app/pb_kits/playbook/config/_kit_example.html.slim +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1f5453ef495f16a0c7abae04bef14015972c62ac815cd6b2c95e8b3d628bd67
4
- data.tar.gz: 541addf63471c2acbc2c8e67ecbfa7beb2d13f7a986bdea2675e78a915cdd568
3
+ metadata.gz: 3a4d73c76588b25b5e3ee3b257516d846582794b6a86e435cad10ecd5dcdc8bc
4
+ data.tar.gz: 57d4d2629084e41b54d0a5d041b80203ef2372718e14d750a680c5b324b18fcf
5
5
  SHA512:
6
- metadata.gz: 270dbf525c913b04d5ec65c4318b11da5fffea2c4624e42e2dbc26321651369039f0bc0b24d0d8ae1859cb01387bf1197dfe5f64aeb77ef08ddc5a9c833aaa38
7
- data.tar.gz: 1f35b76115e2679e476ea3188188a96e5362847db1a1047e9eea3fe1e0c02d937b3abe988f55b5d89b38ee3584f156e3f9710f69d9c448cb425e14e5c8634201
6
+ metadata.gz: 30175126c0b79b3625a628965b0a2869d1e5bbfa46359413335fb9b45246a21d699e65039c9d97de5d6486d6152f350308b0be4c5fee63e530a98c9de03a33d9
7
+ data.tar.gz: 8adec477ac41c310c523f6b526052bde4f6aaa72506d4d5e91a8e591cd34930ff3bca48783c8085704b6d1a318c2ea55aa17cc6165c1ffda08fffcab8385750a
@@ -7,6 +7,7 @@ module Playbook
7
7
  helper Webpacker::Helper
8
8
  helper Playbook::PbKitHelper
9
9
  helper Playbook::PbDocHelper
10
+ helper Playbook::PbSampleHelper
10
11
  append_view_path Playbook::Engine.root + "app/pb_kits"
11
12
  end
12
13
  end
@@ -21,10 +21,6 @@ module Playbook
21
21
 
22
22
  def principles; end
23
23
 
24
- def fullscreen
25
- render layout: "layouts/playbook/fullscreen"
26
- end
27
-
28
24
  def grid
29
25
  render layout: "layouts/playbook/grid"
30
26
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "playbook/application_controller"
4
+ require "yaml"
5
+
6
+ module Playbook
7
+ class SamplesController < ApplicationController
8
+ before_action :set_sample, only: %i[sample_show_rails sample_show_react]
9
+
10
+ layout "playbook/samples"
11
+
12
+ def samples
13
+ params[:type] ||= "rails"
14
+ @type = params[:type]
15
+ end
16
+
17
+ def sample_show_rails
18
+ params[:type] ||= "rails"
19
+ @type = params[:type]
20
+ render template: "playbook/samples/sample_show"
21
+ end
22
+
23
+ def sample_show_react
24
+ params[:type] ||= "react"
25
+ @type = params[:type]
26
+ render template: "playbook/samples/sample_show"
27
+ end
28
+
29
+ private
30
+
31
+ def set_sample
32
+ menu = MENU["samples"].map { |link| link.is_a?(Hash) ? link.first.last : link }
33
+ if menu.flatten.include?(params[:name])
34
+ @sample = params[:name]
35
+ else
36
+ redirect_to root_path, flash: { error: "That kit does not exist" }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -24,7 +24,8 @@ module Playbook
24
24
 
25
25
  def pb_kits(type: "rails")
26
26
  display_kits = []
27
- MENU["kits"].each do |kit|
27
+ kits = get_kits()
28
+ kits.each do |kit|
28
29
  if kit.is_a?(Hash)
29
30
  nav_hash_array(kit).each do |sub_kit|
30
31
  display_kits << render_pb_doc_kit(sub_kit, type)
@@ -36,6 +37,11 @@ module Playbook
36
37
  raw("<div class='pb--docItem'>" + display_kits.join("</div><div class='pb--docItem'>") + "</div>")
37
38
  end
38
39
 
40
+ def get_kits
41
+ menu = YAML.load_file("#{Playbook::Engine.root}/app/pb_kits/playbook/data/menu.yml")
42
+ return menu['kits']
43
+ end
44
+
39
45
  def pb_category_kits(category_kits: [], type: "rails")
40
46
  display_kits = []
41
47
  category_kits.each do |kit|
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbSampleHelper
5
+ def has_sample_type?(sample, type)
6
+ type ||= "rails"
7
+ if type == "rails"
8
+ Dir["../../views/playbook/samples/#{sample}/*.html.erb"].empty?
9
+ elsif type == "react"
10
+ Dir["../../views/playbook/samples/#{sample}/*.jsx"].empty?
11
+ end
12
+ end
13
+
14
+ def pb_sample(sample: "", type: "rails")
15
+ @type = type
16
+ @sample = sample
17
+ end
18
+ end
19
+ end
@@ -38,7 +38,7 @@ module Playbook
38
38
  end
39
39
 
40
40
  def rouge(text, language)
41
- formatter = Rouge::Formatters::HTML.new(css_class: "highlight")
41
+ formatter = Rouge::Formatters::HTML.new(scope: ".highlight")
42
42
  lexer = Rouge::Lexer.find(language)
43
43
  formatter.format(lexer.lex(text))
44
44
  end
@@ -20,6 +20,7 @@
20
20
  @import 'pb_form/form';
21
21
  @import 'pb_flex/flex';
22
22
  @import 'pb_hashtag/hashtag';
23
+ @import 'pb_highlight/highlight';
23
24
  @import 'pb_home_address_street/home_address_street';
24
25
  @import 'pb_icon/icon';
25
26
  @import 'pb_icon_circle/icon_circle';
@@ -0,0 +1,3 @@
1
+ <div>
2
+ Flexbox list of thumbnail previews.
3
+ </div>
@@ -1,7 +1,7 @@
1
1
  - type ||= "rails"
2
2
 
3
3
  - if type == "react"
4
- - contents = "<%= react_component('kits/#{key}') %>"
4
+ - contents = File.read("#{Playbook::Engine.root}/app/pb_kits/playbook/pb_#{@kit_examples[:kit]}/docs/_#{key}.jsx")
5
5
  - else
6
6
  - contents = File.read("#{Playbook::Engine.root}/app/pb_kits/playbook/pb_#{@kit_examples[:kit]}/docs/_#{key}.html.erb")
7
7
 
@@ -14,6 +14,8 @@
14
14
  = pb_react(key.camelize)
15
15
  br
16
16
 
17
+ - if @samples
18
+ = render partial: "kit_samples_list"
17
19
 
18
20
  - if @show_code
19
21
  .pb--codeControls
@@ -23,7 +25,9 @@
23
25
 
24
26
  .pb--codeCopy data-action="toggle" data-togglable="code_example"
25
27
  a.pb--close-toggle href="#" data-toggle="false" Close
26
- - if type == "rails"
27
- = raw rouge(contents, "erb")
28
- - elsif type == "react"
29
- = raw rouge(contents, "erb")
28
+ pre.highlight
29
+ - if type == "rails"
30
+ = raw rouge(contents, "erb")
31
+ - elsif type == "react"
32
+ = raw rouge(contents, "react")
33
+
@@ -1,3 +1,5 @@
1
+ samples:
2
+ - dashboards
1
3
  kits:
2
4
  - avatar
3
5
  - badge
@@ -22,6 +24,7 @@ kits:
22
24
  - textarea
23
25
  - typeahead
24
26
  - toggle
27
+ - highlight
25
28
  - hashtag
26
29
  - icon
27
30
  - icon_circle
@@ -68,3 +71,4 @@ kits:
68
71
  - title_detail
69
72
  - user
70
73
  - user_badge
74
+ - editor
@@ -20,6 +20,7 @@ export FixedConfirmationToast from './pb_fixed_confirmation_toast/_fixed_confirm
20
20
  export Flex from './pb_flex/_flex.jsx'
21
21
  export FlexItem from './pb_flex/_flex_item.jsx'
22
22
  export Hashtag from './pb_hashtag/_hashtag.jsx'
23
+ export Highlight from './pb_highlight/_highlight.jsx'
23
24
  export HomeAddressStreet from './pb_home_address_street/_home_address_street.jsx'
24
25
  export Icon from './pb_icon/_icon.jsx'
25
26
  export IconCircle from './pb_icon_circle/_icon_circle.jsx'
@@ -39,6 +40,7 @@ export MultipleUsersStacked from './pb_multiple_users_stacked/_multiple_users_st
39
40
  export Nav from './pb_nav/_nav.jsx'
40
41
  export NavItem from './pb_nav/_item.jsx'
41
42
  export OnlineStatus from './pb_online_status/_online_status.jsx'
43
+ export PbReactPopover from './pb_popover/_popover.jsx'
42
44
  export Person from './pb_person/_person.jsx'
43
45
  export PersonContact from './pb_person_contact/_person_contact.jsx'
44
46
  export Pill from './pb_pill/_pill.jsx'
@@ -0,0 +1,4 @@
1
+ import Flex from '../pb_flex/_flex.jsx'
2
+
3
+ import WebpackerReact from 'webpacker-react'
4
+ WebpackerReact.setup({ Flex })
@@ -0,0 +1,4 @@
1
+ import Highlight from '../pb_highlight/_highlight.jsx'
2
+
3
+ import WebpackerReact from 'webpacker-react'
4
+ WebpackerReact.setup({ Highlight })
@@ -33,6 +33,7 @@ import * as DistributionBar from 'pb_distribution_bar/docs'
33
33
  import * as FixedConfirmationToast from 'pb_fixed_confirmation_toast/docs'
34
34
  import * as Flex from 'pb_flex/docs'
35
35
  import * as Hashtag from 'pb_hashtag/docs'
36
+ import * as Highlight from 'pb_highlight/docs'
36
37
  import * as HomeAddressStreet from 'pb_home_address_street/docs'
37
38
  import * as Icon from 'pb_icon/docs'
38
39
  import * as IconCircle from 'pb_icon_circle/docs'
@@ -50,6 +51,7 @@ import * as MultipleUsers from 'pb_multiple_users/docs'
50
51
  import * as MultipleUsersStacked from 'pb_multiple_users_stacked/docs'
51
52
  import * as Nav from 'pb_nav/docs'
52
53
  import * as OnlineStatus from 'pb_online_status/docs'
54
+ import * as PbReactPopover from 'pb_popover/docs'
53
55
  import * as Person from 'pb_person/docs'
54
56
  import * as PersonContact from 'pb_person_contact/docs'
55
57
  import * as Pill from 'pb_pill/docs'
@@ -99,6 +101,7 @@ WebpackerReact.setup({
99
101
  ...FixedConfirmationToast,
100
102
  ...Flex,
101
103
  ...Hashtag,
104
+ ...Highlight,
102
105
  ...HomeAddressStreet,
103
106
  ...Icon,
104
107
  ...IconCircle,
@@ -116,6 +119,7 @@ WebpackerReact.setup({
116
119
  ...MultipleUsersStacked,
117
120
  ...Nav,
118
121
  ...OnlineStatus,
122
+ ...PbReactPopover,
119
123
  ...Person,
120
124
  ...PersonContact,
121
125
  ...Pill,
@@ -0,0 +1,2 @@
1
+ import '../../pb_highlight/_highlight.jsx'
2
+
@@ -0,0 +1 @@
1
+ import '../../pb_popover/_popover.jsx'
@@ -7,3 +7,6 @@
7
7
  // APP STYLES
8
8
  @import "site_styles/site-style";
9
9
  @import "site_styles/docs/all";
10
+
11
+ // FULL PAGE EXAMPLE STYLES
12
+ @import "site_styles/samples";
@@ -0,0 +1,50 @@
1
+ // ===========================================
2
+ // Generated file from kit generator.
3
+ //
4
+ // ===========================================
5
+
6
+ import WebpackerReact from 'webpacker-react'
7
+
8
+ //
9
+ // ===========================================
10
+ // ===========================================
11
+ // Generated file from kit generator.
12
+
13
+ import Dashboards from '../../../views/playbook/samples/dashboards/dashboards.jsx'
14
+
15
+ WebpackerReact.setup({ Dashboards })
16
+
17
+ $(document).ready(() => {
18
+ $('.pb--codeCopy').show()
19
+ $('.compress').hide()
20
+
21
+ window.$(document).on('click', '.toggle-button', (e) => {
22
+ e.preventDefault()
23
+ $('.pb--codeCopy').toggleClass('close')
24
+ })
25
+
26
+ $('.expand').click(() => {
27
+ $('.sample-nav').hide()
28
+ $('.compress').show()
29
+ })
30
+
31
+ $('.compress').click(() => {
32
+ $('.sample-nav').show()
33
+ $('.compress').hide()
34
+ })
35
+
36
+ const setClipboard = (value) => {
37
+ var tempInput = document.createElement('textarea')
38
+ tempInput.style = 'position: absolute; left: -1000px; top: -1000px'
39
+ tempInput.value = value
40
+ document.body.appendChild(tempInput)
41
+ tempInput.select()
42
+ document.execCommand('copy')
43
+ document.body.removeChild(tempInput)
44
+ }
45
+
46
+ $('.copy-clipboard').click(() => {
47
+ var copyText = document.querySelector('.hiddenCodeforCopy').textContent
48
+ setClipboard(copyText)
49
+ })
50
+ })
@@ -0,0 +1,71 @@
1
+ .sample-layout {
2
+ overflow-y: hidden;
3
+ .sample {
4
+ padding-left: 50px;
5
+ border-bottom: 0px;
6
+ }
7
+ .code-controls {
8
+ .pb_nav_list_item_text {
9
+ color: white !important;
10
+ }
11
+ .pb_nav_list_kit_item {
12
+ .pb_nav_list_item_link {
13
+ border-color: transparent !important;
14
+ }
15
+ }
16
+ }
17
+
18
+ .sample-nav {
19
+ padding: 0 25px;
20
+ background: #172257;
21
+ display: flex;
22
+ width: 100%;
23
+ flex-basis: 200px;
24
+
25
+ }
26
+
27
+ .sample-actions {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+
32
+ &-right {
33
+ margin-left: auto;
34
+ order: 2;
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ .items {
39
+ padding: 5px;
40
+ }
41
+ }
42
+ }
43
+ .pb--doc {
44
+ margin-bottom: 0px;
45
+ }
46
+ .pb--codeCopy {
47
+ border: 0px;
48
+ position: fixed;
49
+ width: 100%;
50
+ height: calc(50vh - 45px);
51
+ bottom: 0;
52
+ left: 0;
53
+ transition: all .4s;
54
+ }
55
+
56
+ .pb--codeCopy.close {
57
+ top: 100%;
58
+ height: 0px;
59
+ transition: all .4s;
60
+ }
61
+ .compress {
62
+ position: absolute;
63
+ top: 15px;
64
+ right: 30px;
65
+ display: none;
66
+ z-index: 4;
67
+ }
68
+ .hiddenCodeforCopy {
69
+ display: none;
70
+ }
71
+ }
@@ -46,6 +46,12 @@
46
46
  line-height: 34px;
47
47
  border-bottom: 2px solid rgba($border_light, 0.6);
48
48
 
49
+ &.sample {
50
+ margin: 0;
51
+ border-bottom: 2px solid rgba(228, 232, 240, 0.6);
52
+ background: rgb(23, 34, 87) !important;
53
+ }
54
+
49
55
  a {
50
56
  padding: 0 10px;
51
57
  line-height: 34px;
@@ -1,4 +1,12 @@
1
+ .pb--kit-show.flex-kit {
1
2
  [class^=pb_flex_kit] { background: #F3F7FB; }
2
- .flex-item,
3
- [class^=pb_flex_item_kit] { background: #E4E8F0; min-width: 30px; min-height: 30px; color: #242B42; }
4
- .tall {min-height: 200px;}
3
+
4
+ .flex-item, [class^=pb_flex_item_kit] {
5
+ background: #E4E8F0;
6
+ min-width: 30px;
7
+ min-height: 30px;
8
+ color: #242B42;
9
+ }
10
+
11
+ .tall { min-height: 200px; }
12
+ }
@@ -2,5 +2,5 @@
2
2
  id: object.id,
3
3
  data: object.data,
4
4
  class: object.classname) do %>
5
- <%= !object.children.nil? ? capture(&object.children) : object.text %>
5
+ <%= object.children.present? ? capture(&object.children) : object.content %>
6
6
  <% end %>
@@ -2,6 +2,7 @@
2
2
 
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
+ import { Highlight } from '../'
5
6
 
6
7
  type BodyProps = {
7
8
  className?: String,
@@ -11,6 +12,8 @@ type BodyProps = {
11
12
  status?: 'negative' | 'positive',
12
13
  tag: String,
13
14
  text?: String,
15
+ highlighting?: Boolean,
16
+ highlightedText?: Array<String>
14
17
  }
15
18
 
16
19
  const bodyCSS = ({
@@ -34,13 +37,19 @@ const Body = (props: BodyProps) => {
34
37
  children,
35
38
  text,
36
39
  tag = 'div',
40
+ highlightedText,
41
+ highlighting = false,
37
42
  } = props
38
43
 
39
44
  const Tag = `${tag}`
40
45
 
41
46
  return (
42
47
  <Tag className={classnames(bodyCSS(props), className)}>
43
- { text || children }
48
+ <If condition={highlighting}>
49
+ <Highlight highlightedText={highlightedText}>{text || children}</Highlight>
50
+ <Else />
51
+ { text || children }
52
+ </If>
44
53
  </Tag>
45
54
  )
46
55
  }