playbook_ui 12.21.0 → 12.22.0.pre.alpha.play698responsivespacingglobalprop690
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_docs/kit_example.html.erb +23 -19
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx +69 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +9 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +10 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +4 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_more_extensions.jsx +55 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_more_extensions.md +12 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_weekday_stacked/{_weekday_stacked.jsx → _weekday_stacked.tsx} +4 -5
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx +105 -0
- data/app/pb_kits/playbook/utilities/_spacing.scss +27 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +60 -15
- data/lib/playbook/spacing.rb +20 -5
- data/lib/playbook/version.rb +2 -2
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 383851d079d36f1d554a0e282c498a4fc6847f4b5454e7235949dac02a03d72b
|
4
|
+
data.tar.gz: a16155b3649ed77452c42f37b2dba7453759265c5fa8670ae8bafc5d110db796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bf064f59ae1cb0b15bf62cfd577d92f08a106f58ed014a142b656bf101cc5915b3598f83c2ef26fcb225b8f44a601a193a9b7893503e36dd1a097a3a43ee24e
|
7
|
+
data.tar.gz: f715563781a813989eb0a90910db0034ce7f117a133708a449abeb2c7631b65b2e4fdd14361c93a7524ba521bc1ea31d4352f7e62dc79c7433e2a8772479284d
|
@@ -46,25 +46,29 @@
|
|
46
46
|
|
47
47
|
<script>
|
48
48
|
var htmlButton = document.getElementById('<%= "copy-html-#{example_key}" %>')
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
if (htmlButton) {
|
50
|
+
htmlButton.addEventListener('click', function() {
|
51
|
+
var tempElement = document.createElement('div')
|
52
|
+
tempElement.innerHTML = `<%= example_html %>`
|
53
|
+
var decodedString = tempElement.textContent || tempElement.innerText;
|
54
|
+
copyContent(decodedString)
|
55
|
+
})
|
56
|
+
}
|
55
57
|
|
56
58
|
var button = document.getElementById('<%= "copy-button-#{example_key}" %>')
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
if (button) {
|
60
|
+
button.addEventListener('click', function() {
|
61
|
+
var tempElement = document.createElement('div')
|
62
|
+
tempElement.innerHTML = `<%= source %>`
|
63
|
+
var decodedString = tempElement.textContent || tempElement.innerText;
|
64
|
+
copyContent(decodedString)
|
65
|
+
var fadeAwayDiv = document.getElementById("<%= "tooltip-#{example_key}" %>")
|
66
|
+
setTimeout(function() {
|
67
|
+
fadeAwayDiv.classList.remove('show')
|
68
|
+
}, 3000)
|
69
|
+
setTimeout(function() {
|
70
|
+
fadeAwayDiv.classList.add('hide')
|
71
|
+
}, 3001)
|
72
|
+
})
|
73
|
+
}
|
70
74
|
</script>
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
|
3
|
+
import Flex from '../../pb_flex/_flex'
|
4
|
+
import PbReactPopover from '../../pb_popover/_popover'
|
5
|
+
import Icon from '../../pb_icon/_icon'
|
6
|
+
import Nav from '../../pb_nav/_nav'
|
7
|
+
import NavItem from '../../pb_nav/_item'
|
8
|
+
|
9
|
+
const MoreExtensionsDropdown = ({extensions}: any) => {
|
10
|
+
const [showPopover, setShowPopover] = useState(false)
|
11
|
+
|
12
|
+
const handleTogglePopover = () => {
|
13
|
+
setShowPopover(true)
|
14
|
+
}
|
15
|
+
|
16
|
+
const handlePopoverClose = (shouldClosePopover: boolean) => {
|
17
|
+
setShowPopover(!shouldClosePopover)
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
const popoverReference = (
|
22
|
+
<button
|
23
|
+
className="toolbar_button"
|
24
|
+
onClick={handleTogglePopover}
|
25
|
+
>
|
26
|
+
<Flex
|
27
|
+
align="center"
|
28
|
+
className="toolbar_button_icon"
|
29
|
+
justify="center"
|
30
|
+
>
|
31
|
+
<Icon icon="ellipsis" size="lg" />
|
32
|
+
</Flex>
|
33
|
+
</button>
|
34
|
+
|
35
|
+
);
|
36
|
+
|
37
|
+
return (
|
38
|
+
<PbReactPopover
|
39
|
+
closeOnClick='outside'
|
40
|
+
padding='none'
|
41
|
+
placement="bottom"
|
42
|
+
reference={popoverReference}
|
43
|
+
shouldClosePopover={handlePopoverClose}
|
44
|
+
show={showPopover}
|
45
|
+
>
|
46
|
+
<Nav
|
47
|
+
paddingTop={extensions.length > 1 ? "xs" : "none"}
|
48
|
+
paddingBottom={extensions.length > 1 ? "xs" : "none"}
|
49
|
+
variant="subtle"
|
50
|
+
>
|
51
|
+
{extensions && extensions.map(({ icon, text, onclick, isActive}:any, index:number) => (
|
52
|
+
<NavItem
|
53
|
+
cursor="pointer"
|
54
|
+
className={`pb_tiptap_toolbar_dropdown_list_item ${isActive ? "is-active" : ""}`}
|
55
|
+
iconLeft={icon}
|
56
|
+
key={`${text}_${index}`}
|
57
|
+
margin='none'
|
58
|
+
onClick={()=> {onclick(); setShowPopover(false)}}
|
59
|
+
text={text}
|
60
|
+
paddingTop='xxs'
|
61
|
+
paddingBottom='xxs'
|
62
|
+
/>
|
63
|
+
))}
|
64
|
+
</Nav>
|
65
|
+
</PbReactPopover>
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
export default MoreExtensionsDropdown
|
@@ -9,8 +9,9 @@ import ToolbarDropdown from "./ToolbarDropdown";
|
|
9
9
|
import ToolbarNodes from "./ToolbarNodes";
|
10
10
|
import { ToolbarTypes } from "./EditorTypes";
|
11
11
|
import ToolbarHistoryItems from "./ToolbarHistory";
|
12
|
+
import MoreExtensionsDropdown from "./MoreExtensionsDropdown";
|
12
13
|
|
13
|
-
const EditorToolbar = ({ editor }:any) => {
|
14
|
+
const EditorToolbar = ({ editor, extensions }:any) => {
|
14
15
|
const toolbaritems = [
|
15
16
|
{
|
16
17
|
icon: "bold",
|
@@ -51,10 +52,16 @@ const EditorToolbar = ({ editor }:any) => {
|
|
51
52
|
)}
|
52
53
|
<SectionSeparator orientation="vertical" />
|
53
54
|
<ToolbarNodes editor={editor} />
|
55
|
+
{
|
56
|
+
extensions && (
|
57
|
+
<>
|
58
|
+
<MoreExtensionsDropdown extensions={extensions}/>
|
59
|
+
</>
|
60
|
+
)
|
61
|
+
}
|
54
62
|
</FlexItem>
|
55
63
|
<ToolbarHistoryItems editor={editor} />
|
56
64
|
</Flex>
|
57
|
-
{/* <SectionSeparator /> */}
|
58
65
|
</Background>
|
59
66
|
);
|
60
67
|
};
|
@@ -98,7 +98,17 @@ const popoverReference = (
|
|
98
98
|
activeCount === 2 ? (
|
99
99
|
activeItems[1]
|
100
100
|
) : (
|
101
|
+
activeCount === 1 ? (
|
101
102
|
activeItems[0] || null
|
103
|
+
) : (
|
104
|
+
<Flex align="center" key="paragraph" gap="xs">
|
105
|
+
<Icon icon="paragraph" size="lg" />
|
106
|
+
<div>Paragraph</div>
|
107
|
+
<Flex className={showPopover ? "fa-flip-vertical" : ""} display="inline_flex">
|
108
|
+
<Icon fixedWidth icon="angle-down" margin-left="xs" />
|
109
|
+
</Flex>
|
110
|
+
</Flex>
|
111
|
+
)
|
102
112
|
)
|
103
113
|
}
|
104
114
|
</Button>
|
@@ -35,7 +35,8 @@ type RichTextEditorProps = {
|
|
35
35
|
data?: { [key: string]: string },
|
36
36
|
focus?: boolean,
|
37
37
|
id?: string,
|
38
|
-
inline?: boolean,
|
38
|
+
inline?: boolean,
|
39
|
+
extensions?: { [key: string]: string }[],
|
39
40
|
name?: string,
|
40
41
|
onChange: (html: string, text: string) => void,
|
41
42
|
placeholder?: string,
|
@@ -56,6 +57,7 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
56
57
|
data = {},
|
57
58
|
focus = false,
|
58
59
|
inline = false,
|
60
|
+
extensions,
|
59
61
|
name,
|
60
62
|
onChange = noop,
|
61
63
|
placeholder,
|
@@ -162,7 +164,7 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
162
164
|
{
|
163
165
|
advancedEditor ? (
|
164
166
|
<div className='pb_rich_text_editor_advanced_container'>
|
165
|
-
<EditorToolbar editor={advancedEditor}/>
|
167
|
+
<EditorToolbar extensions={extensions} editor={advancedEditor}/>
|
166
168
|
{ children }
|
167
169
|
</div>
|
168
170
|
) : (
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { RichTextEditor } from '../..'
|
3
|
+
import { useEditor, EditorContent } from "@tiptap/react"
|
4
|
+
import StarterKit from "@tiptap/starter-kit"
|
5
|
+
import Link from '@tiptap/extension-link'
|
6
|
+
|
7
|
+
import HorizontalRule from "@tiptap/extension-horizontal-rule"
|
8
|
+
import Highlight from '@tiptap/extension-highlight'
|
9
|
+
|
10
|
+
|
11
|
+
const RichTextEditorMoreExtensions = (props) => {
|
12
|
+
|
13
|
+
const editor = useEditor({
|
14
|
+
extensions: [
|
15
|
+
StarterKit,
|
16
|
+
Link,
|
17
|
+
HorizontalRule,
|
18
|
+
Highlight.configure({ multicolor: true })
|
19
|
+
],
|
20
|
+
content:"Add your text here. You can format your text, add links, quotes, and bullets."
|
21
|
+
})
|
22
|
+
if (!editor) {
|
23
|
+
return null
|
24
|
+
}
|
25
|
+
|
26
|
+
const ExtensionsList = [
|
27
|
+
{
|
28
|
+
icon: "horizontal-rule",
|
29
|
+
isActive: editor.isActive("horizontalRule"),
|
30
|
+
text: "Horizontal Rule",
|
31
|
+
onclick: () => editor.chain().focus().setHorizontalRule().run(),
|
32
|
+
},
|
33
|
+
{
|
34
|
+
icon: "highlighter",
|
35
|
+
isActive: editor.isActive("highlight"),
|
36
|
+
text: "Highlighter",
|
37
|
+
onclick: () => editor.chain().focus().toggleHighlight().run(),
|
38
|
+
}
|
39
|
+
]
|
40
|
+
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div>
|
44
|
+
<RichTextEditor
|
45
|
+
advancedEditor={editor}
|
46
|
+
extensions={ExtensionsList}
|
47
|
+
{...props}
|
48
|
+
>
|
49
|
+
<EditorContent editor={editor}/>
|
50
|
+
</RichTextEditor>
|
51
|
+
</div>
|
52
|
+
)
|
53
|
+
}
|
54
|
+
|
55
|
+
export default RichTextEditorMoreExtensions
|
@@ -0,0 +1,12 @@
|
|
1
|
+
This variant allows you to optionally include any of [Tiptap’s 53 extensions](https://tiptap.dev/extensions) within any advanced editor by using the `extensions` prop.
|
2
|
+
|
3
|
+
__NOTE__: In order to leverage this prop, you __must__ install the extension you need in your project, import it and pass it to the extensions array as shown in this example with the HorizontalRule and the Highlight extensions.
|
4
|
+
|
5
|
+
In order to add the extension to the editor toolbar, create an array of objects (as shown in the ExtensionsList array in the example below). Each object in this array should include:
|
6
|
+
|
7
|
+
`icon`: the icon to display within the toolbar dropdown (any Fontawesome icons can be used)
|
8
|
+
`isActive`: sets the extension to active within the dropdown, when applicable
|
9
|
+
`text`: the label within the toolbar dropdown
|
10
|
+
`onclick`: initializes the extension when it’s clicked within the dropdown (snytax varies with extension, see Tiptap's docs for more information)
|
11
|
+
|
12
|
+
This array can then be passed to the `extensions` prop and all extensions in the array will be rendered in the ellipsis dropdown.
|
@@ -14,6 +14,7 @@ examples:
|
|
14
14
|
react:
|
15
15
|
- rich_text_editor_default: Default
|
16
16
|
- rich_text_editor_advanced_default: Advanced Default
|
17
|
+
- rich_text_editor_more_extensions: Advanced (Extra Extensions)
|
17
18
|
- rich_text_editor_simple: Simple
|
18
19
|
- rich_text_editor_attributes: Attributes
|
19
20
|
- rich_text_editor_focus: Focus
|
@@ -7,4 +7,5 @@ export { default as RichTextEditorTemplates } from './_rich_text_editor_template
|
|
7
7
|
export { default as RichTextEditorToolbarBottom } from './_rich_text_editor_toolbar_bottom.jsx'
|
8
8
|
export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
|
9
9
|
export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
|
10
|
-
export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
|
10
|
+
export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
|
11
|
+
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
@@ -12,18 +12,17 @@ import DateTime from '../pb_kit/dateTime'
|
|
12
12
|
|
13
13
|
type WeekdayStackedProps = {
|
14
14
|
align?: "left" | "center" | "right",
|
15
|
-
aria?:
|
15
|
+
aria?: {[key:string]:string },
|
16
16
|
className?: string,
|
17
17
|
dark?: boolean,
|
18
18
|
data?: object,
|
19
|
-
date:
|
19
|
+
date: Date,
|
20
20
|
id?: string,
|
21
21
|
variant?: "day_only" | "month_day" | "expanded",
|
22
22
|
compact?: boolean,
|
23
|
-
id?: string,
|
24
23
|
}
|
25
24
|
|
26
|
-
const getDayOfWeek = (value, compact) => {
|
25
|
+
const getDayOfWeek = (value: Date | string, compact: boolean) => {
|
27
26
|
const dateTime = new DateTime({ value })
|
28
27
|
if (compact) {
|
29
28
|
return dateTime.toDayAbbr()
|
@@ -32,7 +31,7 @@ const getDayOfWeek = (value, compact) => {
|
|
32
31
|
}
|
33
32
|
}
|
34
33
|
|
35
|
-
const getFormattedDate = (value, variant) => {
|
34
|
+
const getFormattedDate = (value: Date | string, variant: "day_only" | "month_day" | "expanded") => {
|
36
35
|
const dateTime = new DateTime({ value })
|
37
36
|
if (variant === 'day_only') {
|
38
37
|
return dateTime.toDay()
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
|
+
|
4
|
+
import WeekdayStacked from "./_weekday_stacked";
|
5
|
+
|
6
|
+
const TEST_DATE = "01/01/2020 00:00:000 GMT-0500";
|
7
|
+
jest.setSystemTime(new Date(TEST_DATE));
|
8
|
+
const testId = "weekdaystacked-kit";
|
9
|
+
const realDate = Date;
|
10
|
+
|
11
|
+
beforeEach(() => {
|
12
|
+
global.Date.now = jest.fn(() => new Date(TEST_DATE));
|
13
|
+
});
|
14
|
+
|
15
|
+
afterEach(() => {
|
16
|
+
global.Date = realDate;
|
17
|
+
});
|
18
|
+
|
19
|
+
describe("WeekdayStacked Kit", () => {
|
20
|
+
test("renders className", () => {
|
21
|
+
render(
|
22
|
+
<WeekdayStacked
|
23
|
+
data={{ testid: testId }}
|
24
|
+
/>
|
25
|
+
);
|
26
|
+
|
27
|
+
const kit = screen.getByTestId(testId);
|
28
|
+
expect(kit).toHaveClass("pb_weekday_stacked_kit_left");
|
29
|
+
});
|
30
|
+
|
31
|
+
test("renders Caption with weekday", () => {
|
32
|
+
render(
|
33
|
+
<WeekdayStacked
|
34
|
+
data={{ testid: testId }}
|
35
|
+
/>
|
36
|
+
);
|
37
|
+
|
38
|
+
const kit = screen.getByTestId(testId);
|
39
|
+
const text = kit.querySelector(".pb_caption_kit_md");
|
40
|
+
expect(text.textContent).toEqual("Wed")
|
41
|
+
});
|
42
|
+
|
43
|
+
test("renders Title with date", () => {
|
44
|
+
render(
|
45
|
+
<WeekdayStacked
|
46
|
+
data={{ testid: testId }}
|
47
|
+
/>
|
48
|
+
);
|
49
|
+
|
50
|
+
const kit = screen.getByTestId(testId);
|
51
|
+
const text = kit.querySelector(".pb_title_kit_size_4");
|
52
|
+
expect(text.textContent).toEqual("1/1")
|
53
|
+
});
|
54
|
+
|
55
|
+
test("renders compact prop", () => {
|
56
|
+
render(
|
57
|
+
<WeekdayStacked
|
58
|
+
compact
|
59
|
+
data={{ testid: testId }}
|
60
|
+
/>
|
61
|
+
);
|
62
|
+
|
63
|
+
const kit = screen.getByTestId(testId);
|
64
|
+
const text = kit.querySelector(".pb_caption_kit_md");
|
65
|
+
expect(text.textContent).toEqual("W")
|
66
|
+
});
|
67
|
+
|
68
|
+
test("renders align prop", () => {
|
69
|
+
render(
|
70
|
+
<WeekdayStacked
|
71
|
+
align="left"
|
72
|
+
data={{ testid: testId }}
|
73
|
+
/>
|
74
|
+
);
|
75
|
+
|
76
|
+
const kit = screen.getByTestId(testId);
|
77
|
+
expect(kit).toHaveClass("pb_weekday_stacked_kit_left")
|
78
|
+
});
|
79
|
+
|
80
|
+
test("renders day_only variant prop", () => {
|
81
|
+
render(
|
82
|
+
<WeekdayStacked
|
83
|
+
data={{ testid: testId }}
|
84
|
+
variant="day_only"
|
85
|
+
/>
|
86
|
+
);
|
87
|
+
|
88
|
+
const kit = screen.getByTestId(testId);
|
89
|
+
const text = kit.querySelector(".pb_title_kit_size_4");
|
90
|
+
expect(text.textContent).toEqual("1")
|
91
|
+
});
|
92
|
+
|
93
|
+
test("renders expanded variant prop", () => {
|
94
|
+
render(
|
95
|
+
<WeekdayStacked
|
96
|
+
data={{ testid: testId }}
|
97
|
+
variant="expanded"
|
98
|
+
/>
|
99
|
+
);
|
100
|
+
|
101
|
+
const kit = screen.getByTestId(testId);
|
102
|
+
const text = kit.querySelector(".pb_title_kit_size_4");
|
103
|
+
expect(text.textContent).toEqual("Jan 1")
|
104
|
+
});
|
105
|
+
});
|
@@ -7,7 +7,10 @@ $space_classes: (
|
|
7
7
|
md: $space_md,
|
8
8
|
lg: $space_lg,
|
9
9
|
xl: $space_xl,
|
10
|
-
none: 0
|
10
|
+
none: 0,
|
11
|
+
auto: auto,
|
12
|
+
initial: initial,
|
13
|
+
inherit: inherit
|
11
14
|
);
|
12
15
|
|
13
16
|
$positions: (
|
@@ -41,3 +44,26 @@ $positions: (
|
|
41
44
|
}
|
42
45
|
}
|
43
46
|
}
|
47
|
+
|
48
|
+
@each $size, $size_value in $breakpoints_grid {
|
49
|
+
@each $position_name, $position in $positions {
|
50
|
+
@each $space_name, $space in $space_classes {
|
51
|
+
$min_size: map-get($size_value, "min");
|
52
|
+
$max_size: map-get($size_value, "max");
|
53
|
+
.#{$position_name}_#{$size}_#{$space_name} {
|
54
|
+
@if type-of($position)=="list" {
|
55
|
+
@each $coordinate in $position {
|
56
|
+
@include break_on($min_size, $max_size) {
|
57
|
+
#{$coordinate}: #{$space} !important;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
@else {
|
62
|
+
@include break_on($min_size, $max_size) {
|
63
|
+
#{$position}: #{$space} !important;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
@@ -153,22 +153,67 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
153
153
|
padding,
|
154
154
|
}: Margin & Padding) => {
|
155
155
|
let css = ''
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
156
|
+
const spacingProps = {
|
157
|
+
marginRight,
|
158
|
+
marginLeft,
|
159
|
+
marginTop,
|
160
|
+
marginBottom,
|
161
|
+
marginX,
|
162
|
+
marginY,
|
163
|
+
margin,
|
164
|
+
paddingRight,
|
165
|
+
paddingLeft,
|
166
|
+
paddingTop,
|
167
|
+
paddingBottom,
|
168
|
+
paddingX,
|
169
|
+
paddingY,
|
170
|
+
padding,
|
171
|
+
};
|
172
|
+
|
173
|
+
function handleObjectValue(properties: Margin | Padding, prefix: string) {
|
174
|
+
let classResult = '';
|
175
|
+
|
176
|
+
Object.entries(properties).forEach(([key, value]) => {
|
177
|
+
classResult += `${prefix}_${key}_${value} `;
|
178
|
+
});
|
179
|
+
|
180
|
+
return classResult;
|
181
|
+
}
|
182
|
+
|
183
|
+
function getPrefix(key: string) {
|
184
|
+
const prefixes: Record<string, string> = {
|
185
|
+
marginRight: 'mr',
|
186
|
+
marginLeft: 'ml',
|
187
|
+
marginTop: 'mt',
|
188
|
+
marginBottom: 'mb',
|
189
|
+
marginX: 'mx',
|
190
|
+
marginY: 'my',
|
191
|
+
margin: 'm',
|
192
|
+
paddingRight: 'pr',
|
193
|
+
paddingLeft: 'pl',
|
194
|
+
paddingTop: 'pt',
|
195
|
+
paddingBottom: 'pb',
|
196
|
+
paddingX: 'px',
|
197
|
+
paddingY: 'py',
|
198
|
+
padding: 'p',
|
199
|
+
};
|
200
|
+
|
201
|
+
return prefixes[key];
|
202
|
+
}
|
203
|
+
|
204
|
+
Object.entries(spacingProps).forEach(([key, value]) => {
|
205
|
+
if (value) {
|
206
|
+
if (typeof value === 'object') {
|
207
|
+
css += handleObjectValue(value, getPrefix(key));
|
208
|
+
} else {
|
209
|
+
const prefix = getPrefix(key);
|
210
|
+
css += `${prefix}_${value} `;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
});
|
214
|
+
return css.trim();
|
171
215
|
},
|
216
|
+
|
172
217
|
darkProps: ({ dark }: Dark) => dark ? 'dark' : '',
|
173
218
|
numberSpacingProps: ({ numberSpacing }: NumberSpacing) => {
|
174
219
|
let css = ''
|
data/lib/playbook/spacing.rb
CHANGED
@@ -50,17 +50,32 @@ module Playbook
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def spacing_values
|
53
|
-
%w[none xxs xs sm md lg xl]
|
53
|
+
%w[none xxs xs sm md lg xl auto initial inherit]
|
54
|
+
end
|
55
|
+
|
56
|
+
def screen_size_values
|
57
|
+
%w[xs sm md lg xl]
|
54
58
|
end
|
55
59
|
|
56
60
|
def spacing_props
|
57
61
|
selected_props = spacing_options.keys.select { |sk| try(sk) }
|
58
62
|
return nil unless selected_props.present?
|
59
63
|
|
60
|
-
selected_props.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
responsive = selected_props.present? && try(selected_props.first).is_a?(::Hash)
|
65
|
+
css = ""
|
66
|
+
selected_props.each do |prop|
|
67
|
+
spacing_value = send(prop)
|
68
|
+
prefix = spacing_options[prop]
|
69
|
+
if responsive
|
70
|
+
spacing_value.each do |key, value|
|
71
|
+
css += "#{prefix}_#{key}_#{value} " if screen_size_values.include?(key.to_s) && spacing_values.include?(value.to_s)
|
72
|
+
end
|
73
|
+
elsif spacing_values.include?(spacing_value)
|
74
|
+
css += "#{prefix}_#{spacing_value} "
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
css.strip unless css.blank?
|
64
79
|
end
|
65
80
|
|
66
81
|
def max_width_props
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.
|
4
|
+
version: 12.22.0.pre.alpha.play698responsivespacingglobalprop690
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
8
8
|
- Power Devs
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-05-
|
12
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -1721,6 +1721,7 @@ files:
|
|
1721
1721
|
- app/pb_kits/playbook/pb_radio/radio.test.js
|
1722
1722
|
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorButton.tsx
|
1723
1723
|
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorTypes.ts
|
1724
|
+
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx
|
1724
1725
|
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx
|
1725
1726
|
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx
|
1726
1727
|
- app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarHistory.tsx
|
@@ -1740,6 +1741,8 @@ files:
|
|
1740
1741
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.jsx
|
1741
1742
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.html.erb
|
1742
1743
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.jsx
|
1744
|
+
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_more_extensions.jsx
|
1745
|
+
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_more_extensions.md
|
1743
1746
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb
|
1744
1747
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.jsx
|
1745
1748
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb
|
@@ -2347,8 +2350,8 @@ files:
|
|
2347
2350
|
- app/pb_kits/playbook/pb_walkthrough/docs/example.yml
|
2348
2351
|
- app/pb_kits/playbook/pb_walkthrough/docs/index.js
|
2349
2352
|
- app/pb_kits/playbook/pb_walkthrough/walkthrough.test.jsx
|
2350
|
-
- app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
|
2351
2353
|
- app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.scss
|
2354
|
+
- app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx
|
2352
2355
|
- app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.html.erb
|
2353
2356
|
- app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.jsx
|
2354
2357
|
- app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_default.html.erb
|
@@ -2359,6 +2362,7 @@ files:
|
|
2359
2362
|
- app/pb_kits/playbook/pb_weekday_stacked/docs/index.js
|
2360
2363
|
- app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb
|
2361
2364
|
- app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
|
2365
|
+
- app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx
|
2362
2366
|
- app/pb_kits/playbook/playbook-doc.js
|
2363
2367
|
- app/pb_kits/playbook/playbook-rails-react-bindings.js
|
2364
2368
|
- app/pb_kits/playbook/playbook-rails.js
|
@@ -2487,7 +2491,7 @@ homepage: http://playbook.powerapp.cloud
|
|
2487
2491
|
licenses:
|
2488
2492
|
- ISC
|
2489
2493
|
metadata: {}
|
2490
|
-
post_install_message:
|
2494
|
+
post_install_message:
|
2491
2495
|
rdoc_options: []
|
2492
2496
|
require_paths:
|
2493
2497
|
- lib
|
@@ -2498,12 +2502,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
2498
2502
|
version: '0'
|
2499
2503
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
2500
2504
|
requirements:
|
2501
|
-
- - "
|
2505
|
+
- - ">"
|
2502
2506
|
- !ruby/object:Gem::Version
|
2503
|
-
version:
|
2507
|
+
version: 1.3.1
|
2504
2508
|
requirements: []
|
2505
2509
|
rubygems_version: 3.3.7
|
2506
|
-
signing_key:
|
2510
|
+
signing_key:
|
2507
2511
|
specification_version: 4
|
2508
2512
|
summary: Playbook Design System
|
2509
2513
|
test_files: []
|