playbook_ui 10.5.0 → 10.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31e7e0a26b7b9819517d52aaa9359224528df45c92fbba2cef45a75523d7b52b
4
- data.tar.gz: c9f444527d413d7a874a6cbb24be7898a43747d55b5c461bdfe90cee14c2d8b3
3
+ metadata.gz: 92a63c7a34002ee474379b924fac531199e11e3d5976bf78b6fe97e5537110e5
4
+ data.tar.gz: eb19246bf1a95c6bafb81e752a897a92fc8dd7b7e128c08c05e7ce3d24b8b6d8
5
5
  SHA512:
6
- metadata.gz: bddd1fd46ae05dbff5b5f2d87d96c96d323bb0e0a612cb4234c7a9dce751469dfc68b7745df14876616fb08aaed593d449f4da94cec3d1df77c91d09e68a272b
7
- data.tar.gz: 9019f94b33aa5caaa9ee99872df9e6a951d4a9f1c6ffd482dfc24b05e03f773d3f05633a2179addb706d885ed86bdf4918dffd90cd551d5c2d92ce3b5e237db0
6
+ metadata.gz: 1c76fe545fd05b58ea4e449cbfaed640329cae428bb317203ba41d6b82ff3881cce0beb55ee5e289ca83752490515aa2263b13f4975a94925f955ceee93d6fa6
7
+ data.tar.gz: a2c4878dbfa7e00663dddba7c265fa8ab7bef5250ddee8bc7b694dcafa2a56185b6dcc0af7611717cf33ad976193594366ce55ce0570c9fe90f27c92af3f76dd
@@ -1,3 +1,11 @@
1
1
  Use to display the date. Year will not display if it is the current year.
2
2
 
3
3
  `DateTime` defaults to the "America/New_York" timezone. `Date` ignores timezone.
4
+
5
+ **Please note**: this kit could potentially change the dates on you!
6
+
7
+ This is because the Javascript `Date` class does not have the concept of a date without time. If you pass a Ruby `Date` string to JavaScript, you will receive a date *and* a time which makes use of the timezone it infers from your browser based on your virtual geolocation or custom browser settings.
8
+
9
+ For example, if you pass a date like "7/2/2022" and your browser is on London time, Javascript will convert this to "7/2/2022 at 0:00 BST".
10
+
11
+ Subsequently, if you have not passed in a timezone to this kit, it will convert that time into US Eastern Time (default), making the resulting date and time "7/1/2022 at 19:00 EST". In this case the expected July 2 date will now be presented as July 1.
@@ -14,12 +14,14 @@ import Card from '../pb_card/_card'
14
14
  type FileUploadProps = {
15
15
  accept?: array<string>,
16
16
  className?: string,
17
+ acceptedFilesDescription?: string,
17
18
  onFilesAccepted: Callback,
18
19
  }
19
20
 
