playbook_ui 10.5.0 → 10.6.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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_date/docs/_description.md +8 -0
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +4 -2
- data/app/pb_kits/playbook/pb_icon/_icon.scss +7 -2
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +16 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.md +10 -2
- data/app/pb_kits/playbook/pb_icon/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +13 -7
- data/app/pb_kits/playbook/pb_icon/icon.rb +33 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +7 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.html.erb +12 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +1 -0
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -0
- data/lib/playbook/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92a63c7a34002ee474379b924fac531199e11e3d5976bf78b6fe97e5537110e5
|
4
|
+
data.tar.gz: eb19246bf1a95c6bafb81e752a897a92fc8dd7b7e128c08c05e7ce3d24b8b6d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = ['
|
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>
|
@@ -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
|
-
|
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
|
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.
|
@@ -1,7 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
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,
|
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
|
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: {
|
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
|
|
data/lib/playbook/version.rb
CHANGED
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.
|
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-
|
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
|