playbook_ui 13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2306 → 13.19.0
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/_advanced_table.tsx +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +2 -13
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +1 -32
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.jsx +4 -38
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +16 -28
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +11 -5
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.jsx +18 -44
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.md +8 -4
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +4 -6
- data/app/pb_kits/playbook/pb_icon/icon.rb +10 -27
- data/app/pb_kits/playbook/pb_table/_table.tsx +67 -86
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_table/styles/_content.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_hover.scss +11 -11
- data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_reset.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_side_highlight.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_single-line.scss +4 -4
- data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +4 -4
- data/app/pb_kits/playbook/pb_table/styles/_structure.scss +6 -18
- data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +7 -7
- data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +14 -14
- data/app/pb_kits/playbook/pb_table/styles/_table_header.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +4 -3
- data/app/pb_kits/playbook/pb_table/table.html.erb +2 -12
- data/app/pb_kits/playbook/pb_table/table.rb +0 -3
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +7 -9
- data/app/pb_kits/playbook/pb_table/docs/_table_div.html.erb +0 -34
- data/app/pb_kits/playbook/pb_table/docs/_table_div.jsx +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e7f392fc3d4bc8c6c896b4b54fd0cf5fcb4953fc1de2ee8bd59f14e223462a5
|
4
|
+
data.tar.gz: 71904fc8f23cb411b2022643cb08167a3c8a882a9f1bd135dbbeb980674c0bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f2629ac4ad220d2c39ca406eb422a9ae0d04052f6bb893b3feceb1b909b281d19faa7a47e2f09a2003fb5ac2f2aa42bddabcf337b54ee345841d96be308ec3
|
7
|
+
data.tar.gz: cb38c42e015efbec6d56ed5d6cb4bdfe8c0cdeb91f4c8baeb02679348380c4dbca08f1a6d977bc3c23f0e761b43f1e9578ee1d4c1600cd94048fbe2970d6a27d
|
@@ -20,7 +20,7 @@ import AdvancedTableContext from "./Context/AdvancedTableContext";
|
|
20
20
|
import { TableHeader } from "./SubKits/TableHeader";
|
21
21
|
import { TableBody } from "./SubKits/TableBody";
|
22
22
|
|
23
|
-
import { DataType } from "./Utilities/types";
|
23
|
+
import { DataType, ExpandedStateObject } from "./Utilities/types";
|
24
24
|
|
25
25
|
type AdvancedTableProps = {
|
26
26
|
aria?: { [key: string]: string };
|
@@ -80,7 +80,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
80
80
|
? expandedControl.onChange
|
81
81
|
: setLocalExpanded;
|
82
82
|
|
83
|
-
const columnHelper = createColumnHelper();
|
83
|
+
const columnHelper = createColumnHelper<DataType>();
|
84
84
|
|
85
85
|
//Create cells for first columns
|
86
86
|
const createCellFunction = (cellAccessors: string[]) => {
|
@@ -163,7 +163,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
163
163
|
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
164
164
|
columns,
|
165
165
|
onExpandedChange: setExpanded,
|
166
|
-
getSubRows: (row
|
166
|
+
getSubRows: (row) => row.children,
|
167
167
|
getCoreRowModel: getCoreRowModel(),
|
168
168
|
getExpandedRowModel: getExpandedRowModel(),
|
169
169
|
getSortedRowModel: getSortedRowModel(),
|
@@ -192,7 +192,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
192
192
|
const handleExpandOrCollapse = (row: Row<DataType>) => {
|
193
193
|
onToggleExpansionClick && onToggleExpansionClick(row);
|
194
194
|
|
195
|
-
const expandedState = expanded;
|
195
|
+
const expandedState = expanded as ExpandedStateObject;
|
196
196
|
const targetParent = row?.parentId;
|
197
197
|
return setExpanded(
|
198
198
|
updateExpandAndCollapseState(tableRows, expandedState, targetParent)
|
@@ -1 +1 @@
|
|
1
|
-
`collapsibleTrail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of
|
1
|
+
`collapsibleTrail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of rows when subRows are toggled open.
|
@@ -8,7 +8,7 @@ For a visual of the data structure needed for `tableData`, see [here](https://gi
|
|
8
8
|
|
9
9
|
### columnDefinitions
|
10
10
|
|
11
|
-
`columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is
|
11
|
+
`columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is a array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
|
12
12
|
|
13
13
|
- `accessor`: this is the key from your data for the value you want rendered in that column
|
14
14
|
- `label`: this is what will be rendered as the column header label
|
@@ -1,3 +1,3 @@
|
|
1
1
|
the optional `loading` prop takes a boolean value that can be managed using state. If loading is true, the table will display the loading skeleton and once loading is false, the table will render with the data provided.
|
2
2
|
|
3
|
-
By default, the inital row count of the loading skeleton is set to 10. If you want more control over this initial row count, the optional `initialLoadingRowCount` prop can be used to pass in a number. __NOTE__: This is only for the first render of the table, subsequent loading skeleton row count logic is handled within the kit itself.
|
3
|
+
By default, the inital row count of the loading skeleton is set to 10. If you want more control over this initial row count, the optional `initialLoadingRowCount` prop can be used to to pass in a number. __NOTE__: This is only for the first render of the table, subsequent loading skeleton row count logic is handled within the kit itself.
|
@@ -1,3 +1,3 @@
|
|
1
1
|
`subRowHeaders` is an optional prop that if present will add header rows at each level of the nested data. The prop takes an array of strings, each string being the text for each header row. The array of strings must be in the order in which they need to be rendered in the UI according to depth.
|
2
2
|
|
3
|
-
`enableToggleExpansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enableToggleExpansion` is a string that can be 'all'
|
3
|
+
`enableToggleExpansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enableToggleExpansion` is a string that can be 'all' or 'header". If set to 'all', the toggle exapansion button will appear in the table header as well as in the subRow headers. If set to 'header' button will only appear in header and NOT in subRow headers. This is set to 'headeer' by default.
|
@@ -1,3 +1,3 @@
|
|
1
1
|
The Tanstack table consumes the useReactTable hook to create the table. This hook takes an object that can contain any of the functions that the Tanstack table provides. The advancedTable's optional `tableOptions` can be used to pass tanstack options to the kit.
|
2
2
|
|
3
|
-
In the above example, we are using the initialState option provided by tanstack that takes sort as one of it's values. Setting it to true for the first column is reversing the sort order on first render of the table. For a complete list of possible options and
|
3
|
+
In the above example, we are using the initialState option provided by tanstack that takes sort as one of it's values. Setting it to true for the first column is reversing the sort order on first render of the table. For a complete list of possible options and hoe to use them, see [here](https://tanstack.com/table/v8/docs/api/core/table#usereacttable--createsolidtable--usevuetable--createsveltetable)
|
@@ -56,14 +56,6 @@ $confirmation_toast_colors: (
|
|
56
56
|
transform: translateX(-50%);
|
57
57
|
}
|
58
58
|
|
59
|
-
@media only screen and (max-width: 600px) {
|
60
|
-
&.center {
|
61
|
-
left: 5%;
|
62
|
-
right: 5%;
|
63
|
-
transform: translateX(-0%);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
59
|
&.right {
|
68
60
|
left: auto;
|
69
61
|
right: $space_md;
|
@@ -91,11 +83,8 @@ $confirmation_toast_colors: (
|
|
91
83
|
&[class*=_multi_line] .pb_fixed_confirmation_toast_text {
|
92
84
|
color: $white;
|
93
85
|
margin: 0 $space_md 0 $space_md;
|
94
|
-
|
95
|
-
|
96
|
-
-webkit-line-clamp: 2;
|
97
|
-
-webkit-box-orient: vertical;
|
98
|
-
white-space: normal;
|
86
|
+
max-width: 100%;
|
87
|
+
white-space: break-spaces;
|
99
88
|
}
|
100
89
|
}
|
101
90
|
}
|
@@ -1,36 +1,5 @@
|
|
1
|
-
<%= pb_rails("button", props: { text: "Multiline Example", variant: "primary", data: { toast: "#toast-top-center-multi" } }) %>
|
2
|
-
|
3
1
|
<%= pb_rails("fixed_confirmation_toast", props: {
|
4
|
-
classname: "toast-to-hide",
|
5
|
-
closeable: true,
|
6
|
-
id: "toast-top-center-multi",
|
7
2
|
multi_line: true,
|
8
|
-
text: "
|
3
|
+
text: "Scan to Assign Selected Items. Click here to generate report",
|
9
4
|
status: "tip",
|
10
|
-
vertical: "top",
|
11
|
-
horizontal: "center"
|
12
5
|
}) %>
|
13
|
-
|
14
|
-
<script type="text/javascript">
|
15
|
-
const alltoasts = document.queryselectorall(".toast-to-hide")
|
16
|
-
const allbuttons = document.queryselectorall("button[data-toast]")
|
17
|
-
|
18
|
-
const hidealltoasts = () => {
|
19
|
-
alltoasts.foreach((toast) => {
|
20
|
-
toast.style.display = "none"
|
21
|
-
})
|
22
|
-
}
|
23
|
-
|
24
|
-
hidealltoasts()
|
25
|
-
|
26
|
-
allbuttons.foreach((button) => {
|
27
|
-
button.onclick = () => {
|
28
|
-
hidealltoasts()
|
29
|
-
let toast = document.queryselector(button.getattribute("data-toast"))
|
30
|
-
|
31
|
-
if (toast) {
|
32
|
-
toast.style.display = "flex"
|
33
|
-
}
|
34
|
-
}
|
35
|
-
})
|
36
|
-
</script>
|
data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.jsx
CHANGED
@@ -1,52 +1,18 @@
|
|
1
|
+
import React from 'react'
|
1
2
|
|
2
|
-
import React, { useState } from 'react'
|
3
|
-
|
4
|
-
import Button from '../../pb_button/_button'
|
5
3
|
import FixedConfirmationToast from '../_fixed_confirmation_toast'
|
6
4
|
|
7
|
-
const
|
8
|
-
const [state, setState] = useState({
|
9
|
-
open: false,
|
10
|
-
vertical: 'top',
|
11
|
-
horizontal: 'center',
|
12
|
-
})
|
13
|
-
|
14
|
-
const { vertical, horizontal, open } = state
|
15
|
-
|
16
|
-
const handleClick = (newState) => () => {
|
17
|
-
setState({ open: true, ...newState })
|
18
|
-
}
|
19
|
-
|
20
|
-
const handleClose = () => {
|
21
|
-
setState({ ...state, open: false })
|
22
|
-
}
|
23
|
-
|
5
|
+
const FixedConfirmationToastMultiLine = (props) => {
|
24
6
|
return (
|
25
7
|
<div>
|
26
|
-
<Button
|
27
|
-
onClick={handleClick({
|
28
|
-
horizontal: 'center',
|
29
|
-
open: true,
|
30
|
-
vertical: 'top',
|
31
|
-
})}
|
32
|
-
text="Multiline Example"
|
33
|
-
variant="primary"
|
34
|
-
{...props}
|
35
|
-
/>
|
36
|
-
{' '}
|
37
8
|
<FixedConfirmationToast
|
38
|
-
closeable
|
39
|
-
horizontal={horizontal}
|
40
9
|
multiLine
|
41
|
-
onClose={handleClose}
|
42
|
-
open={open}
|
43
10
|
status="tip"
|
44
|
-
text=
|
45
|
-
vertical={vertical}
|
11
|
+
text="Scan to Assign Selected Items. Click here to generate report"
|
46
12
|
{...props}
|
47
13
|
/>
|
48
14
|
</div>
|
49
15
|
)
|
50
16
|
}
|
51
17
|
|
52
|
-
export default
|
18
|
+
export default FixedConfirmationToastMultiLine
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react'
|
2
2
|
import classnames from 'classnames'
|
3
3
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/props'
|
4
4
|
import { GlobalProps, globalProps } from '../utilities/globalProps'
|
@@ -27,7 +27,7 @@ type IconProps = {
|
|
27
27
|
data?: {[key: string]: string},
|
28
28
|
fixedWidth?: boolean,
|
29
29
|
flip?: "horizontal" | "vertical" | "both" | "none",
|
30
|
-
icon: string
|
30
|
+
icon: string,
|
31
31
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
32
32
|
id?: string,
|
33
33
|
inverse?: boolean,
|
@@ -47,11 +47,6 @@ const flipMap = {
|
|
47
47
|
none: ""
|
48
48
|
}
|
49
49
|
|
50
|
-
declare global {
|
51
|
-
// eslint-disable-next-line no-var
|
52
|
-
var PB_ICONS: {[key: string]: React.FunctionComponent<any>}
|
53
|
-
}
|
54
|
-
|
55
50
|
const Icon = (props: IconProps) => {
|
56
51
|
const {
|
57
52
|
aria = {},
|
@@ -62,7 +57,7 @@ const Icon = (props: IconProps) => {
|
|
62
57
|
fixedWidth = true,
|
63
58
|
flip = "none",
|
64
59
|
htmlOptions = {},
|
65
|
-
icon
|
60
|
+
icon,
|
66
61
|
id,
|
67
62
|
inverse = false,
|
68
63
|
listItem = false,
|
@@ -74,8 +69,6 @@ const Icon = (props: IconProps) => {
|
|
74
69
|
spin = false,
|
75
70
|
} = props
|
76
71
|
|
77
|
-
let iconElement: ReactSVGElement | null = typeof(icon) === "object" ? icon : null
|
78
|
-
|
79
72
|
const faClasses = {
|
80
73
|
'fa-border': border,
|
81
74
|
'fa-fw': fixedWidth,
|
@@ -86,23 +79,19 @@ const Icon = (props: IconProps) => {
|
|
86
79
|
[`fa-${size}`]: size,
|
87
80
|
[`fa-pull-${pull}`]: pull,
|
88
81
|
[`fa-rotate-${rotation}`]: rotation,
|
89
|
-
}
|
90
|
-
|
91
|
-
if (!customIcon && !iconElement) {
|
92
|
-
const PowerIcon: React.FunctionComponent<any> | undefined =
|
93
|
-
window.PB_ICONS ? window.PB_ICONS[icon as string] : null
|
94
82
|
|
95
|
-
if (PowerIcon) {
|
96
|
-
iconElement = <PowerIcon /> as ReactSVGElement
|
97
|
-
} else {
|
98
|
-
faClasses[`fa-${icon}`] = icon as string
|
99
|
-
}
|
100
83
|
}
|
101
84
|
|
85
|
+
// Lets check and see if the icon prop is referring to a custom Power icon...
|
86
|
+
// If so, then set fa-icon to "custom"
|
87
|
+
// this ensures the JS will not do any further operations
|
88
|
+
// faClasses[`fa-${icon}`] = customIcon ? 'custom' : icon
|
89
|
+
if (!customIcon) faClasses[`fa-${icon}`] = icon
|
90
|
+
|
102
91
|
const classes = classnames(
|
103
92
|
flipMap[flip],
|
104
|
-
|
105
|
-
|
93
|
+
'pb_icon_kit',
|
94
|
+
customIcon ? '' : fontStyle,
|
106
95
|
faClasses,
|
107
96
|
globalProps(props),
|
108
97
|
className
|
@@ -121,22 +110,20 @@ const Icon = (props: IconProps) => {
|
|
121
110
|
|
122
111
|
// Add a conditional here to show only the SVG if custom
|
123
112
|
const displaySVG = (customIcon: any) => {
|
124
|
-
if (
|
113
|
+
if (customIcon)
|
125
114
|
return (
|
126
115
|
<>
|
127
116
|
{
|
128
|
-
React.cloneElement(
|
117
|
+
React.cloneElement(customIcon, {
|
129
118
|
...dataProps,
|
130
119
|
...htmlProps,
|
131
120
|
className: classes,
|
132
121
|
id,
|
133
|
-
width: 'auto',
|
134
|
-
height: 'auto',
|
135
122
|
})
|
136
123
|
}
|
137
124
|
</>
|
138
125
|
)
|
139
|
-
else if (isValidEmoji(icon
|
126
|
+
else if (isValidEmoji(icon))
|
140
127
|
return (
|
141
128
|
<>
|
142
129
|
<span
|
@@ -149,6 +136,7 @@ const Icon = (props: IconProps) => {
|
|
149
136
|
</span>
|
150
137
|
</>
|
151
138
|
)
|
139
|
+
|
152
140
|
else
|
153
141
|
return (
|
154
142
|
<>
|
@@ -173,4 +161,4 @@ const Icon = (props: IconProps) => {
|
|
173
161
|
)
|
174
162
|
}
|
175
163
|
|
176
|
-
export default Icon
|
164
|
+
export default Icon
|
@@ -2,9 +2,15 @@
|
|
2
2
|
<div class="icon-wrapper">
|
3
3
|
|
4
4
|
<% svg_url = "https://upload.wikimedia.org/wikipedia/commons/3/3b/Wrench_font_awesome.svg" %>
|
5
|
-
<p><%= pb_rails("icon", props: {
|
6
|
-
<p><%= pb_rails("icon", props: { rotation: 90,
|
7
|
-
<p><%= pb_rails("icon", props: { spin: true,
|
8
|
-
<p><%= pb_rails("icon", props: { size: "5x",
|
9
|
-
<p><%= pb_rails("icon", props: { flip: "horizontal", size: "5x",
|
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
|
+
} ) %>
|
10
16
|
</div>
|
@@ -1,59 +1,33 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { Icon } from '../../'
|
3
3
|
|
4
|
+
// import Icons as config from 'power-icons'
|
4
5
|
const config = {
|
5
|
-
|
6
|
-
<svg
|
6
|
+
moon: (
|
7
|
+
<svg
|
8
|
+
ariaHidden="true"
|
9
|
+
focusable="false"
|
10
|
+
role="img"
|
11
|
+
viewBox="0 0 512 512"
|
7
12
|
xmlns="http://www.w3.org/2000/svg"
|
8
13
|
>
|
9
|
-
<
|
10
|
-
|
11
|
-
|
14
|
+
<path
|
15
|
+
d="M448 0H64C28.7 0 0 28.7 0 64v288c0 35.3 28.7 64 64 64h96v84c0 7.1 5.8 12 12 12 2.4 0 4.9-.7 7.1-2.4L304 416h144c35.3 0 64-28.7 64-64V64c0-35.3-28.7-64-64-64zm16 352c0 8.8-7.2 16-16 16H288l-12.8 9.6L208 428v-60H64c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16h384c8.8 0 16 7.2 16 16v288zM336 184h-56v-56c0-8.8-7.2-16-16-16h-16c-8.8 0-16 7.2-16 16v56h-56c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16h56v56c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16v-56h56c8.8 0 16-7.2 16-16v-16c0-8.8-7.2-16-16-16z"
|
16
|
+
fill="currentColor"
|
17
|
+
/>
|
12
18
|
</svg>
|
13
19
|
),
|
14
20
|
}
|
15
21
|
|
16
22
|
const IconCustom = (props) => {
|
17
23
|
return (
|
18
|
-
<
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
<p>
|
26
|
-
<Icon
|
27
|
-
icon={config.icon}
|
28
|
-
rotation={90}
|
29
|
-
size="2x"
|
30
|
-
{...props}
|
31
|
-
/>
|
32
|
-
</p>
|
33
|
-
<p>
|
34
|
-
<Icon
|
35
|
-
icon={config.icon}
|
36
|
-
size="3x"
|
37
|
-
spin
|
38
|
-
{...props}
|
39
|
-
/>
|
40
|
-
</p>
|
41
|
-
<p>
|
42
|
-
<Icon
|
43
|
-
icon={config.icon}
|
44
|
-
size="5x"
|
45
|
-
{...props}
|
46
|
-
/>
|
47
|
-
</p>
|
48
|
-
<p>
|
49
|
-
<Icon
|
50
|
-
flip="horizontal"
|
51
|
-
icon={config.icon}
|
52
|
-
size="5x"
|
53
|
-
{...props}
|
54
|
-
/>
|
55
|
-
</p>
|
56
|
-
</React.Fragment>
|
24
|
+
<div>
|
25
|
+
<Icon
|
26
|
+
customIcon={config.moon}
|
27
|
+
size="7x"
|
28
|
+
{...props}
|
29
|
+
/>
|
30
|
+
</div>
|
57
31
|
)
|
58
32
|
}
|
59
33
|
|
@@ -4,12 +4,16 @@ When using custom icons it is important to introduce a "clean" SVG. In order to
|
|
4
4
|
|
5
5
|
Attributes must be React compatible e.g. <code>xmlns:xlink</code> should be <code>xmlnsXlink</code> and so on. <strong>There should be no hyphenated attributes and no semi-colons!.</strong>
|
6
6
|
|
7
|
-
Fill colors with regards to <code>g</code> or <code>path</code> nodes, e.g. <code>fill="black"</code>, should be replaced with
|
7
|
+
Fill colors with regards to <code>g</code> or <code>path</code> nodes, e.g. <code>fill="black"</code>, should be replaced with <code>currentColor</code> ala <code>fill="currentColor"</code>. Your mileage may vary depending on the complexity of your SVG.
|
8
8
|
|
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
|
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
|
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.
|
12
16
|
|
13
17
|
### Rails
|
14
18
|
|
15
|
-
|
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,9 +1,7 @@
|
|
1
|
-
<% if object.
|
2
|
-
<%= object.render_svg %>
|
3
|
-
<% elsif object.valid_emoji
|
4
|
-
<span class="pb_icon_kit_emoji">
|
5
|
-
<%= object.icon.html_safe %>
|
6
|
-
</span>
|
1
|
+
<% if object.custom_icon %>
|
2
|
+
<%= object.render_svg(object.custom_icon) %>
|
3
|
+
<% elsif object.valid_emoji(object.icon) %>
|
4
|
+
<span class="pb_icon_kit_emoji"><%= object.icon.html_safe %></span>
|
7
5
|
<% else %>
|
8
6
|
<%= content_tag(:i, nil,
|
9
7
|
id: object.id,
|
@@ -38,7 +38,7 @@ module Playbook
|
|
38
38
|
prop :spin, type: Playbook::Props::Boolean,
|
39
39
|
default: false
|
40
40
|
|
41
|
-
def valid_emoji
|
41
|
+
def valid_emoji(icon)
|
42
42
|
emoji_regex = /\p{Emoji}/
|
43
43
|
emoji_regex.match?(icon)
|
44
44
|
end
|
@@ -79,36 +79,19 @@ module Playbook
|
|
79
79
|
)
|
80
80
|
end
|
81
81
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
svg = doc.at_css "svg"
|
92
|
-
svg["class"] = "pb_custom_icon " + object.custom_icon_classname
|
93
|
-
svg["id"] = object.id
|
94
|
-
svg["data"] = object.data
|
95
|
-
svg["aria"] = object.aria
|
96
|
-
svg["height"] = "auto"
|
97
|
-
svg["width"] = "auto"
|
98
|
-
doc.at_css("path")["fill"] = "currentColor"
|
99
|
-
raw doc
|
100
|
-
end
|
101
|
-
|
102
|
-
def is_svg?
|
103
|
-
(icon || custom_icon.to_s).include?(".svg") || asset_path.present?
|
82
|
+
def render_svg(path)
|
83
|
+
if File.extname(path) == ".svg"
|
84
|
+
doc = Nokogiri::XML(URI.open(path)) # rubocop:disable Security/Open
|
85
|
+
svg = doc.at_css "svg"
|
86
|
+
svg["class"] = "pb_custom_icon " + object.custom_icon_classname
|
87
|
+
raw doc
|
88
|
+
else
|
89
|
+
raise("Custom icon must be an svg. Please check your path and file type.")
|
90
|
+
end
|
104
91
|
end
|
105
92
|
|
106
93
|
private
|
107
94
|
|
108
|
-
def svg_size
|
109
|
-
size.nil? ? "1x" : size
|
110
|
-
end
|
111
|
-
|
112
95
|
def border_class
|
113
96
|
border ? "fa-border" : nil
|
114
97
|
end
|