playbook_ui 12.24.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown756 → 12.24.0.pre.alpha.alphatestforselfhostfak720
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_date/_date.tsx +42 -96
- data/app/pb_kits/playbook/pb_date/date.html.erb +2 -22
- data/app/pb_kits/playbook/pb_date/date.rb +0 -2
- data/app/pb_kits/playbook/pb_date/docs/example.yml +4 -4
- data/app/pb_kits/playbook/pb_date/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -26
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +95 -99
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -44
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +2 -34
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +2 -3
- data/app/pb_kits/playbook/pb_docs/kit_api.html.erb +311 -0
- data/app/pb_kits/playbook/pb_docs/kit_api.rb +149 -0
- data/app/pb_kits/playbook/pb_docs/kit_example.rb +2 -0
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_time/_time.tsx +35 -71
- data/app/pb_kits/playbook/pb_time/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_time/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_time/time.html.erb +7 -26
- data/app/pb_kits/playbook/pb_time/time.rb +0 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +1 -2
- data/app/pb_kits/playbook/pb_title/_title.tsx +2 -3
- data/app/pb_kits/playbook/pb_title/title.rb +3 -10
- data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
- data/lib/playbook/markdown/helper.rb +132 -0
- data/lib/playbook/markdown.rb +3 -0
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook.rb +2 -1
- metadata +36 -17
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.html.erb +0 -30
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +0 -47
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.md +0 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.html.erb +0 -8
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.jsx +0 -18
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +0 -164
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +0 -75
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.html.erb +0 -37
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.jsx +0 -58
- data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.md +0 -1
- data/dist/playbook-rails.js +0 -323
@@ -1,47 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { Caption, Date as FormattedDate, Title } from '../../'
|
3
|
-
|
4
|
-
const DateUnstyled = (props) => {
|
5
|
-
return (
|
6
|
-
<>
|
7
|
-
<Caption size="xs"
|
8
|
-
text="Basic unstyled example"
|
9
|
-
/>
|
10
|
-
<FormattedDate
|
11
|
-
unstyled
|
12
|
-
value={new Date()}
|
13
|
-
{...props}
|
14
|
-
/>
|
15
|
-
|
16
|
-
<br />
|
17
|
-
|
18
|
-
<Caption size="xs"
|
19
|
-
text="Example with wrapping typography kit"
|
20
|
-
/>
|
21
|
-
<Title size={1}>
|
22
|
-
<FormattedDate
|
23
|
-
unstyled
|
24
|
-
value="1995-12-25"
|
25
|
-
{...props}
|
26
|
-
/>
|
27
|
-
</Title>
|
28
|
-
|
29
|
-
<br />
|
30
|
-
|
31
|
-
<Caption size="xs"
|
32
|
-
text="Example with icon + subcaption"
|
33
|
-
/>
|
34
|
-
<Caption size="xs">
|
35
|
-
<FormattedDate
|
36
|
-
showDayOfWeek
|
37
|
-
showIcon
|
38
|
-
unstyled
|
39
|
-
value="1995-12-25"
|
40
|
-
{...props}
|
41
|
-
/>
|
42
|
-
</Caption>
|
43
|
-
</>
|
44
|
-
)
|
45
|
-
}
|
46
|
-
|
47
|
-
export default DateUnstyled
|
@@ -1 +0,0 @@
|
|
1
|
-
For alternative typography styles, you can pass a boolean prop called `unstyled` to the `Date` kit and wrap it in any of our typography kits (`Title`, `Body`, `Caption`, etc.). This will allow the `Date` kit to inherit any of our typography styles.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
|
3
|
-
import DatePicker from '../_date_picker'
|
4
|
-
|
5
|
-
const DatePickerQuickPick = (props) => (
|
6
|
-
<div>
|
7
|
-
<DatePicker
|
8
|
-
allowInput
|
9
|
-
mode="range"
|
10
|
-
pickerId="date-picker-quick-pick"
|
11
|
-
placeholder="mm/dd/yyyy → mm/dd/yyyy"
|
12
|
-
selectionType="quickpick"
|
13
|
-
{...props}
|
14
|
-
/>
|
15
|
-
</div>
|
16
|
-
)
|
17
|
-
|
18
|
-
export default DatePickerQuickPick
|
@@ -1,164 +0,0 @@
|
|
1
|
-
import moment from 'moment'
|
2
|
-
|
3
|
-
type FpTypes = {
|
4
|
-
setDate: (arg0: any, arg1: boolean) => void,
|
5
|
-
config: { [key: string]: string },
|
6
|
-
clear: (arg0: boolean, arg1: boolean) => void,
|
7
|
-
close: () => void,
|
8
|
-
calendarContainer?: {
|
9
|
-
classList: { add: (arg0: string) => void };
|
10
|
-
prepend: (arg0: HTMLDivElement) => void;
|
11
|
-
append: (arg0: HTMLDivElement) => void;
|
12
|
-
},
|
13
|
-
loadedPlugins: string[],
|
14
|
-
};
|
15
|
-
|
16
|
-
type pluginDataType = {
|
17
|
-
ranges: { [key: string]: Date[] },
|
18
|
-
rangesNav: HTMLUListElement,
|
19
|
-
rangesButtons: [] | any,
|
20
|
-
}
|
21
|
-
|
22
|
-
let activeLabel = ""
|
23
|
-
|
24
|
-
const quickPickPlugin = () => {
|
25
|
-
return function (fp: FpTypes & any): any {
|
26
|
-
// variable that holds the ranges available
|
27
|
-
const ranges = {
|
28
|
-
'Today': [new Date(), new Date()],
|
29
|
-
'Yesterday': [moment().subtract(1, 'days').toDate(), moment().subtract(1, 'days').toDate()],
|
30
|
-
'This week': [moment().startOf('week').toDate(), moment().endOf('week').toDate()],
|
31
|
-
'This month': [moment().startOf('month').toDate(), new Date()],
|
32
|
-
'This quarter': [moment().startOf('quarter').toDate(), new Date()],
|
33
|
-
'This year': [moment().startOf('year').toDate(), new Date()],
|
34
|
-
'Last week': [
|
35
|
-
moment().subtract(1, 'week').startOf('week').toDate(),
|
36
|
-
moment().subtract(1, 'week').endOf('week').toDate()
|
37
|
-
],
|
38
|
-
'Last month': [
|
39
|
-
moment().subtract(1, 'month').startOf('month').toDate(),
|
40
|
-
moment().subtract(1, 'month').endOf('month').toDate()
|
41
|
-
],
|
42
|
-
'Last quarter': [
|
43
|
-
moment().subtract(1, 'quarter').startOf('quarter').toDate(),
|
44
|
-
moment().subtract(1, 'quarter').endOf('quarter').toDate()
|
45
|
-
],
|
46
|
-
'Last year': [
|
47
|
-
moment().subtract(1, 'year').startOf('year').toDate(),
|
48
|
-
moment().subtract(1, 'year').endOf('year').toDate()
|
49
|
-
]
|
50
|
-
}
|
51
|
-
//creating the ul element for the nav dropdown and giving it classnames
|
52
|
-
const rangesNav = document.createElement('ul');
|
53
|
-
|
54
|
-
// creating the pluginData object that will hold the properties of this plugin
|
55
|
-
const pluginData: pluginDataType = {
|
56
|
-
ranges: ranges,
|
57
|
-
rangesNav: rangesNav,
|
58
|
-
rangesButtons: [],
|
59
|
-
};
|
60
|
-
|
61
|
-
/**
|
62
|
-
* @param {string} label
|
63
|
-
* @returns HTML Element
|
64
|
-
*/
|
65
|
-
|
66
|
-
//function for creating the range buttons in the nav
|
67
|
-
const addRangeButton = (label: string) => {
|
68
|
-
|
69
|
-
// creating new elements to mimick selectable card component
|
70
|
-
const div2 = document.createElement('div');
|
71
|
-
div2.className = "nav-item-link"
|
72
|
-
div2.innerHTML = label;
|
73
|
-
|
74
|
-
pluginData.rangesButtons[label] = div2;
|
75
|
-
|
76
|
-
// create li elements inside the dropdown
|
77
|
-
const item = document.createElement('li');
|
78
|
-
item.className = "nav-item";
|
79
|
-
|
80
|
-
// append those nav items to the li items
|
81
|
-
item.appendChild(pluginData.rangesButtons[label]);
|
82
|
-
|
83
|
-
// append the li item to the ul rangeNav prop
|
84
|
-
pluginData.rangesNav.appendChild(item);
|
85
|
-
|
86
|
-
// return the ranges buton prop
|
87
|
-
return pluginData.rangesButtons[label];
|
88
|
-
};
|
89
|
-
|
90
|
-
const selectActiveRangeButton = (selectedDates: Array<string>) => {
|
91
|
-
const current = pluginData.rangesNav.querySelector('.active');
|
92
|
-
|
93
|
-
if (current) {
|
94
|
-
current.classList.remove('active');
|
95
|
-
}
|
96
|
-
/** conditional statment to extract start and end dates from selectedDates,
|
97
|
-
* then loop through ranges prop in pluginData
|
98
|
-
* and check if chosen dates equal to a date in the ranges prop
|
99
|
-
* if they are equal, add the active class
|
100
|
-
*/
|
101
|
-
if (selectedDates.length > 0 && activeLabel) {
|
102
|
-
// const selected = pluginData.rangesNav.querySelectorAll(".nav-item-link")
|
103
|
-
// selected.forEach(el => {
|
104
|
-
// if (el.innerHTML === activeLabel)
|
105
|
-
// el.classList.add('active')
|
106
|
-
// return
|
107
|
-
// })
|
108
|
-
|
109
|
-
pluginData.rangesButtons[activeLabel].classList.add('active');
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
return {
|
115
|
-
// onReady is a hook from flatpickr that runs when calender is in a ready state
|
116
|
-
onReady(selectedDates: Array<string>) {
|
117
|
-
// loop through the ranges and create an anchor tag for each range and add an event listener to set the date when user clicks on a date range
|
118
|
-
for (const [label, range] of Object.entries(pluginData.ranges)) {
|
119
|
-
addRangeButton(label).addEventListener('click', function () {
|
120
|
-
|
121
|
-
const start = moment(range[0]).toDate();
|
122
|
-
const end = moment(range[1]).toDate();
|
123
|
-
|
124
|
-
if (!start) {
|
125
|
-
fp.clear();
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
activeLabel = label
|
129
|
-
fp.setDate([start, end], true);
|
130
|
-
fp.close();
|
131
|
-
}
|
132
|
-
});
|
133
|
-
}
|
134
|
-
// conditional to check if there is a dropdown to add it to the calendar container and get it the classes it needs
|
135
|
-
if (pluginData.rangesNav.children.length > 0) {
|
136
|
-
|
137
|
-
fp.calendarContainer.prepend(pluginData.rangesNav);
|
138
|
-
pluginData.rangesNav.classList.add('quick-pick-ul')
|
139
|
-
fp.calendarContainer.classList.add('quick-pick-drop-down');
|
140
|
-
|
141
|
-
/**
|
142
|
-
*
|
143
|
-
* @param {Array} selectedDates
|
144
|
-
*/
|
145
|
-
// function to give the active button the active class
|
146
|
-
selectActiveRangeButton(selectedDates);
|
147
|
-
}
|
148
|
-
},
|
149
|
-
onValueUpdate(selectedDates: Array<string>) {
|
150
|
-
debugger
|
151
|
-
selectActiveRangeButton(selectedDates);
|
152
|
-
},
|
153
|
-
|
154
|
-
onClose(selectedDates: Array<string>) {
|
155
|
-
// set the input value to the selected dates when the dropdown is closed
|
156
|
-
if (selectedDates.length < 2 && selectedDates.length > 0) {
|
157
|
-
fp.input.placeholder = fp.formatDate(this.selectedDates[0], fp.config.dateFormat);
|
158
|
-
}
|
159
|
-
}
|
160
|
-
};
|
161
|
-
};
|
162
|
-
}
|
163
|
-
|
164
|
-
export default quickPickPlugin;
|
@@ -1,75 +0,0 @@
|
|
1
|
-
@import "../../tokens/animation-curves";
|
2
|
-
@import "../../tokens/colors";
|
3
|
-
@import "../../tokens/typography";
|
4
|
-
@import "../../tokens/titles";
|
5
|
-
@import "../../tokens/spacing";
|
6
|
-
|
7
|
-
$pb_card_border_width: 1px;
|
8
|
-
$pb_card_border_radius: $border_rad_heavier;
|
9
|
-
|
10
|
-
// used to display dropdown on the left of the calender
|
11
|
-
.quick-pick-drop-down {
|
12
|
-
width: auto;
|
13
|
-
display: grid;
|
14
|
-
}
|
15
|
-
|
16
|
-
.quick-pick-ul {
|
17
|
-
padding: $space_xs 0px;
|
18
|
-
margin: 0;
|
19
|
-
list-style: none;
|
20
|
-
}
|
21
|
-
|
22
|
-
.nav-item {
|
23
|
-
list-style: none;
|
24
|
-
border-radius: 6px;
|
25
|
-
border-bottom: 0;
|
26
|
-
margin: $space_xs $space_sm;
|
27
|
-
}
|
28
|
-
|
29
|
-
.nav-item-link {
|
30
|
-
text-decoration: none;
|
31
|
-
border-width: $pb_card_border_width;
|
32
|
-
border-style: solid;
|
33
|
-
border-color: $border_light;
|
34
|
-
border-radius: $pb_card_border_radius;
|
35
|
-
padding: $space_xs 14px;
|
36
|
-
transition-property: color, background-color;
|
37
|
-
transition-duration: 0.15s;
|
38
|
-
transition-timing-function: $bezier;
|
39
|
-
line-height: 1.4;
|
40
|
-
color: $charcoal;
|
41
|
-
font-size: $font_default;
|
42
|
-
font-weight: $regular;
|
43
|
-
&.active {
|
44
|
-
border-width: 2px;
|
45
|
-
border-color: $primary;
|
46
|
-
}
|
47
|
-
@media (hover:hover) {
|
48
|
-
&:hover {
|
49
|
-
cursor: pointer;
|
50
|
-
box-shadow: $shadow-deep;
|
51
|
-
border-color: $slate;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
// Hide the calendar
|
57
|
-
.quick-pick-drop-down > .flatpickr-months, .quick-pick-drop-down > .flatpickr-innerContainer {
|
58
|
-
display: none;
|
59
|
-
}
|
60
|
-
|
61
|
-
@media only screen and (max-width: 767px) {
|
62
|
-
.quick-pick-ul {
|
63
|
-
padding: $space_xs $space_xs;
|
64
|
-
display: grid;
|
65
|
-
grid-template-columns: 1fr 1fr;
|
66
|
-
}
|
67
|
-
|
68
|
-
.nav-item {
|
69
|
-
margin: $space_xxs $space_xs;
|
70
|
-
}
|
71
|
-
|
72
|
-
.nav-item-link {
|
73
|
-
padding: $space_xs $space_xxs;
|
74
|
-
}
|
75
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
<%= pb_rails("caption", props: { size: "xs", text: "Example with no year" }) %>
|
2
|
-
|
3
|
-
<%= pb_rails("time", props: {
|
4
|
-
show_icon: true,
|
5
|
-
show_timezone: true,
|
6
|
-
time: DateTime.now,
|
7
|
-
timezone: "America/New_York",
|
8
|
-
unstyled: true
|
9
|
-
}) %>
|
10
|
-
|
11
|
-
<br />
|
12
|
-
|
13
|
-
<%= pb_rails("caption", props: { size: "xs", text: "Example with wrapping typography kit" }) %>
|
14
|
-
|
15
|
-
<%= pb_rails("title", props: { size: 1 }) do %>
|
16
|
-
<%= pb_rails("time", props: {
|
17
|
-
show_icon: true,
|
18
|
-
show_timezone: true,
|
19
|
-
time: DateTime.now,
|
20
|
-
timezone: "America/New_York",
|
21
|
-
unstyled: true
|
22
|
-
}) %>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<br />
|
26
|
-
|
27
|
-
<%= pb_rails("caption", props: { size: "xs", text: "Example with icon + subcaption" }) %>
|
28
|
-
|
29
|
-
<%= pb_rails("caption", props: { size: "xs" }) do %>
|
30
|
-
<%= pb_rails("time", props: {
|
31
|
-
show_icon: true,
|
32
|
-
show_timezone: true,
|
33
|
-
time: DateTime.now,
|
34
|
-
timezone: "America/New_York",
|
35
|
-
unstyled: true
|
36
|
-
}) %>
|
37
|
-
<% end %>
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import Time from '../_time'
|
3
|
-
import Caption from '../../pb_caption/_caption'
|
4
|
-
import Title from '../../pb_title/_title'
|
5
|
-
|
6
|
-
const TimeUnstyled = (props) => {
|
7
|
-
return (
|
8
|
-
<>
|
9
|
-
<Caption size="xs"
|
10
|
-
text="Basic unstyled example"
|
11
|
-
/>
|
12
|
-
<Time
|
13
|
-
date={new Date()}
|
14
|
-
showIcon
|
15
|
-
showTimezone
|
16
|
-
timeZone="America/New_York"
|
17
|
-
unstyled
|
18
|
-
{...props}
|
19
|
-
/>
|
20
|
-
|
21
|
-
<br />
|
22
|
-
|
23
|
-
<Caption size="xs"
|
24
|
-
text="Example with wrapping typography kit"
|
25
|
-
/>
|
26
|
-
<Title size={1}>
|
27
|
-
<Time
|
28
|
-
date={new Date()}
|
29
|
-
showIcon
|
30
|
-
showTimezone
|
31
|
-
timeZone="America/New_York"
|
32
|
-
unstyled
|
33
|
-
{...props}
|
34
|
-
/>
|
35
|
-
</Title>
|
36
|
-
|
37
|
-
<br />
|
38
|
-
|
39
|
-
<Caption size="xs"
|
40
|
-
text="Example with icon + subcaption"
|
41
|
-
/>
|
42
|
-
<Caption size="xs">
|
43
|
-
<Time
|
44
|
-
date={new Date()}
|
45
|
-
showIcon
|
46
|
-
showTimezone
|
47
|
-
timeZone="America/New_York"
|
48
|
-
unstyled
|
49
|
-
{...props}
|
50
|
-
/>
|
51
|
-
</Caption>
|
52
|
-
|
53
|
-
<br />
|
54
|
-
</>
|
55
|
-
)
|
56
|
-
}
|
57
|
-
|
58
|
-
export default TimeUnstyled
|
@@ -1 +0,0 @@
|
|
1
|
-
For alternative typography styles, you can pass a boolean prop called `unstyled` to the `Time` kit and wrap it in any of our typography kits (`Title`, `Body`, `Caption`, etc.). This will allow the `Time` kit to inherit any of our typography styles.
|