playbook_ui 13.30.0 → 13.31.0.pre.alpha.PLAY882formpillprimaryandneutral3201
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +59 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +4 -4
- data/app/pb_kits/playbook/pb_background/background.html.erb +2 -11
- data/app/pb_kits/playbook/pb_body/body.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +1 -6
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +1 -6
- data/app/pb_kits/playbook/pb_card/_card.tsx +4 -3
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -7
- data/app/pb_kits/playbook/pb_collapsible/index.js +6 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_default_swift.md +33 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_props_swift.md +18 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/example.yml +6 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.jsx +4 -1
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +1 -6
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -6
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +1 -6
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +2 -5
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -6
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +2 -4
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +84 -50
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +31 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +15 -19
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +5 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +5 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +11 -4
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +8 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +2 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +5 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +6 -4
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +142 -15
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +6 -5
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +18 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +228 -218
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.html.erb +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.jsx +34 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +16 -12
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +9 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +17 -2
- data/app/pb_kits/playbook/pb_dropdown/index.js +33 -4
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +9 -3
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_custom_icon.html.erb +32 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_custom_icon.jsx +48 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +16 -11
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +72 -0
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +1 -5
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +9 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +108 -5
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +53 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +11 -2
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +5 -1
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -6
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +1 -5
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +1 -5
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +37 -6
- data/app/pb_kits/playbook/pb_icon/docs/_icon_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_default.jsx +2 -3
- data/app/pb_kits/playbook/pb_icon/icon.rb +21 -1
- data/app/pb_kits/playbook/pb_icon/icon_aliases.json +39 -0
- data/app/pb_kits/playbook/pb_list/_list.tsx +4 -4
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +7 -3
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.html.erb +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +3 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_nav/item.rb +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.html.erb +24 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.md +4 -4
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +27 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +110 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -23
- data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +7 -3
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +3 -3
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +16 -2
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +11 -10
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +8 -6
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -0
- data/dist/menu.yml +566 -472
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +2 -2
- metadata +22 -5
@@ -1,8 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data,
|
4
|
-
class: object.classname,
|
5
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
6
2
|
<%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
|
7
3
|
<% end %>
|
8
4
|
|
@@ -3,6 +3,7 @@ import classnames from 'classnames'
|
|
3
3
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/props'
|
4
4
|
import { GlobalProps, globalProps } from '../utilities/globalProps'
|
5
5
|
import { isValidEmoji } from '../utilities/validEmojiChecker'
|
6
|
+
import aliasesJson from './icon_aliases.json'
|
6
7
|
|
7
8
|
export type IconSizes = "lg"
|
8
9
|
| "xs"
|
@@ -40,6 +41,19 @@ type IconProps = {
|
|
40
41
|
spin?: boolean,
|
41
42
|
} & GlobalProps
|
42
43
|
|
44
|
+
type AliasType = string | string[];
|
45
|
+
|
46
|
+
interface Aliases {
|
47
|
+
[key: string]: AliasType;
|
48
|
+
}
|
49
|
+
|
50
|
+
interface AliasesJson {
|
51
|
+
aliases: Aliases;
|
52
|
+
}
|
53
|
+
|
54
|
+
const aliases: AliasesJson = aliasesJson;
|
55
|
+
|
56
|
+
|
43
57
|
const flipMap = {
|
44
58
|
horizontal: 'fa-flip-horizontal',
|
45
59
|
vertical: 'fa-flip-vertical',
|
@@ -52,6 +66,22 @@ declare global {
|
|
52
66
|
var PB_ICONS: {[key: string]: React.FunctionComponent<any>}
|
53
67
|
}
|
54
68
|
|
69
|
+
// Resolve alias function
|
70
|
+
const resolveAlias = (icon: string): string => {
|
71
|
+
const alias = aliases.aliases[icon];
|
72
|
+
|
73
|
+
if (alias) {
|
74
|
+
if (Array.isArray(alias)) {
|
75
|
+
return alias[0];
|
76
|
+
} else {
|
77
|
+
return alias;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
return icon;
|
82
|
+
};
|
83
|
+
|
84
|
+
|
55
85
|
const Icon = (props: IconProps) => {
|
56
86
|
const {
|
57
87
|
aria = {},
|
@@ -74,7 +104,8 @@ const Icon = (props: IconProps) => {
|
|
74
104
|
spin = false,
|
75
105
|
} = props
|
76
106
|
|
77
|
-
|
107
|
+
const resolvedIcon = resolveAlias(icon as string)
|
108
|
+
let iconElement: ReactSVGElement | null = typeof(resolvedIcon) === "object" ? resolvedIcon : null
|
78
109
|
|
79
110
|
const faClasses = {
|
80
111
|
'fa-border': border,
|
@@ -90,12 +121,12 @@ const Icon = (props: IconProps) => {
|
|
90
121
|
|
91
122
|
if (!customIcon && !iconElement) {
|
92
123
|
const PowerIcon: React.FunctionComponent<any> | undefined =
|
93
|
-
window.PB_ICONS ? window.PB_ICONS[
|
124
|
+
window.PB_ICONS ? window.PB_ICONS[resolvedIcon as string] : null
|
94
125
|
|
95
126
|
if (PowerIcon) {
|
96
127
|
iconElement = <PowerIcon /> as ReactSVGElement
|
97
128
|
} else {
|
98
|
-
faClasses[`fa-${
|
129
|
+
faClasses[`fa-${resolvedIcon}`] = resolvedIcon as string
|
99
130
|
}
|
100
131
|
}
|
101
132
|
|
@@ -115,7 +146,7 @@ const Icon = (props: IconProps) => {
|
|
115
146
|
className
|
116
147
|
)
|
117
148
|
|
118
|
-
aria.label ? null : aria.label = `${
|
149
|
+
aria.label ? null : aria.label = `${resolvedIcon} icon`
|
119
150
|
const ariaProps: {[key: string]: any} = buildAriaProps(aria)
|
120
151
|
const dataProps: {[key: string]: any} = buildDataProps(data)
|
121
152
|
const htmlProps = buildHtmlProps(htmlOptions)
|
@@ -137,7 +168,7 @@ const Icon = (props: IconProps) => {
|
|
137
168
|
}
|
138
169
|
</>
|
139
170
|
)
|
140
|
-
else if (isValidEmoji(
|
171
|
+
else if (isValidEmoji(resolvedIcon as string))
|
141
172
|
return (
|
142
173
|
<>
|
143
174
|
<span
|
@@ -146,7 +177,7 @@ const Icon = (props: IconProps) => {
|
|
146
177
|
className={classesEmoji}
|
147
178
|
id={id}
|
148
179
|
>
|
149
|
-
{
|
180
|
+
{resolvedIcon}
|
150
181
|
</span>
|
151
182
|
</>
|
152
183
|
)
|
@@ -1 +1 @@
|
|
1
|
-
<%= pb_rails("icon", props: { icon: "user", fixed_width: true }) %>
|
1
|
+
<%= pb_rails("icon", props: { icon: "user", fixed_width: true }) %>
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# rubocop:disable Style/HashLikeCase
|
4
4
|
|
5
5
|
require "open-uri"
|
6
|
+
require "json"
|
6
7
|
|
7
8
|
module Playbook
|
8
9
|
module PbIcon
|
@@ -38,6 +39,8 @@ module Playbook
|
|
38
39
|
prop :spin, type: Playbook::Props::Boolean,
|
39
40
|
default: false
|
40
41
|
|
42
|
+
ALIASES = JSON.parse(File.read(Playbook::Engine.root.join("app/pb_kits/playbook/pb_icon/icon_aliases.json")))["aliases"].freeze
|
43
|
+
|
41
44
|
def valid_emoji?
|
42
45
|
emoji_regex = /\p{Emoji}/
|
43
46
|
emoji_regex.match?(icon)
|
@@ -83,7 +86,8 @@ module Playbook
|
|
83
86
|
return unless Rails.application.config.respond_to?(:icon_path)
|
84
87
|
|
85
88
|
base_path = Rails.application.config.icon_path
|
86
|
-
|
89
|
+
resolved_icon = resolve_alias(icon)
|
90
|
+
icon_path = Dir.glob(Rails.root.join(base_path, "**", "#{resolved_icon}.svg")).first
|
87
91
|
icon_path if icon_path && File.exist?(icon_path)
|
88
92
|
end
|
89
93
|
|
@@ -106,6 +110,22 @@ module Playbook
|
|
106
110
|
|
107
111
|
private
|
108
112
|
|
113
|
+
def resolve_alias(icon)
|
114
|
+
aliases = ALIASES[icon]
|
115
|
+
return icon unless aliases
|
116
|
+
|
117
|
+
if aliases.is_a?(Array)
|
118
|
+
aliases.find { |alias_name| file_exists?(alias_name) } || icon
|
119
|
+
else
|
120
|
+
aliases
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def file_exists?(alias_name)
|
125
|
+
base_path = Rails.application.config.icon_path
|
126
|
+
File.exist?(Dir.glob(Rails.root.join(base_path, "**", "#{alias_name}.svg")).first)
|
127
|
+
end
|
128
|
+
|
109
129
|
def svg_size
|
110
130
|
size.nil? ? "1x" : size
|
111
131
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"aliases": {
|
3
|
+
"arrow-alt-circle-right": "circle-right",
|
4
|
+
"angles-down": "angle-double-down",
|
5
|
+
"arrow-alt-down": "down",
|
6
|
+
"arrow-alt-up": "up",
|
7
|
+
"arrow-right-long": "long-arrow-right",
|
8
|
+
"arrow-to-bottom": "arrow-down-to-line",
|
9
|
+
"arrows-h": "arrows-left-right",
|
10
|
+
"calendar-days": "calendar-alt",
|
11
|
+
"circle-arrow-right": "arrow-circle-right",
|
12
|
+
"clock-rotate-left": "history",
|
13
|
+
"close": [
|
14
|
+
"times",
|
15
|
+
"xmark"
|
16
|
+
],
|
17
|
+
"ellipsis-h": "ellipsis",
|
18
|
+
"exclamation-circle": "circle-exclamation",
|
19
|
+
"external-link": "arrow-up-right-from-square",
|
20
|
+
"file-lines": "file-alt",
|
21
|
+
"gear": "cog",
|
22
|
+
"home": "house",
|
23
|
+
"info-circle": "circle-info",
|
24
|
+
"map-o": "map",
|
25
|
+
"message": "comment-alt",
|
26
|
+
"minus-circle": "circle-minus",
|
27
|
+
"money": "money-bill",
|
28
|
+
"mouse-pointer": "arrow-pointer",
|
29
|
+
"nitro": "nitro-n",
|
30
|
+
"play-circle": "circle-play",
|
31
|
+
"plus-circle": "circle-plus",
|
32
|
+
"plus-square": "square-plus",
|
33
|
+
"powergon": "powergon-p",
|
34
|
+
"question-circle": "circle-question",
|
35
|
+
"roofing": "product-roofing",
|
36
|
+
"shelves": "inventory",
|
37
|
+
"th-list": "table-list"
|
38
|
+
}
|
39
|
+
}
|
@@ -10,7 +10,7 @@ type ListProps = {
|
|
10
10
|
className?: string;
|
11
11
|
children: React.ReactNode[] | React.ReactNode;
|
12
12
|
dark?: boolean;
|
13
|
-
|
13
|
+
enableDrag?: boolean;
|
14
14
|
data?: Record<string, unknown>;
|
15
15
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
16
16
|
id?: string;
|
@@ -32,7 +32,7 @@ const List = (props: ListProps) => {
|
|
32
32
|
className,
|
33
33
|
dark = false,
|
34
34
|
data = {},
|
35
|
-
|
35
|
+
enableDrag = false,
|
36
36
|
htmlOptions = {},
|
37
37
|
id,
|
38
38
|
layout = "",
|
@@ -54,7 +54,7 @@ const List = (props: ListProps) => {
|
|
54
54
|
const childrenWithProps = React.Children.map(
|
55
55
|
children,
|
56
56
|
(child: React.ReactElement) => {
|
57
|
-
return React.cloneElement(child, { text, variant,
|
57
|
+
return React.cloneElement(child, { text, variant, enableDrag });
|
58
58
|
}
|
59
59
|
);
|
60
60
|
const ariaProps = buildAriaProps(aria);
|
@@ -74,7 +74,7 @@ const List = (props: ListProps) => {
|
|
74
74
|
return (
|
75
75
|
<>
|
76
76
|
{
|
77
|
-
|
77
|
+
enableDrag ? (
|
78
78
|
<Draggable.Container>
|
79
79
|
<div className={classes}>
|
80
80
|
{ordered ? (
|
@@ -11,6 +11,7 @@ type ListItemProps = {
|
|
11
11
|
children: React.ReactNode[] | React.ReactNode,
|
12
12
|
className?: string,
|
13
13
|
data?: Record<string, unknown>,
|
14
|
+
dragId?: string,
|
14
15
|
dragHandle?: boolean,
|
15
16
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
16
17
|
id?: string,
|
@@ -23,7 +24,8 @@ const ListItem = (props: ListItemProps) => {
|
|
23
24
|
children,
|
24
25
|
className,
|
25
26
|
data = {},
|
26
|
-
|
27
|
+
enableDrag,
|
28
|
+
dragId,
|
27
29
|
dragHandle = true,
|
28
30
|
htmlOptions = {},
|
29
31
|
id,
|
@@ -42,8 +44,10 @@ const ListItem = (props: ListItemProps) => {
|
|
42
44
|
return (
|
43
45
|
<>
|
44
46
|
{
|
45
|
-
|
46
|
-
<Draggable.Item
|
47
|
+
enableDrag ? (
|
48
|
+
<Draggable.Item
|
49
|
+
dragId={dragId}
|
50
|
+
>
|
47
51
|
<li
|
48
52
|
{...ariaProps}
|
49
53
|
{...dataProps}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= pb_rails("nav", props: { variant: "bold" }) do %>
|
2
|
-
<%= pb_rails("nav/item", props: { text: "Overview", link: "#", collapsible: true, icon_left:"city" }) do %>
|
2
|
+
<%= pb_rails("nav/item", props: { text: "Overview", link: "#", collapsible: true, icon_left:"city", collapsed: false }) do %>
|
3
3
|
<%= pb_rails("nav", props: { variant: "bold" }) do %>
|
4
4
|
<%= pb_rails("nav/item", props: { text: "City", link: "#" }) %>
|
5
5
|
<%= pb_rails("nav/item", props: { text: "People", link: "#" }) %>
|
@@ -1 +1,3 @@
|
|
1
|
-
The `collapsible` prop allows users to create a nested, collapsible nav. Pass `collapsible` to any NavItem and pass that navItem any number of NavItems as children to create a collapsible nav.
|
1
|
+
The `collapsible` prop allows users to create a nested, collapsible nav. Pass `collapsible` to any NavItem and pass that navItem any number of NavItems as children to create a collapsible nav.
|
2
|
+
|
3
|
+
The optional `collapsed` prop can also be used to set the default state for the collapsed nav on first render of the page. `collapsed` takes a boolean value that is set to true (meaning nav is collapsed) by default. Set it to false as shown here to have the nav open on first render.
|
@@ -12,6 +12,7 @@ module Playbook
|
|
12
12
|
default: "regular"
|
13
13
|
prop :highlighted_border, type: Playbook::Props::Boolean, default: true
|
14
14
|
prop :collapsible, type: Playbook::Props::Boolean, default: false
|
15
|
+
prop :collapsed, type: Playbook::Props::Boolean, default: true
|
15
16
|
prop :link
|
16
17
|
prop :text
|
17
18
|
prop :collapsible_trail, type: Playbook::Props::Boolean, default: false
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%= pb_rails("overlay") do %>
|
2
|
+
<%= pb_rails("table", props: { size: "sm" }) do %>
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th>Column 1</th>
|
6
|
+
<th>Column 2</th>
|
7
|
+
<th>Column 3</th>
|
8
|
+
<th>Column 4</th>
|
9
|
+
<th>Column 5</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% 7.times do %>
|
14
|
+
<tr>
|
15
|
+
<td>Value 1</td>
|
16
|
+
<td>Value 2</td>
|
17
|
+
<td>Value 3</td>
|
18
|
+
<td>Value 4</td>
|
19
|
+
<td>Value 5</td>
|
20
|
+
</tr>
|
21
|
+
<% end %>
|
22
|
+
</tbody>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
|
-
Overlays
|
1
|
+
Overlays optionally accept a `color`, which sets the "start" (opaque) color of a gradient mask. Because this overlay is intended to reveal underlying content, the "end" color is fixed to transparent.
|
2
2
|
|
3
|
-
The optional `layout` prop accepts
|
3
|
+
The optional `layout` prop accepts the `position` and `size` of the overlay as a key:value pair.
|
4
4
|
|
5
|
-
The `position` key accepts `
|
5
|
+
The `position` key accepts `bottom` (default), `top`, `y` (for both top and bottom) `right`, `left`, or `x` (for both left and right), which sets the side(s) where the `color` overlay starts. The direction of the overlay is always toward the opposite side of the position. For example, the default position of `bottom` starts the overlay on the bottom edge of your container and extends it toward the opposite side: the top.
|
6
6
|
|
7
|
-
The `size` value accepts our [spacing tokens](https://playbook.powerapp.cloud/visual_guidelines/spacing) or a percentage value as a string, and literally translates to how much of the container is covered by the overlay
|
7
|
+
The `size` value is `full` (100%) by default, but accepts our [spacing tokens](https://playbook.powerapp.cloud/visual_guidelines/spacing) or a percentage value as a string, and literally translates to how much of the container is covered by the overlay(s).
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= pb_rails("overlay", props: { layout: { "x": "xl" }, color: "card_light" }) do %>
|
2
|
+
<%= pb_rails("flex", props: { column_gap: "lg", orientation: "row", overflow_x: "auto" }) do %>
|
3
|
+
<% 15.times do %>
|
4
|
+
<%= pb_rails("flex/flex_item") do %>
|
5
|
+
<%= pb_rails("card") do %>
|
6
|
+
Card content
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= pb_content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
7
|
+
<% if is_size_percentage %>
|
8
|
+
<div class="overlay_linear_gradient"
|
9
|
+
style="background: <%= previous_overlay %>"></div>
|
10
|
+
|
11
|
+
<%= content.presence %>
|
12
|
+
|
13
|
+
<% if has_subsequent_overlay %>
|
14
|
+
<div class="overlay_linear_gradient"
|
15
|
+
style="background: <%= subsequent_overlay %>"></div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% else %>
|
19
|
+
<div class="<%= previous_overlay_class_name %>"></div>
|
20
|
+
|
21
|
+
<%= content.presence %>
|
22
|
+
|
23
|
+
<% if has_subsequent_overlay %>
|
24
|
+
<div class="<%= subsequent_overlay_class_name %>"></div>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbOverlay
|
5
|
+
class Overlay < Playbook::KitBase
|
6
|
+
prop :color, type: Playbook::Props::Enum,
|
7
|
+
values: %w[card_light bg_light card_dark bg_dark],
|
8
|
+
default: "card_light"
|
9
|
+
prop :layout, type: Playbook::Props::HashProp,
|
10
|
+
default: { "bottom": "full" }
|
11
|
+
|
12
|
+
def classname
|
13
|
+
generate_classname("pb_overlay")
|
14
|
+
end
|
15
|
+
|
16
|
+
def position
|
17
|
+
layout.keys[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def size
|
21
|
+
layout.values[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_size_percentage
|
25
|
+
size.include?("%")
|
26
|
+
end
|
27
|
+
|
28
|
+
def previous_overlay
|
29
|
+
"linear-gradient(#{previous_overlay_direction}, #{color_map[color.to_sym]} 0%, transparent #{size})"
|
30
|
+
end
|
31
|
+
|
32
|
+
def subsequent_overlay
|
33
|
+
"linear-gradient(#{subsequent_overlay_direction}, #{color_map[color.to_sym]} 0%, transparent #{size})"
|
34
|
+
end
|
35
|
+
|
36
|
+
def previous_overlay_class_name
|
37
|
+
"overlay_#{color}_#{previous_overlay_direction_token}_#{size}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def subsequent_overlay_class_name
|
41
|
+
"overlay_#{color}_#{subsequent_overlay_direction_token}_#{size}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def previous_overlay_direction
|
45
|
+
previous_overlay_direction_map[position.to_sym]
|
46
|
+
end
|
47
|
+
|
48
|
+
def subsequent_overlay_direction
|
49
|
+
subsequent_overlay_direction_map[position.to_sym]
|
50
|
+
end
|
51
|
+
|
52
|
+
def previous_overlay_direction_token
|
53
|
+
has_subsequent_overlay ? previous_overlay_direction_map_token[position.to_sym] : position
|
54
|
+
end
|
55
|
+
|
56
|
+
def subsequent_overlay_direction_token
|
57
|
+
has_subsequent_overlay ? subsequent_overlay_direction_map_token[position.to_sym] : position
|
58
|
+
end
|
59
|
+
|
60
|
+
def previous_overlay_direction_map
|
61
|
+
{
|
62
|
+
"bottom": "to top",
|
63
|
+
"top": "to bottom",
|
64
|
+
"left": "to right",
|
65
|
+
"right": "to left",
|
66
|
+
"x": "to right",
|
67
|
+
"y": "to top",
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def subsequent_overlay_direction_map
|
72
|
+
{
|
73
|
+
"bottom": "to top",
|
74
|
+
"top": "to bottom",
|
75
|
+
"left": "to right",
|
76
|
+
"right": "to left",
|
77
|
+
"x": "to left",
|
78
|
+
"y": "to bottom",
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def previous_overlay_direction_map_token
|
83
|
+
{
|
84
|
+
"x": "left",
|
85
|
+
"y": "top",
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
def subsequent_overlay_direction_map_token
|
90
|
+
{
|
91
|
+
"x": "right",
|
92
|
+
"y": "bottom",
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def has_subsequent_overlay
|
97
|
+
position == "x".to_sym || position == "y".to_sym
|
98
|
+
end
|
99
|
+
|
100
|
+
def color_map
|
101
|
+
{
|
102
|
+
"card_light": "#fff",
|
103
|
+
"bg_light": "#F3F7FB",
|
104
|
+
"card_dark": "#231E3D",
|
105
|
+
"bg_dark": "#0a0527",
|
106
|
+
}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -86,33 +86,18 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
86
86
|
const toolbarElement = element.parentElement.querySelector('trix-toolbar') as HTMLElement,
|
87
87
|
blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
|
88
88
|
|
89
|
+
// replace default trix "block code" button with "inline code" button
|
89
90
|
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]') as HTMLElement
|
90
|
-
if (!inlineCodeButton)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
if (!inlineCodeButton) {
|
92
|
+
inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
|
93
|
+
blockCodeButton.hidden = true
|
94
|
+
// set button attributes
|
95
|
+
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
96
|
+
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
97
|
+
}
|
95
98
|
|
96
99
|
if (toolbarBottom) editor.element.after(toolbarElement)
|
97
100
|
|
98
|
-
const getCodeFormattingType = (): string => {
|
99
|
-
if (editor.attributeIsActive('code')) return 'block'
|
100
|
-
if (editor.attributeIsActive('inlineCode')) return 'inline'
|
101
|
-
|
102
|
-
const range = editor.getSelectedRange()
|
103
|
-
if (range[0] == range[1]) return 'block'
|
104
|
-
|
105
|
-
const text = editor.getSelectedDocument().toString().trim()
|
106
|
-
return /\n/.test(text) ? 'block' : 'inline'
|
107
|
-
}
|
108
|
-
|
109
|
-
// DOM event listeners
|
110
|
-
element.addEventListener('trix-selection-change', () => {
|
111
|
-
const type = getCodeFormattingType()
|
112
|
-
blockCodeButton.hidden = type == 'inline'
|
113
|
-
inlineCodeButton.hidden = type == 'block'
|
114
|
-
})
|
115
|
-
|
116
101
|
focus
|
117
102
|
? (document.addEventListener('trix-focus', useFocus),
|
118
103
|
document.addEventListener('trix-blur', useFocus),
|
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|
2
2
|
import classnames from "classnames";
|
3
3
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
5
|
-
import { globalProps } from "../utilities/globalProps";
|
5
|
+
import { globalProps, domSafeProps } from "../utilities/globalProps";
|
6
6
|
|
7
7
|
import Checkbox from "../pb_checkbox/_checkbox";
|
8
8
|
import ListItem from "../pb_list/_list_item";
|
@@ -16,6 +16,7 @@ export type SelectableListItemProps = {
|
|
16
16
|
className?: string;
|
17
17
|
data?: GenericObject;
|
18
18
|
defaultChecked?: boolean;
|
19
|
+
dragId?: string;
|
19
20
|
dragHandle?: boolean;
|
20
21
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
21
22
|
id?: string;
|
@@ -33,6 +34,7 @@ const SelectableListItem = ({
|
|
33
34
|
children,
|
34
35
|
className,
|
35
36
|
data = {},
|
37
|
+
dragId,
|
36
38
|
dragHandle = true,
|
37
39
|
defaultChecked,
|
38
40
|
htmlOptions = {},
|
@@ -67,7 +69,7 @@ const SelectableListItem = ({
|
|
67
69
|
{...props}
|
68
70
|
className={classnames(checkedState ? "checked_item" : "", className)}
|
69
71
|
dragHandle={dragHandle}
|
70
|
-
|
72
|
+
dragId={dragId}
|
71
73
|
>
|
72
74
|
<div
|
73
75
|
{...ariaProps}
|
@@ -106,7 +108,9 @@ const SelectableListItem = ({
|
|
106
108
|
text={label}
|
107
109
|
type="radio"
|
108
110
|
value={value}
|
109
|
-
|
111
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
112
|
+
//@ts-ignore
|
113
|
+
{...domSafeProps(props)}
|
110
114
|
/>
|
111
115
|
{children}
|
112
116
|
</>
|
@@ -14,7 +14,7 @@ type SelectableListProps = {
|
|
14
14
|
children?: React.ReactElement[],
|
15
15
|
className?: string,
|
16
16
|
data?: GenericObject,
|
17
|
-
|
17
|
+
enableDrag?: boolean,
|
18
18
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
19
19
|
id?: string,
|
20
20
|
variant?: 'checkbox' | 'radio',
|
@@ -26,7 +26,7 @@ const SelectableList = (props: SelectableListProps) => {
|
|
26
26
|
children,
|
27
27
|
className,
|
28
28
|
data = {},
|
29
|
-
|
29
|
+
enableDrag = false,
|
30
30
|
htmlOptions = {},
|
31
31
|
id,
|
32
32
|
} = props
|
@@ -68,7 +68,7 @@ const SelectableList = (props: SelectableListProps) => {
|
|
68
68
|
className={classes}
|
69
69
|
id={id}
|
70
70
|
>
|
71
|
-
<List
|
71
|
+
<List enableDrag={enableDrag}
|
72
72
|
variant={props.variant}
|
73
73
|
>
|
74
74
|
{selectableListItems}
|
@@ -52,6 +52,20 @@
|
|
52
52
|
data: object.data,
|
53
53
|
id: object.id,
|
54
54
|
**combined_html_options) do %>
|
55
|
-
|
55
|
+
<% unless sorting_style? %>
|
56
|
+
<%= content.presence || object.text %>
|
57
|
+
<% else %>
|
58
|
+
<%= link_to next_link, style: link_style do %>
|
59
|
+
<%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_link" }) do %>
|
60
|
+
<%= content.presence || object.text %>
|
61
|
+
<% if sorting_style? %>
|
62
|
+
<%= pb_rails("icon", props: { icon: object.sort_icon(active_item[:direction], active_item[:active]),
|
63
|
+
fixed_width: true,
|
64
|
+
classname: active_item.any? ? "pb_th_active" : "",
|
65
|
+
padding_left: "xs" }) %>
|
66
|
+
<% end %>
|
67
|
+
<% end %>
|
68
|
+
<% end %>
|
69
|
+
<% end %>
|
70
|
+
<% end %>
|
56
71
|
<% end %>
|
57
|
-
<% end %>
|