playbook_ui 13.32.0.pre.alpha.PBNTR405dropdownformfixesrails3301 → 13.32.0.pre.alpha.PLAY1138iconkitaddcolorprop3268
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_bar_graph/docs/_bar_graph_custom.md +0 -4
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +7 -12
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -11
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +1 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +17 -75
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +5 -108
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +2 -11
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.html.erb +1 -5
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +0 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.html.erb +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.html.erb +1 -4
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +2 -3
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +0 -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 +1 -5
- data/app/pb_kits/playbook/pb_icon/_icon.scss +27 -210
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +44 -100
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb +7 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx +46 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -0
- data/app/pb_kits/playbook/pb_icon/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_icon/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_icon/icon.rb +28 -34
- data/app/pb_kits/playbook/pb_icon/icon_aliases.json +39 -0
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +2 -2
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_nav/nav.rb +0 -9
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +2 -11
- data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -25
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +0 -6
- data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/index.ts +4 -4
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -2
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +27 -45
- data/app/pb_kits/playbook/pb_textarea/index.tsx +3 -3
- data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
- data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +2 -1
- data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +0 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -4
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +7 -11
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +3 -8
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +1 -6
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +19 -18
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.html.erb +57 -22
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -2
- data/app/pb_kits/playbook/pb_typeahead/index.ts +31 -31
- data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
- data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +235 -236
- data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +63 -68
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +2 -2
- data/app/pb_kits/playbook/playbook-rails.js +0 -6
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/forms/builder.rb +0 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -13
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.jsx +0 -31
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.jsx +0 -31
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +0 -53
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.html.erb +0 -48
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.md +0 -3
- data/app/pb_kits/playbook/pb_nav/index.js +0 -43
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_interactive.html.erb +0 -1
- data/app/pb_kits/playbook/pb_star_rating/index.js +0 -50
- data/lib/playbook/forms/builder/star_rating_field.rb +0 -14
@@ -1,3 +1,30 @@
|
|
1
|
+
@import "../tokens/colors";
|
2
|
+
|
3
|
+
// All the merges below create $icon_colors, a map of all color tokens in colors.scss
|
4
|
+
$merge_kits1: map-merge($status_colors, $category_colors);
|
5
|
+
$merge_kits2: map-merge($merge_kits1, $product_colors);
|
6
|
+
$merge_kits3: map-merge($merge_kits2, $text_colors);
|
7
|
+
$merge_kits4: map-merge($merge_kits3, $card_colors);
|
8
|
+
$merge_kits5: map-merge($merge_kits4, $action_colors);
|
9
|
+
$merge_kits6: map-merge($merge_kits5, $data_colors);
|
10
|
+
$merge_kits7: map-merge($merge_kits6, $border_colors);
|
11
|
+
$merge_kits8: map-merge($merge_kits7, $interface_colors);
|
12
|
+
$merge_kits9: map-merge($merge_kits8, $main_colors);
|
13
|
+
$merge_kits10: map-merge($merge_kits9, $shadow_colors);
|
14
|
+
$merge_kits11: map-merge($merge_kits10, $text_colors);
|
15
|
+
$merge_kits12: map-merge($merge_kits11, $status_color_text);
|
16
|
+
$merge_kits13: map-merge($merge_kits12, $status_color_text_dark);
|
17
|
+
$icon_colors: map-merge($merge_kits13, $colors);
|
18
|
+
|
19
|
+
.pb_custom_icon, .pb_icon_kit {
|
20
|
+
@each $color_name, $color_value in $icon_colors {
|
21
|
+
&[class*="#{$color_name}"] {
|
22
|
+
color: $color_value;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// Rails custom icon styles
|
1
28
|
svg.pb_custom_icon {
|
2
29
|
width: 1em;
|
3
30
|
fill: currentColor;
|
@@ -9,213 +36,3 @@ svg.pb_custom_icon {
|
|
9
36
|
.pb_icon_kit_emoji {
|
10
37
|
font-family: monospace;
|
11
38
|
}
|
12
|
-
|
13
|
-
$rotate-list: (90, 180, 270);
|
14
|
-
|
15
|
-
@keyframes pb_icon_spin {
|
16
|
-
0% {
|
17
|
-
-webkit-transform: rotate(0);
|
18
|
-
transform: rotate(0);
|
19
|
-
}
|
20
|
-
100% {
|
21
|
-
-webkit-transform: rotate(360deg);
|
22
|
-
transform: rotate(360deg);
|
23
|
-
}
|
24
|
-
};
|
25
|
-
|
26
|
-
svg {
|
27
|
-
&.pb_icon_kit,
|
28
|
-
&.pb_custom_icon{
|
29
|
-
@each $r in $rotate-list {
|
30
|
-
&.rotate_#{$r} {
|
31
|
-
transform: rotate(#{$r}deg);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
&.flip_horizontal {
|
35
|
-
transform: scaleX(-1);
|
36
|
-
}
|
37
|
-
&.flip_vertical {
|
38
|
-
transform: scaleY(-1);
|
39
|
-
}
|
40
|
-
&.flip_horizontal.flip_vertical {
|
41
|
-
transform: scaleX(-1) scaleY(-1);
|
42
|
-
}
|
43
|
-
&.svg-inline--fa {
|
44
|
-
height: 1em;
|
45
|
-
overflow: visible;
|
46
|
-
vertical-align: -.125em
|
47
|
-
}
|
48
|
-
&.svg_inverse {
|
49
|
-
color: #fff;
|
50
|
-
}
|
51
|
-
&.svg_border {
|
52
|
-
border-color: #eee;
|
53
|
-
border-radius: .1em;
|
54
|
-
border-style: solid;
|
55
|
-
border-width: .08em;
|
56
|
-
padding: .2em .25em .15em;
|
57
|
-
}
|
58
|
-
&.svg_fw {
|
59
|
-
text-align: center;
|
60
|
-
width: 1.25em
|
61
|
-
}
|
62
|
-
&.svg_li {
|
63
|
-
left: calc(2em * -1);
|
64
|
-
position: absolute;
|
65
|
-
text-align: center;
|
66
|
-
width: 2em;
|
67
|
-
line-height: inherit
|
68
|
-
}
|
69
|
-
&.pull_left {
|
70
|
-
float: left;
|
71
|
-
margin-right: .3em;
|
72
|
-
}
|
73
|
-
|
74
|
-
&.pull_right {
|
75
|
-
float: right;
|
76
|
-
margin-left: .3em;
|
77
|
-
}
|
78
|
-
&.pulse {
|
79
|
-
animation-name: pb_icon_spin;
|
80
|
-
animation-direction: normal;
|
81
|
-
animation-duration: 1s;
|
82
|
-
animation-iteration-count: infinite;
|
83
|
-
animation-timing-function: steps(8);
|
84
|
-
}
|
85
|
-
&.spin {
|
86
|
-
animation-name: pb_icon_spin;
|
87
|
-
animation-delay: 0s;
|
88
|
-
animation-direction: normal;
|
89
|
-
animation-duration: 2s;
|
90
|
-
animation-iteration-count: infinite;
|
91
|
-
animation-timing-function: linear;
|
92
|
-
}
|
93
|
-
|
94
|
-
&.svg_xs {
|
95
|
-
font-size: 0.75em
|
96
|
-
}
|
97
|
-
|
98
|
-
&.svg_sm {
|
99
|
-
font-size: 0.875em
|
100
|
-
}
|
101
|
-
|
102
|
-
&.svg_lg {
|
103
|
-
font-size: 1.25em
|
104
|
-
}
|
105
|
-
|
106
|
-
&.svg_1x {
|
107
|
-
font-size: 1em
|
108
|
-
}
|
109
|
-
|
110
|
-
&.svg_2x {
|
111
|
-
font-size: 2em
|
112
|
-
}
|
113
|
-
|
114
|
-
&.svg_3x {
|
115
|
-
font-size: 3em
|
116
|
-
}
|
117
|
-
|
118
|
-
&.svg_4x {
|
119
|
-
font-size: 4em
|
120
|
-
}
|
121
|
-
|
122
|
-
&.svg_5x {
|
123
|
-
font-size: 5em
|
124
|
-
}
|
125
|
-
|
126
|
-
&.svg_6x {
|
127
|
-
font-size: 6em
|
128
|
-
}
|
129
|
-
|
130
|
-
&.svg_7x {
|
131
|
-
font-size: 7em
|
132
|
-
}
|
133
|
-
|
134
|
-
&.svg_8x {
|
135
|
-
font-size: 8em
|
136
|
-
}
|
137
|
-
|
138
|
-
&.svg_9x {
|
139
|
-
font-size: 9em
|
140
|
-
}
|
141
|
-
|
142
|
-
&.svg_10x {
|
143
|
-
font-size: 10em
|
144
|
-
}
|
145
|
-
&.fa-xs {
|
146
|
-
font-size: .75em;
|
147
|
-
line-height: .0833333337em;
|
148
|
-
vertical-align: .125em
|
149
|
-
}
|
150
|
-
&.fa-sm {
|
151
|
-
font-size: .875em;
|
152
|
-
line-height: .0714285718em;
|
153
|
-
vertical-align: .0535714295em
|
154
|
-
}
|
155
|
-
&.fa-lg {
|
156
|
-
font-size: 1.25em;
|
157
|
-
line-height: .05em;
|
158
|
-
vertical-align: -.075em
|
159
|
-
}
|
160
|
-
&.fa-pull-left {
|
161
|
-
float: left;
|
162
|
-
margin-right: .3em;
|
163
|
-
}
|
164
|
-
|
165
|
-
&.fa-pull-right {
|
166
|
-
float: right;
|
167
|
-
margin-left: .3em;
|
168
|
-
}
|
169
|
-
&.fa-li {
|
170
|
-
left: calc(2em * -1);
|
171
|
-
position: absolute;
|
172
|
-
text-align: center;
|
173
|
-
width: 2em;
|
174
|
-
line-height: inherit
|
175
|
-
}
|
176
|
-
&.svg-inline--fa.fa-li {
|
177
|
-
width: 2em;
|
178
|
-
top: .25em
|
179
|
-
}
|
180
|
-
&.svg-inline--fa.fa-fw {
|
181
|
-
width: 1.25em;
|
182
|
-
}
|
183
|
-
&.fa-fw {
|
184
|
-
text-align: center;
|
185
|
-
width: 1.25em
|
186
|
-
}
|
187
|
-
&.fa-layers {
|
188
|
-
display: inline-block;
|
189
|
-
height: 1em;
|
190
|
-
position: relative;
|
191
|
-
text-align: center;
|
192
|
-
vertical-align: -.125em;
|
193
|
-
width: 1em
|
194
|
-
}
|
195
|
-
&.fa-2x {
|
196
|
-
font-size: 2em
|
197
|
-
}
|
198
|
-
&.fa-3x {
|
199
|
-
font-size: 3em
|
200
|
-
}
|
201
|
-
&.fa-flip {
|
202
|
-
animation-name: fa-flip;
|
203
|
-
animation-delay: 0s;
|
204
|
-
animation-direction: normal;
|
205
|
-
animation-duration: 1s;
|
206
|
-
animation-iteration-count: infinite;
|
207
|
-
animation-timing-function: ease-in-out;
|
208
|
-
}
|
209
|
-
&.fa-spin {
|
210
|
-
animation-name: fa-spin;
|
211
|
-
animation-delay: 0s;
|
212
|
-
animation-direction: normal;
|
213
|
-
animation-duration: 2s;
|
214
|
-
animation-iteration-count: infinite;
|
215
|
-
animation-timing-function: linear;
|
216
|
-
}
|
217
|
-
&.fa-pulse {
|
218
|
-
animation: fa-spin 1s infinite linear;
|
219
|
-
}
|
220
|
-
}
|
221
|
-
}
|
@@ -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"
|
@@ -23,6 +24,7 @@ type IconProps = {
|
|
23
24
|
aria?: {[key: string]: string},
|
24
25
|
border?: string,
|
25
26
|
className?: string,
|
27
|
+
color?: string,
|
26
28
|
customIcon?: {[key: string] :SVGElement},
|
27
29
|
data?: {[key: string]: string},
|
28
30
|
fixedWidth?: boolean,
|
@@ -40,75 +42,24 @@ type IconProps = {
|
|
40
42
|
spin?: boolean,
|
41
43
|
} & GlobalProps
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
both: 'fa-flip-horizontal fa-flip-vertical',
|
48
|
-
none: ''
|
49
|
-
},
|
50
|
-
svg: {
|
51
|
-
horizontal: 'flip_horizontal',
|
52
|
-
vertical: 'flip_vertical',
|
53
|
-
both: 'flip_horizontal flip_vertical',
|
54
|
-
none: ''
|
55
|
-
}
|
56
|
-
}
|
57
|
-
const pulseMap = {
|
58
|
-
fa: 'fa-pulse',
|
59
|
-
svg: 'pulse'
|
60
|
-
}
|
61
|
-
const spinMap = {
|
62
|
-
fa: 'fa-spin',
|
63
|
-
svg: 'spin'
|
45
|
+
type AliasType = string | string[];
|
46
|
+
|
47
|
+
interface Aliases {
|
48
|
+
[key: string]: AliasType;
|
64
49
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
180: 'fa-rotate-180',
|
69
|
-
270: 'fa-rotate-270'
|
70
|
-
},
|
71
|
-
svg: {
|
72
|
-
90: 'rotate_90',
|
73
|
-
180: 'rotate_180',
|
74
|
-
270: 'rotate_270'
|
75
|
-
}
|
50
|
+
|
51
|
+
interface AliasesJson {
|
52
|
+
aliases: Aliases;
|
76
53
|
}
|
77
54
|
|
78
|
-
const
|
79
|
-
|
80
|
-
"lg": "fa-lg",
|
81
|
-
"xs": "fa-xs",
|
82
|
-
"sm": "fa-sm",
|
83
|
-
"1x": "fa-1x",
|
84
|
-
"2x": "fa-2x",
|
85
|
-
"3x": "fa-3x",
|
86
|
-
"4x": "fa-4x",
|
87
|
-
"5x": "fa-5x",
|
88
|
-
"6x": "fa-6x",
|
89
|
-
"7x": "fa-7x",
|
90
|
-
"8x": "fa-8x",
|
91
|
-
"9x": "fa-9x",
|
92
|
-
"10x": "fa-10x",
|
93
|
-
"": ""
|
94
|
-
},
|
95
|
-
svg: {
|
96
|
-
"lg": "svg_lg",
|
97
|
-
"xs": "svg_xs",
|
98
|
-
"sm": "svg_sm",
|
99
|
-
"1x": "svg_1x",
|
100
|
-
"2x": "svg_2x",
|
101
|
-
"3x": "svg_3x",
|
102
|
-
"4x": "svg_4x",
|
103
|
-
"5x": "svg_5x",
|
104
|
-
"6x": "svg_6x",
|
105
|
-
"7x": "svg_7x",
|
106
|
-
"8x": "svg_8x",
|
107
|
-
"9x": "svg_9x",
|
108
|
-
"10x": "svg_10x",
|
109
|
-
"": ""
|
110
|
-
}
|
55
|
+
const aliases: AliasesJson = aliasesJson;
|
56
|
+
|
111
57
|
|
58
|
+
const flipMap = {
|
59
|
+
horizontal: 'fa-flip-horizontal',
|
60
|
+
vertical: 'fa-flip-vertical',
|
61
|
+
both: 'fa-flip-horizontal fa-flip-vertical',
|
62
|
+
none: ""
|
112
63
|
}
|
113
64
|
|
114
65
|
declare global {
|
@@ -116,11 +67,28 @@ declare global {
|
|
116
67
|
var PB_ICONS: {[key: string]: React.FunctionComponent<any>}
|
117
68
|
}
|
118
69
|
|
70
|
+
// Resolve alias function
|
71
|
+
const resolveAlias = (icon: string): string => {
|
72
|
+
const alias = aliases.aliases[icon];
|
73
|
+
|
74
|
+
if (alias) {
|
75
|
+
if (Array.isArray(alias)) {
|
76
|
+
return alias[0];
|
77
|
+
} else {
|
78
|
+
return alias;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
return icon;
|
83
|
+
};
|
84
|
+
|
85
|
+
|
119
86
|
const Icon = (props: IconProps) => {
|
120
87
|
const {
|
121
88
|
aria = {},
|
122
89
|
border = false,
|
123
90
|
className,
|
91
|
+
color,
|
124
92
|
customIcon,
|
125
93
|
data = {},
|
126
94
|
fixedWidth = true,
|
@@ -138,7 +106,8 @@ const Icon = (props: IconProps) => {
|
|
138
106
|
spin = false,
|
139
107
|
} = props
|
140
108
|
|
141
|
-
|
109
|
+
const resolvedIcon = resolveAlias(icon as string)
|
110
|
+
let iconElement: ReactSVGElement | null = typeof(resolvedIcon) === "object" ? resolvedIcon : null
|
142
111
|
|
143
112
|
const faClasses = {
|
144
113
|
'fa-border': border,
|
@@ -154,58 +123,33 @@ const Icon = (props: IconProps) => {
|
|
154
123
|
|
155
124
|
if (!customIcon && !iconElement) {
|
156
125
|
const PowerIcon: React.FunctionComponent<any> | undefined =
|
157
|
-
window.PB_ICONS ? window.PB_ICONS[
|
126
|
+
window.PB_ICONS ? window.PB_ICONS[resolvedIcon as string] : null
|
158
127
|
|
159
128
|
if (PowerIcon) {
|
160
129
|
iconElement = <PowerIcon /> as ReactSVGElement
|
161
130
|
} else {
|
162
|
-
faClasses[`fa-${
|
131
|
+
faClasses[`fa-${resolvedIcon}`] = resolvedIcon as string
|
163
132
|
}
|
164
133
|
}
|
165
134
|
|
166
|
-
const
|
167
|
-
|
168
|
-
let classes = classnames(
|
135
|
+
const classes = classnames(
|
136
|
+
flipMap[flip],
|
169
137
|
(!iconElement && !customIcon) ? 'pb_icon_kit' : '',
|
170
138
|
(iconElement || customIcon) ? 'pb_custom_icon' : fontStyle,
|
171
139
|
iconElement ? 'svg-inline--fa' : '',
|
140
|
+
faClasses,
|
141
|
+
color ? `color_${color}` : '',
|
172
142
|
globalProps(props),
|
173
143
|
className
|
174
144
|
)
|
175
145
|
|
176
|
-
const transformClasses = classnames(
|
177
|
-
flip ? flipMap[isFA ? 'fa' : 'svg'][flip] : null,
|
178
|
-
pulse ? pulseMap[isFA ? 'fa' : 'svg'] : null,
|
179
|
-
rotation ? rotateMap[isFA ? 'fa' : 'svg'][rotation] : null,
|
180
|
-
spin ? spinMap[isFA ? 'fa' : 'svg'] : null,
|
181
|
-
size ? sizeMap[isFA ? 'fa' : 'svg'][size] : null,
|
182
|
-
border ? isFA ? 'fa-border' : 'svg_border' : null,
|
183
|
-
fixedWidth ? isFA ? 'fa-fw' : 'svg_fw' : null,
|
184
|
-
inverse ? isFA ? 'fa-inverse' : 'svg_inverse' : null,
|
185
|
-
listItem ? isFA ? 'fa-li' : 'svg_li' : null,
|
186
|
-
pull ? isFA ? `fa-pull-${pull}` : `pull_${pull}` : null,
|
187
|
-
)
|
188
|
-
classes += ` ${transformClasses}`
|
189
|
-
|
190
|
-
if (isFA) {
|
191
|
-
const faClassList = {
|
192
|
-
'fa-border': border,
|
193
|
-
'fa-inverse': inverse,
|
194
|
-
'fa-li': listItem,
|
195
|
-
[`fa-${size}`]: size,
|
196
|
-
[`fa-pull-${pull}`]: pull,
|
197
|
-
}
|
198
|
-
faClassList[`fa-${icon}`] = icon as string
|
199
|
-
classes += ` ${classnames(faClassList)}`
|
200
|
-
}
|
201
|
-
|
202
146
|
const classesEmoji = classnames(
|
203
147
|
'pb_icon_kit_emoji',
|
204
148
|
globalProps(props),
|
205
149
|
className
|
206
150
|
)
|
207
151
|
|
208
|
-
aria.label ? null : aria.label = `${
|
152
|
+
aria.label ? null : aria.label = `${resolvedIcon} icon`
|
209
153
|
const ariaProps: {[key: string]: any} = buildAriaProps(aria)
|
210
154
|
const dataProps: {[key: string]: any} = buildDataProps(data)
|
211
155
|
const htmlProps = buildHtmlProps(htmlOptions)
|
@@ -227,7 +171,7 @@ const Icon = (props: IconProps) => {
|
|
227
171
|
}
|
228
172
|
</>
|
229
173
|
)
|
230
|
-
else if (isValidEmoji(
|
174
|
+
else if (isValidEmoji(resolvedIcon as string))
|
231
175
|
return (
|
232
176
|
<>
|
233
177
|
<span
|
@@ -236,7 +180,7 @@ const Icon = (props: IconProps) => {
|
|
236
180
|
className={classesEmoji}
|
237
181
|
id={id}
|
238
182
|
>
|
239
|
-
{
|
183
|
+
{resolvedIcon}
|
240
184
|
</span>
|
241
185
|
</>
|
242
186
|
)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= pb_rails("flex", props: {orientation: "column"}) do %>
|
2
|
+
<%= pb_rails("icon", props: { icon: "user", fixed_width: true, color: "primary", size: "2x" }) %>
|
3
|
+
<%= pb_rails("icon", props: { icon: "recycle", fixed_width: true, color: "info", size: "2x" }) %>
|
4
|
+
<%= pb_rails("icon", props: { icon: "frog", fixed_width: true, color: "data_4", size: "2x" }) %>
|
5
|
+
<%= pb_rails("icon", props: { icon: "vial", fixed_width: true, color: "text_lt_lighter", size: "2x" }) %>
|
6
|
+
<%= pb_rails("icon", props: { icon: "roofing", fixed_width: true, color: "product_roofing", size: "2x" }) %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import Icon from "../_icon"
|
3
|
+
|
4
|
+
const IconDefault = (props) => {
|
5
|
+
return (
|
6
|
+
<div style={{ display: "flex", flexDirection: "column"}}>
|
7
|
+
<Icon
|
8
|
+
color="primary"
|
9
|
+
fixedWidth
|
10
|
+
icon="user"
|
11
|
+
size="2x"
|
12
|
+
{...props}
|
13
|
+
/>
|
14
|
+
<Icon
|
15
|
+
color="info"
|
16
|
+
fixedWidth
|
17
|
+
icon="recycle"
|
18
|
+
size="2x"
|
19
|
+
{...props}
|
20
|
+
/>
|
21
|
+
<Icon
|
22
|
+
color="data_4"
|
23
|
+
fixedWidth
|
24
|
+
icon="frog"
|
25
|
+
size="2x"
|
26
|
+
{...props}
|
27
|
+
/>
|
28
|
+
<Icon
|
29
|
+
color="text_lt_lighter"
|
30
|
+
fixedWidth
|
31
|
+
icon="vial"
|
32
|
+
size="2x"
|
33
|
+
{...props}
|
34
|
+
/>
|
35
|
+
<Icon
|
36
|
+
color="roofing"
|
37
|
+
fixedWidth
|
38
|
+
icon="product-roofing"
|
39
|
+
size="2x"
|
40
|
+
{...props}
|
41
|
+
/>
|
42
|
+
</div>
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
export default IconDefault
|
@@ -0,0 +1 @@
|
|
1
|
+
Pass any Playbook <a href="https://playbook.powerapp.cloud/visual_guidelines/colors" target="_blank">color token</a> to the `color` prop to change any icon's color.
|
@@ -9,6 +9,7 @@ examples:
|
|
9
9
|
- icon_sizes: Icon Sizes
|
10
10
|
- icon_custom: Icon Custom
|
11
11
|
- icon_fa_kit: Icon with FontAwesome Kit
|
12
|
+
- icon_color: Icon Color
|
12
13
|
|
13
14
|
react:
|
14
15
|
- icon_default: Icon Default
|
@@ -20,6 +21,7 @@ examples:
|
|
20
21
|
- icon_sizes: Icon Sizes
|
21
22
|
- icon_custom: Icon Custom
|
22
23
|
- icon_fa_kit: Icon with FontAwesome Kit
|
24
|
+
- icon_color: Icon Color
|
23
25
|
|
24
26
|
swift:
|
25
27
|
- icon_default_swift: Icon Default
|
@@ -7,3 +7,4 @@ export { default as IconBorder } from './_icon_border.jsx'
|
|
7
7
|
export { default as IconSizes } from './_icon_sizes.jsx'
|
8
8
|
export { default as IconCustom } from './_icon_custom.jsx'
|
9
9
|
export { default as IconFaKit} from './_icon_fa_kit.jsx'
|
10
|
+
export { default as IconColor } from './_icon_color.jsx'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Style/HashLikeCase
|
4
|
+
|
3
5
|
require "open-uri"
|
4
6
|
require "json"
|
5
7
|
|
@@ -36,6 +38,9 @@ module Playbook
|
|
36
38
|
default: "far"
|
37
39
|
prop :spin, type: Playbook::Props::Boolean,
|
38
40
|
default: false
|
41
|
+
prop :color, type: Playbook::Props::String
|
42
|
+
|
43
|
+
ALIASES = JSON.parse(File.read(Playbook::Engine.root.join("app/pb_kits/playbook/pb_icon/icon_aliases.json")))["aliases"].freeze
|
39
44
|
|
40
45
|
def valid_emoji?
|
41
46
|
emoji_regex = /\p{Emoji}/
|
@@ -45,6 +50,7 @@ module Playbook
|
|
45
50
|
def classname
|
46
51
|
generate_classname(
|
47
52
|
"pb_icon_kit",
|
53
|
+
color_class,
|
48
54
|
font_style_class,
|
49
55
|
icon_class,
|
50
56
|
border_class,
|
@@ -65,6 +71,7 @@ module Playbook
|
|
65
71
|
generate_classname(
|
66
72
|
"pb_icon_kit",
|
67
73
|
border_class,
|
74
|
+
color_class,
|
68
75
|
fixed_width_class,
|
69
76
|
flip_class,
|
70
77
|
inverse_class,
|
@@ -78,14 +85,6 @@ module Playbook
|
|
78
85
|
)
|
79
86
|
end
|
80
87
|
|
81
|
-
def icon_alias_map
|
82
|
-
return unless Rails.application.config.respond_to?(:icon_alias_path)
|
83
|
-
|
84
|
-
base_path = Rails.application.config.icon_alias_path
|
85
|
-
json = File.read(Rails.root.join(base_path))
|
86
|
-
JSON.parse(json)["aliases"].freeze
|
87
|
-
end
|
88
|
-
|
89
88
|
def asset_path
|
90
89
|
return unless Rails.application.config.respond_to?(:icon_path)
|
91
90
|
|
@@ -104,7 +103,8 @@ module Playbook
|
|
104
103
|
svg["aria"] = object.aria
|
105
104
|
svg["height"] = "auto"
|
106
105
|
svg["width"] = "auto"
|
107
|
-
|
106
|
+
fill_color = object.color || "currentColor"
|
107
|
+
doc.at_css("path")["fill"] = fill_color
|
108
108
|
raw doc
|
109
109
|
end
|
110
110
|
|
@@ -115,9 +115,7 @@ module Playbook
|
|
115
115
|
private
|
116
116
|
|
117
117
|
def resolve_alias(icon)
|
118
|
-
|
119
|
-
|
120
|
-
aliases = icon_alias_map[icon]
|
118
|
+
aliases = ALIASES[icon]
|
121
119
|
return icon unless aliases
|
122
120
|
|
123
121
|
if aliases.is_a?(Array)
|
@@ -137,13 +135,11 @@ module Playbook
|
|
137
135
|
end
|
138
136
|
|
139
137
|
def border_class
|
140
|
-
|
141
|
-
border ? prefix : nil
|
138
|
+
border ? "fa-border" : nil
|
142
139
|
end
|
143
140
|
|
144
141
|
def fixed_width_class
|
145
|
-
|
146
|
-
fixed_width ? prefix : nil
|
142
|
+
fixed_width ? "fa-fw" : nil
|
147
143
|
end
|
148
144
|
|
149
145
|
def icon_class
|
@@ -151,45 +147,38 @@ module Playbook
|
|
151
147
|
end
|
152
148
|
|
153
149
|
def inverse_class
|
154
|
-
|
155
|
-
inverse ? class_name : nil
|
150
|
+
inverse ? "fa-inverse" : nil
|
156
151
|
end
|
157
152
|
|
158
153
|
def list_item_class
|
159
|
-
|
160
|
-
list_item ? class_name : nil
|
154
|
+
list_item ? "fa-li" : nil
|
161
155
|
end
|
162
156
|
|
163
157
|
def flip_class
|
164
|
-
prefix = is_svg? ? "flip_" : "fa-flip-"
|
165
158
|
case flip
|
166
159
|
when "horizontal"
|
167
|
-
"
|
160
|
+
"fa-flip-horizontal"
|
168
161
|
when "vertical"
|
169
|
-
"
|
162
|
+
"fa-flip-vertical"
|
170
163
|
when "both"
|
171
|
-
"
|
164
|
+
"fa-flip-horizontal fa-flip-vertical"
|
172
165
|
end
|
173
166
|
end
|
174
167
|
|
175
168
|
def pull_class
|
176
|
-
|
177
|
-
pull ? class_name : nil
|
169
|
+
pull ? "fa-pull-#{pull}" : nil
|
178
170
|
end
|
179
171
|
|
180
172
|
def pulse_class
|
181
|
-
|
182
|
-
pulse ? class_name : nil
|
173
|
+
pulse ? "fa-pulse" : nil
|
183
174
|
end
|
184
175
|
|
185
176
|
def rotation_class
|
186
|
-
|
187
|
-
rotation ? class_name : nil
|
177
|
+
rotation ? "fa-rotate-#{rotation}" : nil
|
188
178
|
end
|
189
179
|
|
190
180
|
def size_class
|
191
|
-
|
192
|
-
size ? class_name : nil
|
181
|
+
size ? "fa-#{size}" : nil
|
193
182
|
end
|
194
183
|
|
195
184
|
def font_style_class
|
@@ -197,9 +186,14 @@ module Playbook
|
|
197
186
|
end
|
198
187
|
|
199
188
|
def spin_class
|
200
|
-
|
201
|
-
|
189
|
+
spin ? "fa-spin" : nil
|
190
|
+
end
|
191
|
+
|
192
|
+
def color_class
|
193
|
+
color ? "color_#{color}" : nil
|
202
194
|
end
|
203
195
|
end
|
204
196
|
end
|
205
197
|
end
|
198
|
+
|
199
|
+
# rubocop:enable Style/HashLikeCase
|