20
21
  const FileUpload = (props: FileUploadProps) => {
21
22
  const {
22
- accept = ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml'],
23
+ accept = ['*'],
24
+ acceptedFilesDescription = '',
23
25
  className,
24
26
  onFilesAccepted = noop,
25
27
  } = props
@@ -51,7 +53,7 @@ const FileUpload = (props: FileUploadProps) => {
51
53
  <If condition={isDragActive}>
52
54
  <p>{'Drop the files here ...'}</p>
53
55
  <Else />
54
- <p>{`Choose a file or drag it here. The accepted file types are: ${acceptedFileTypes}`}</p>
56
+ <p>{`Choose a file or drag it here. The accepted file types are: ${acceptedFilesDescription || acceptedFileTypes}`}</p>
55
57
  </If>
56
58
  </Body>
57
59
  </Card>
@@ -1,3 +1,8 @@
1
- [class^=pb_icon_kit]{
2
-
1
+ // Rails custom icon styles
2
+ svg.pb_custom_icon {
3
+ width: 1em;
4
+ fill: currentColor;
5
+ path {
6
+ fill: currentColor;
7
+ }
3
8
  }
@@ -0,0 +1,16 @@
1
+ <%# SVG fill color inherited from css color property %>
2
+ <div class="icon-wrapper">
3
+
4
+ <% svg_url = "https://upload.wikimedia.org/wikipedia/commons/3/3b/Wrench_font_awesome.svg" %>
5
+ <p><%= pb_rails("icon", props: { custom_icon: svg_url } ) %></p>
6
+ <p><%= pb_rails("icon", props: { rotation: 90, custom_icon: svg_url, size: "2x" } ) %></p>
7
+ <p><%= pb_rails("icon", props: { spin: true, custom_icon: svg_url, size: "3x" } ) %></p>
8
+ <p><%= pb_rails("icon", props: { size: "5x", custom_icon: svg_url } ) %></p>
9
+ <p><%= pb_rails("icon", props: { flip: "horizontal", size: "5x", custom_icon: svg_url } ) %></p>
10
+
11
+ <%= pb_rails("body", props: {
12
+ text: "Custom icons are compatible with other icon props (size, rotation,
13
+ spin, flip, etc). Their SVG fill colors will be inherited from
14
+ parent element's css color properties."
15
+ } ) %>
16
+ </div>
@@ -1,4 +1,4 @@
1
- ### Experimental: Not currently available in the Rails version!
1
+ # Tips for Custom Icons
2
2
 
3
3
  When using custom icons it is important to introduce a "clean" SVG. In order to ensure these custom icons perform as intended within your kit(s), ensure these things have been modified from the original SVG markup:
4
4
 
@@ -8,4 +8,12 @@ Fill colors with regards to <code>g</code> or <code>path</code> nodes, e.g. <cod
8
8
 
9
9
  Pay attention to your custom icon's dimensions and `viewBox` attribute. It is best to use a `viewBox="0 0 512 512"` starting point __when designing instead of trying to retrofit the viewbox afterwards__!
10
10
 
11
- You must source *your own SVG into the React component/view* you are working in. This can easily be done in a programmatic and maintainable way. So long as you have a valid React `<SVG>` node, you can send it as the `customIcon` prop and the kit will take care of the rest.
11
+ You must source *your own SVG into component/view* you are working on. This can easily be done in programmatic and maintainable ways.
12
+
13
+ ### React
14
+
15
+ So long as you have a valid React `<SVG>` node, you can send it as the `customIcon` prop and the kit will take care of the rest.
16
+
17
+ ### Rails
18
+
19
+ Some Rails applications use only webpack(er) which means using `image_url` will be successful over `image_path` in most cases especially development where Webpack Dev Server is serving assets over HTTP. Rails applications still using Asset Pipeline may use `image_path` or `image_url`. Of course, YMMV depending on any custom configurations in your Rails application.
@@ -7,6 +7,7 @@ examples:
7
7
  - icon_pull: Icon Pull
8
8
  - icon_border: Icon Border
9
9
  - icon_sizes: Icon Sizes
10
+ - icon_custom: Icon Custom
10
11
 
11
12
  react:
12
13
  - icon_default: Icon Default
@@ -1,7 +1,13 @@
1
- <%= content_tag(:i, nil,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname ) %>
5
- <%= content_tag(:span, nil,
6
- aria: { label: "#{object.icon} icon" }.merge(object.aria),
7
- hidden: true ) %>
1
+ <% if object.custom_icon %>
2
+ <%= object.render_svg(object.custom_icon) %>
3
+ <% else %>
4
+ <%= content_tag(:i, nil,
5
+ id: object.id,
6
+ data: object.data,
7
+ class: object.classname
8
+ ) %>
9
+ <%= content_tag(:span, nil,
10
+ aria: { label: "#{object.icon} icon" }.merge(object.aria),
11
+ hidden: true
12
+ ) %>
13
+ <% end %>
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "open-uri"
4
+
3
5
  module Playbook
4
6
  module PbIcon
5
7
  class Icon < Playbook::KitBase
@@ -10,7 +12,9 @@ module Playbook
10
12
  prop :flip, type: Playbook::Props::Enum,
11
13
  values: ["horizontal", "vertical", "both", nil],
12
14
  default: nil
13
- prop :icon, required: true
15
+ prop :icon
16
+ prop :custom_icon, type: Playbook::Props::String,
17
+ default: nil
14
18
  prop :inverse, type: Playbook::Props::Boolean,
15
19
  default: false
16
20
  prop :list_item, type: Playbook::Props::Boolean,
@@ -48,6 +52,34 @@ module Playbook
48
52
  )
49
53
  end
50
54
 
55
+ def custom_icon_classname
56
+ generate_classname(
57
+ "pb_icon_kit",
58
+ border_class,
59
+ fixed_width_class,
60
+ flip_class,
61
+ inverse_class,
62
+ list_item_class,
63
+ pull_class,
64
+ pulse_class,
65
+ rotation_class,
66
+ size_class,
67
+ spin_class,
68
+ separator: " "
69
+ )
70
+ end
71
+
72
+ def render_svg(path)
73
+ if File.extname(path) == ".svg"
74
+ doc = Nokogiri::XML(open(path)) # rubocop:disable Security/Open
75
+ svg = doc.at_css "svg"
76
+ svg["class"] = "pb_custom_icon " + object.custom_icon_classname
77
+ raw doc
78
+ else
79
+ raise("Custom icon must be an svg. Please check your path and file type.")
80
+ end
81
+ end
82
+
51
83
  private
52
84
 
53
85
  def border_class
@@ -10,6 +10,8 @@ module Playbook
10
10
  prop :error
11
11
  prop :inline, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :input_options, type: Playbook::Props::Hash,
14
+ default: {}
13
15
  prop :label
14
16
  prop :name
15
17
  prop :placeholder
@@ -27,7 +29,7 @@ module Playbook
27
29
  end
28
30
 
29
31
  def input_tag
30
- tag(:input, input_options)
32
+ tag(:input, all_input_options)
31
33
  end
32
34
 
33
35
  def has_add_on?
@@ -44,13 +46,13 @@ module Playbook
44
46
 
45
47
  private
46
48
 
47
- def input_options
49
+ def all_input_options
48
50
  {
49
51
  autocomplete: autocomplete ? nil : "off",
50
- class: "text_input",
52
+ class: "text_input #{input_options.dig(:classname) || ''}",
51
53
  data: validation_data,
52
54
  disabled: disabled,
53
- id: id,
55
+ id: input_options.dig(:id) || id,
54
56
  name: name,
55
57
  pattern: validation_pattern,
56
58
  placeholder: placeholder,
@@ -69,7 +71,7 @@ module Playbook
69
71
  end
70
72
 
71
73
  def validation_data
72
- fields = {}
74
+ fields = input_options.dig(:data) || {}
73
75
  fields[:message] = validation_message unless validation_message.blank?
74
76
  fields
75
77
  end
@@ -1,4 +1,15 @@
1
- <%= pb_rails("typeahead", props: { label: "user", name: :foo, data: { typeahead_example: true } }) %>
1
+ <%= pb_rails("typeahead", props: {
2
+ label: "user",
3
+ name: :foo,
4
+ data: { typeahead_example: true },
5
+ input_options: {
6
+ classname: "my-typeahead-class",
7
+ data: {
8
+ typeahead_testing: "data field test"
9
+ },
10
+ id: "typeahead-input-id-test",
11
+ },
12
+ })%>
2
13
 
3
14
  <br><br><br>
4
15
 
@@ -15,6 +15,7 @@
15
15
  </div>
16
16
  <%= pb_rails("text_input", props: {
17
17
  type: "search",
18
+ input_options: object.input_options,
18
19
  label: object.label,
19
20
  name: object.name,
20
21
  value: object.value,
@@ -17,6 +17,8 @@ module Playbook
17
17
  prop :name
18
18
  prop :options, type: Playbook::Props::HashArray,
19
19
  default: []
20
+ prop :input_options, type: Playbook::Props::Hash,
21
+ default: {}
20
22
  prop :pills, type: Playbook::Props::Boolean,
21
23
  default: false
22
24
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "10.4.0"
5
- VERSION = "10.5.0"
4
+ PREVIOUS_VERSION = "10.5.0"
5
+ VERSION = "10.6.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.5.0
4
+ version: 10.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-04 00:00:00.000000000 Z
12
+ date: 2021-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -1004,6 +1004,7 @@ files:
1004
1004
  - app/pb_kits/playbook/pb_icon/docs/_icon_animate.md
1005
1005
  - app/pb_kits/playbook/pb_icon/docs/_icon_border.html.erb
1006
1006
  - app/pb_kits/playbook/pb_icon/docs/_icon_border.jsx
1007
+ - app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb
1007
1008
  - app/pb_kits/playbook/pb_icon/docs/_icon_custom.jsx
1008
1009
  - app/pb_kits/playbook/pb_icon/docs/_icon_custom.md
1009
1010
  - app/pb_kits/playbook/pb_icon/docs/_icon_default.html.erb