playbook_ui 13.32.0.pre.alpha.PLAY14103236 → 13.32.0.pre.alpha.play1416movealiaslogic3239
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_contact/contact.test.js +1 -1
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +6 -37
- data/app/pb_kits/playbook/pb_icon/icon.rb +9 -3
- data/app/pb_kits/playbook/pb_icon/icon_aliases.json +2 -24
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d2ad5fae80d023caae7a74a96bf549e74693d82376000d2d056ecdd94e5948
|
4
|
+
data.tar.gz: c3de45c50a99868c1a157179eb8912acfd173337bd94af3eb166c42d01c051ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83a30785c99181d6f62a6632ad1d52c6c7970f8a53dd42e01041814fe5c9f09ee969aa0c2a39b180b20f565492c096e94744ce3149cf407c8c2ed09c99636ec
|
7
|
+
data.tar.gz: 37992e6abfc459bdb39b5a62292a43c3d49a79e17261136c955929836de307c9677653338fe9635c619dc0314ca69b498348cbacea044279d1dd924e5edac86f
|
@@ -78,7 +78,7 @@ test('returns correct icon', () => {
|
|
78
78
|
expect(screen.getByTestId('test-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-mobile')
|
79
79
|
expect(screen.getByTestId('test-home').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
|
80
80
|
expect(screen.getByTestId('test-work').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-office')
|
81
|
-
|
81
|
+
expect(screen.getByTestId('test-work-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-laptop')
|
82
82
|
expect(screen.getByTestId('test-email').querySelector('.pb_icon_kit')).toHaveClass('fa-envelope')
|
83
83
|
expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-slash')
|
84
84
|
expect(screen.getByTestId('test-wrong-type').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
|
@@ -3,7 +3,6 @@ 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'
|
7
6
|
|
8
7
|
export type IconSizes = "lg"
|
9
8
|
| "xs"
|
@@ -41,19 +40,6 @@ type IconProps = {
|
|
41
40
|
spin?: boolean,
|
42
41
|
} & GlobalProps
|
43
42
|
|
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
|
-
|
57
43
|
const flipMap = {
|
58
44
|
horizontal: 'fa-flip-horizontal',
|
59
45
|
vertical: 'fa-flip-vertical',
|
@@ -66,22 +52,6 @@ declare global {
|
|
66
52
|
var PB_ICONS: {[key: string]: React.FunctionComponent<any>}
|
67
53
|
}
|
68
54
|
|
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
|
-
|
85
55
|
const Icon = (props: IconProps) => {
|
86
56
|
const {
|
87
57
|
aria = {},
|
@@ -104,8 +74,7 @@ const Icon = (props: IconProps) => {
|
|
104
74
|
spin = false,
|
105
75
|
} = props
|
106
76
|
|
107
|
-
|
108
|
-
let iconElement: ReactSVGElement | null = typeof(resolvedIcon) === "object" ? resolvedIcon : null
|
77
|
+
let iconElement: ReactSVGElement | null = typeof(icon) === "object" ? icon : null
|
109
78
|
|
110
79
|
const faClasses = {
|
111
80
|
'fa-border': border,
|
@@ -121,12 +90,12 @@ const Icon = (props: IconProps) => {
|
|
121
90
|
|
122
91
|
if (!customIcon && !iconElement) {
|
123
92
|
const PowerIcon: React.FunctionComponent<any> | undefined =
|
124
|
-
window.PB_ICONS ? window.PB_ICONS[
|
93
|
+
window.PB_ICONS ? window.PB_ICONS[icon as string] : null
|
125
94
|
|
126
95
|
if (PowerIcon) {
|
127
96
|
iconElement = <PowerIcon /> as ReactSVGElement
|
128
97
|
} else {
|
129
|
-
faClasses[`fa-${
|
98
|
+
faClasses[`fa-${icon}`] = icon as string
|
130
99
|
}
|
131
100
|
}
|
132
101
|
|
@@ -146,7 +115,7 @@ const Icon = (props: IconProps) => {
|
|
146
115
|
className
|
147
116
|
)
|
148
117
|
|
149
|
-
aria.label ? null : aria.label = `${
|
118
|
+
aria.label ? null : aria.label = `${icon} icon`
|
150
119
|
const ariaProps: {[key: string]: any} = buildAriaProps(aria)
|
151
120
|
const dataProps: {[key: string]: any} = buildDataProps(data)
|
152
121
|
const htmlProps = buildHtmlProps(htmlOptions)
|
@@ -168,7 +137,7 @@ const Icon = (props: IconProps) => {
|
|
168
137
|
}
|
169
138
|
</>
|
170
139
|
)
|
171
|
-
else if (isValidEmoji(
|
140
|
+
else if (isValidEmoji(icon as string))
|
172
141
|
return (
|
173
142
|
<>
|
174
143
|
<span
|
@@ -177,7 +146,7 @@ const Icon = (props: IconProps) => {
|
|
177
146
|
className={classesEmoji}
|
178
147
|
id={id}
|
179
148
|
>
|
180
|
-
{
|
149
|
+
{icon}
|
181
150
|
</span>
|
182
151
|
</>
|
183
152
|
)
|
@@ -39,8 +39,6 @@ module Playbook
|
|
39
39
|
prop :spin, type: Playbook::Props::Boolean,
|
40
40
|
default: false
|
41
41
|
|
42
|
-
ALIASES = JSON.parse(File.read(Playbook::Engine.root.join("app/pb_kits/playbook/pb_icon/icon_aliases.json")))["aliases"].freeze
|
43
|
-
|
44
42
|
def valid_emoji?
|
45
43
|
emoji_regex = /\p{Emoji}/
|
46
44
|
emoji_regex.match?(icon)
|
@@ -82,6 +80,14 @@ module Playbook
|
|
82
80
|
)
|
83
81
|
end
|
84
82
|
|
83
|
+
def icon_alias_map
|
84
|
+
return unless Rails.application.config.respond_to?(:icon_alias_path)
|
85
|
+
|
86
|
+
base_path = Rails.application.config.icon_alias_path
|
87
|
+
json = File.read(Rails.root.join(base_path))
|
88
|
+
JSON.parse(json)["aliases"].freeze
|
89
|
+
end
|
90
|
+
|
85
91
|
def asset_path
|
86
92
|
return unless Rails.application.config.respond_to?(:icon_path)
|
87
93
|
|
@@ -111,7 +117,7 @@ module Playbook
|
|
111
117
|
private
|
112
118
|
|
113
119
|
def resolve_alias(icon)
|
114
|
-
aliases =
|
120
|
+
aliases = icon_alias_map[icon]
|
115
121
|
return icon unless aliases
|
116
122
|
|
117
123
|
if aliases.is_a?(Array)
|
@@ -1,20 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"aliases": {
|
3
|
-
"angles-down": "angle-double-down",
|
4
|
-
"arrow-alt-circle-left": "circle-left",
|
5
3
|
"arrow-alt-circle-right": "circle-right",
|
4
|
+
"angles-down": "angle-double-down",
|
6
5
|
"arrow-alt-down": "down",
|
7
6
|
"arrow-alt-up": "up",
|
8
|
-
"arrow-circle-down": "circle-down-arrow",
|
9
7
|
"arrow-right-long": "long-arrow-right",
|
10
8
|
"arrow-to-bottom": "arrow-down-to-line",
|
11
9
|
"arrows-h": "arrows-left-right",
|
12
|
-
"backward-step": "step-backward",
|
13
10
|
"calendar-days": "calendar-alt",
|
14
|
-
"chevrondown": "chevron-down",
|
15
|
-
"chevrons-down": "chevron-double-down",
|
16
|
-
"chevrons-left": "chevron-double-left",
|
17
|
-
"chevrons-right": "chevron-double-right",
|
18
11
|
"circle-arrow-right": "arrow-circle-right",
|
19
12
|
"clock-rotate-left": "history",
|
20
13
|
"close": [
|
@@ -25,37 +18,22 @@
|
|
25
18
|
"exclamation-circle": "circle-exclamation",
|
26
19
|
"external-link": "arrow-up-right-from-square",
|
27
20
|
"file-lines": "file-alt",
|
28
|
-
"floppy-disk": "save",
|
29
|
-
"forward-step": "step-forward",
|
30
21
|
"gear": "cog",
|
31
|
-
"hand-holding-dollar": "hand-holding-usd",
|
32
22
|
"home": "house",
|
33
23
|
"info-circle": "circle-info",
|
34
|
-
"location-pin": "map-marker",
|
35
24
|
"map-o": "map",
|
36
25
|
"message": "comment-alt",
|
37
26
|
"minus-circle": "circle-minus",
|
38
|
-
"mobile-screen-button": "mobile-alt",
|
39
27
|
"money": "money-bill",
|
40
28
|
"mouse-pointer": "arrow-pointer",
|
41
29
|
"nitro": "nitro-n",
|
42
|
-
"phone-laptop": "laptop-mobile",
|
43
30
|
"play-circle": "circle-play",
|
44
31
|
"plus-circle": "circle-plus",
|
45
32
|
"plus-square": "square-plus",
|
46
33
|
"powergon": "powergon-p",
|
47
34
|
"question-circle": "circle-question",
|
48
35
|
"roofing": "product-roofing",
|
49
|
-
"scissors": "shelves",
|
50
36
|
"shelves": "inventory",
|
51
|
-
"
|
52
|
-
"shuffle": "random",
|
53
|
-
"th-large": "table-cells-large",
|
54
|
-
"th-list": "table-list",
|
55
|
-
"thumbs-o-down": "thumbs-down",
|
56
|
-
"unlock": "lock-unlocked",
|
57
|
-
"unlock-keyhole": "lock-keyhole-unlocked",
|
58
|
-
"unlock-alt": "lock-keyhole-unlocked",
|
59
|
-
"usd-circle": "circle-dollar"
|
37
|
+
"th-list": "table-list"
|
60
38
|
}
|
61
39
|
}
|