playbook_ui 13.0.0 → 13.2.0.pre.alpha.PLAY986dateTimeRounding1150
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_collapsible/child_kits/CollapsibleMain.tsx +1 -1
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +7 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_description.md +0 -7
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom.html.erb +7 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom.md +1 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_default.html.erb +3 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/test.html +25 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +17 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.rb +34 -0
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +105 -67
- data/app/pb_kits/playbook/pb_nav/_bold_mixin.scss +16 -14
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +86 -115
- data/app/pb_kits/playbook/pb_nav/_collapsible_trail_mixin.scss +16 -0
- data/app/pb_kits/playbook/pb_nav/_horizontal_nav.scss +58 -58
- data/app/pb_kits/playbook/pb_nav/_item.tsx +242 -138
- data/app/pb_kits/playbook/pb_nav/_nav.scss +38 -0
- data/app/pb_kits/playbook/pb_nav/_nav.tsx +17 -1
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +9 -11
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +50 -59
- data/app/pb_kits/playbook/pb_nav/docs/_block_no_title_nav.jsx +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_borderless_nav.jsx +4 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.html.erb +4 -4
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +4 -10
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom.jsx +6 -1
- data/app/pb_kits/playbook/pb_nav/docs/{_collapsible_nav_emphasize.jsx → _collapsible_nav_item_spacing.jsx} +18 -17
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_item_spacing.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_with_all_options.html.erb +23 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_with_all_options.jsx +55 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_with_all_options.md +4 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_font_control.html.erb +6 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_font_control.jsx +46 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_font_control.md +4 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.html.erb +6 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.jsx +47 -0
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_no_highlight_nav.jsx +4 -1
- data/app/pb_kits/playbook/pb_nav/docs/_subtle_nav.jsx +4 -1
- data/app/pb_kits/playbook/pb_nav/docs/_subtle_with_icons_nav.jsx +4 -1
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +10 -5
- data/app/pb_kits/playbook/pb_nav/docs/index.js +4 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +19 -12
- data/app/pb_kits/playbook/pb_nav/item.rb +55 -14
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +3 -1
- data/app/pb_kits/playbook/pb_nav/navTypes.ts +25 -0
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.scss +0 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_multiple.md +1 -1
- data/app/pb_kits/playbook/pb_time/_time.tsx +1 -1
- data/dist/playbook-rails.js +3 -3
- data/lib/playbook/version.rb +2 -2
- metadata +26 -11
- data/app/pb_kits/playbook/pb_nav/_mixins.scss +0 -5
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.html.erb +0 -23
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_emphasize.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29507bd994a736c71238be60bea9b2b269b5f1a40ebabac51280e93f20d493b2
|
4
|
+
data.tar.gz: fb81b0db3f2615422f9d827859951373dd50d34b5a94aa06f9bc42324d7942a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed2c60ef1307bb8c3ba61cb9d8983a219c6e82568e86ec9e8608ae7efe057094f6307da32f77c4ad5a08d11f9fd5ee5f2b568c1502d3426d2a82416795c846ff
|
7
|
+
data.tar.gz: e96648e381e82365ec5b439cdc3166f08c6c33e7cfc71d42a79415f46a5e3c1f696ccda273952633e858c7802a6746ff45a009ac164e5211ab8af18f7646805d
|
@@ -104,7 +104,7 @@ const CollapsibleMain = ({
|
|
104
104
|
}
|
105
105
|
|
106
106
|
return (
|
107
|
-
<div className={classnames(mainCSS,
|
107
|
+
<div className={classnames(mainCSS, mainSpacing, className)}>
|
108
108
|
<div onClick={handleCollapsibleClick}>
|
109
109
|
<Flex
|
110
110
|
spacing="between"
|
@@ -1,7 +0,0 @@
|
|
1
|
-
This kit provides a drag and drop interface for file uploads. Currently, the kit leverages [react-dropzone](https://github.com/react-dropzone/react-dropzone).
|
2
|
-
|
3
|
-
### Props
|
4
|
-
|
5
|
-
`accept: [String]` Use this prop to set the list of valid file types
|
6
|
-
`customMessage: [String]` Use this prop to set a custom message, replacing the default text
|
7
|
-
`onFilesAccepted: Function` The callback function, providing the list of dropped files
|
@@ -0,0 +1 @@
|
|
1
|
+
The `id` for the File Upload and the existing input you are choosing to wrap with our Kit with must match each other. This will ensure that the click on the button a.k.a, the underlying label's `for`, triggers the File Upload.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
<div class="pb_file_upload_kit" id="import_file">
|
3
|
+
<div class="pb_form_group_kit cursor_pointer">
|
4
|
+
<label for="import_file" class="pb_button_kit_secondary_inline_enabled">Upload File</label>
|
5
|
+
<div class="pb_text_input_kit">
|
6
|
+
<div class=" text_input_wrapper">
|
7
|
+
<input placeholder="custom-placeholder" id="import_file" type="file">
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<h1>not custom</h1>
|
14
|
+
|
15
|
+
<div class="pb_file_upload_kit" id="test">
|
16
|
+
<div class="pb_form_group_kit cursor_pointer">
|
17
|
+
<label for="upload-test" class="pb_button_kit_secondary_inline_enabled">Upload File</label>
|
18
|
+
<div class="pb_text_input_kit">
|
19
|
+
<div class=" text_input_wrapper">
|
20
|
+
<input class="text_input cursor_pointer" id="upload-test" type="file" classname="cursor_pointer">
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= content_tag("div",
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id) do %>
|
6
|
+
<%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
|
7
|
+
<label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
|
8
|
+
<%= pb_rails("text_input", props: {
|
9
|
+
type: "file",
|
10
|
+
input_options: {
|
11
|
+
id: "upload-#{object.id}",
|
12
|
+
classname: "cursor_pointer",
|
13
|
+
}.merge(object.input_options)
|
14
|
+
}) %>
|
15
|
+
<% end %>
|
16
|
+
</label>
|
17
|
+
<% end %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbFileUpload
|
5
|
+
class FileUpload < Playbook::KitBase
|
6
|
+
prop :accept, type: Playbook::Props::String,
|
7
|
+
default: ""
|
8
|
+
|
9
|
+
prop :files, type: Playbook::Props::Array,
|
10
|
+
default: []
|
11
|
+
|
12
|
+
prop :label, type: Playbook::Props::String,
|
13
|
+
default: "Upload File"
|
14
|
+
|
15
|
+
prop :placeholder, type: Playbook::Props::String,
|
16
|
+
default: "No file"
|
17
|
+
|
18
|
+
prop :full_width, type: Playbook::Props::Boolean,
|
19
|
+
default: false
|
20
|
+
|
21
|
+
prop :input_options, type: Playbook::Props::Hash,
|
22
|
+
default: {}
|
23
|
+
|
24
|
+
def classname
|
25
|
+
file_upload_class = generate_classname("pb_file_upload_kit")
|
26
|
+
file_upload_class + full_width_class
|
27
|
+
end
|
28
|
+
|
29
|
+
def full_width_class
|
30
|
+
full_width ? " full_width" : ""
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -17,92 +17,97 @@ const formatDate = (newDate: Date | string) => {
|
|
17
17
|
|
18
18
|
export const toMinute = (newDate: Date | string, timeZone?: string): string => {
|
19
19
|
const date = formatDate(newDate)
|
20
|
+
|
20
21
|
if (timeZone) {
|
21
|
-
return date.toLocaleTimeString(
|
22
|
+
return date.toLocaleTimeString("en-US", { timeZone, hour: "2-digit", minute: "2-digit" }).slice(3, 5);
|
22
23
|
} else {
|
23
|
-
return date.toLocaleTimeString(
|
24
|
+
return date.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }).slice(3, 5);
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
27
28
|
export const toHour = (newDate: Date | string, timeZone?: string): string => {
|
28
29
|
const date = formatDate(newDate)
|
30
|
+
|
29
31
|
if (timeZone) {
|
30
|
-
return date.toLocaleTimeString(
|
32
|
+
return date.toLocaleTimeString("en-US", { timeZone, hour: "numeric" }).split(' ')[0];
|
31
33
|
} else {
|
32
|
-
return date.toLocaleTimeString(
|
34
|
+
return date.toLocaleTimeString("en-US", { hour: "numeric" }).split(' ')[0];
|
33
35
|
}
|
34
36
|
}
|
35
37
|
|
36
38
|
export const toDay = (newDate: Date | string, timeZone?: string): number => {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
if (timeZone) {
|
40
|
+
const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
|
41
|
+
return date.getDate()
|
42
|
+
} else {
|
43
|
+
const date = formatDate(newDate)
|
44
|
+
return date.getDate()
|
45
|
+
}
|
44
46
|
}
|
45
47
|
|
46
48
|
export const toDayAbbr = (newDate: Date | string): string => {
|
47
49
|
const date = formatDate(newDate)
|
48
|
-
return ABBR_DAYS[date.
|
50
|
+
return ABBR_DAYS[date.getDay()]
|
49
51
|
}
|
50
52
|
|
51
53
|
export const toWeekday = (newDate: Date | string): string => {
|
52
|
-
|
53
|
-
|
54
|
+
const date = formatDate(newDate)
|
55
|
+
return days[date.getDay()]
|
54
56
|
}
|
55
57
|
|
56
58
|
export const toMonth = (newDate: Date | string, timeZone?: string): string => {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
if (timeZone) {
|
60
|
+
const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
|
61
|
+
return months[date.getMonth()]
|
62
|
+
} else {
|
63
|
+
const date = formatDate(newDate)
|
64
|
+
return months[date.getMonth()]
|
65
|
+
}
|
64
66
|
}
|
65
67
|
|
66
68
|
export const toMonthNum = (newDate: Date | string): number => {
|
67
69
|
const date = formatDate(newDate)
|
68
|
-
return date.
|
70
|
+
return date.getMonth() + 1
|
69
71
|
}
|
70
72
|
|
71
73
|
export const toYear = (newDate: Date | string, timeZone?: string): number => {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
if (timeZone) {
|
75
|
+
const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
|
76
|
+
return date.getFullYear()
|
77
|
+
} else {
|
78
|
+
const date = formatDate(newDate)
|
79
|
+
return date.getFullYear()
|
80
|
+
}
|
79
81
|
}
|
80
82
|
|
81
83
|
export const toTime = (newDate: Date | string, timeZone?: string): string => {
|
82
84
|
const date = formatDate(newDate)
|
85
|
+
|
83
86
|
if (timeZone) {
|
84
|
-
return date.toLocaleTimeString(
|
87
|
+
return date.toLocaleTimeString("en-US", { timeZone, timeStyle: "short" }).split(' ')[0];
|
85
88
|
} else {
|
86
|
-
return date.toLocaleTimeString(
|
89
|
+
return date.toLocaleTimeString("en-US", { timeStyle: "short" }).split(' ')[0];
|
87
90
|
}
|
88
91
|
}
|
89
92
|
|
90
93
|
export const toMeridiem = (newDate: Date | string, timeZone?: string): string => {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
94
|
+
const date = formatDate(newDate)
|
95
|
+
|
96
|
+
if (timeZone) {
|
97
|
+
return date.toLocaleString("en-US", { timeZone, hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
|
98
|
+
} else {
|
99
|
+
return date.toLocaleString("en-US", { hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
|
100
|
+
}
|
97
101
|
}
|
98
102
|
|
99
103
|
export const toTimeZone = (newDate: Date | string, timeZone?: string): string => {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
104
|
+
const date = formatDate(newDate)
|
105
|
+
|
106
|
+
if (timeZone) {
|
107
|
+
return date.toLocaleString("en-US", { timeZone, timeZoneName: "short" }).split(' ')[3];
|
108
|
+
} else {
|
109
|
+
return date.toLocaleString("en-US", { timeZoneName: "short" }).split(' ')[3];
|
110
|
+
}
|
106
111
|
}
|
107
112
|
|
108
113
|
export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): string => {
|
@@ -111,33 +116,66 @@ export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): st
|
|
111
116
|
}
|
112
117
|
|
113
118
|
export const toIso = (newDate: Date | string): string => {
|
114
|
-
|
115
|
-
|
119
|
+
const date = formatDate(newDate)
|
120
|
+
return date.toISOString()
|
116
121
|
}
|
117
122
|
|
118
123
|
export const fromNow = (newDate: Date | string): string => {
|
119
|
-
const
|
120
|
-
const
|
124
|
+
const today = new Date()
|
125
|
+
const formattedDate = formatDate(newDate)
|
126
|
+
|
127
|
+
const startDate = formattedDate.getTime()
|
128
|
+
const endDate = today.getTime()
|
121
129
|
const elapsedTime = endDate - startDate
|
122
|
-
|
123
|
-
|
124
|
-
const
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
130
|
+
|
131
|
+
// For years/months, don't use elapsedTime due to rounding
|
132
|
+
const differenceInYears = today.getFullYear() - formattedDate.getFullYear()
|
133
|
+
const differenceInMonths = () => {
|
134
|
+
let months = differenceInYears * 12
|
135
|
+
months -= formattedDate.getMonth()
|
136
|
+
months += today.getMonth()
|
137
|
+
return months
|
138
|
+
}
|
139
|
+
|
140
|
+
const FOURTY_FIVE_SECONDS = 45000
|
141
|
+
const NINETY_SECONDS = 90000
|
142
|
+
|
143
|
+
const FOURTY_FIVE_MINUTES = 2670000
|
144
|
+
const NINETY_MINUTES = 5400000
|
145
|
+
|
146
|
+
const TWENTY_TWO_HOURS = 77400000
|
147
|
+
const THIRTY_SIX_HOURS = 129600000
|
148
|
+
|
149
|
+
const TWENTY_SIX_DAYS = 2203200000
|
150
|
+
const FOURTY_FIVE_DAYS = 3888000000
|
151
|
+
|
152
|
+
const TEN_AND_A_HALF_MONTHS = 27560000000
|
153
|
+
|
154
|
+
const MILLISECONDS_IN_A_MINUTE = 60000
|
155
|
+
const MILLISECONDS_IN_A_HOUR = 3600000
|
156
|
+
const MILLISECONDS_IN_A_DAY = 86400000
|
157
|
+
|
158
|
+
let elapsedTimeString = differenceInYears === 1 ? `${differenceInYears} year ago` : `${differenceInYears} years ago` // 320 days to 1+ year: "x year(s) ago"
|
159
|
+
|
160
|
+
// Inspiration: https://momentjs.com/docs/#/displaying/fromnow/
|
161
|
+
const intervals = [
|
162
|
+
{ min: 0, max: FOURTY_FIVE_SECONDS, value: "a few seconds ago" }, // 0-44.99 seconds
|
163
|
+
{ min: FOURTY_FIVE_SECONDS, max: NINETY_SECONDS, value: "a minute ago" }, // 45-89.99 seconds
|
164
|
+
{ min: NINETY_SECONDS, max: FOURTY_FIVE_MINUTES, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_MINUTE)} minutes ago` }, // 90s-44.49 minutes: "2 minutes ago ... 44 minutes ago"
|
165
|
+
{ min: FOURTY_FIVE_MINUTES, max: NINETY_MINUTES, value: "an hour ago" }, // 44.5-89.99 minutes
|
166
|
+
{ min: NINETY_MINUTES, max: TWENTY_TWO_HOURS, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_HOUR)} hours ago` }, // 90m-21.49 hours: "2 hours ago ... 21 hours ago"
|
167
|
+
{ min: TWENTY_TWO_HOURS, max: THIRTY_SIX_HOURS, value: "a day ago" }, // 21.5-35.99 hours
|
168
|
+
{ min: THIRTY_SIX_HOURS, max: TWENTY_SIX_DAYS, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_DAY)} days ago` }, // 36h-25.49 days: "2 days ago ... 25 days ago"
|
169
|
+
{ min: TWENTY_SIX_DAYS, max: FOURTY_FIVE_DAYS, value: "a month ago" }, // 25.5-44.99 days
|
170
|
+
{ min: FOURTY_FIVE_DAYS, max: TEN_AND_A_HALF_MONTHS, value: `${differenceInMonths()} months ago` }, // 45 days to 319 days: "2 months ago ... 10 months ago"
|
171
|
+
]
|
172
|
+
|
173
|
+
for (const interval of intervals) {
|
174
|
+
const { min, max, value } = interval
|
175
|
+
|
176
|
+
if (elapsedTime >= min && elapsedTime < max) {
|
177
|
+
elapsedTimeString = value
|
178
|
+
break
|
141
179
|
}
|
142
180
|
}
|
143
181
|
|
@@ -149,7 +187,7 @@ export const toCustomFormat = (newDate: Date | string, format = 'month_day'): st
|
|
149
187
|
if (format == "month_day") {
|
150
188
|
return `${toMonthNum(date)}/${toDay(date)}`
|
151
189
|
} else {
|
152
|
-
return `${date.toLocaleString(
|
190
|
+
return `${date.toLocaleString("en-US", { month: "short" })} ${toDay(date)}`
|
153
191
|
}
|
154
192
|
}
|
155
193
|
|
@@ -1,22 +1,24 @@
|
|
1
1
|
@mixin bold {
|
2
2
|
@include subtle;
|
3
3
|
|
4
|
-
[class*=pb_nav_list_kit_item]
|
5
|
-
&[class*=
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
[class*=pb_nav_list_kit_item][class*=pb_nav_list_item]{
|
5
|
+
&[class*=_link] {
|
6
|
+
&[class*=_active] {
|
7
|
+
background-color: $primary;
|
8
|
+
color: $white;
|
9
|
+
box-shadow: $shadow_deep;
|
10
|
+
@media (hover:hover) {
|
11
|
+
&:hover {
|
12
|
+
background-color: darken($primary, 4%);
|
13
|
+
[class*=_text],[class*=_icon] {
|
14
|
+
color: $white;
|
15
|
+
}
|
14
16
|
}
|
15
17
|
}
|
18
|
+
[class*=_text],[class*=_icon] {
|
19
|
+
font-weight: $bolder;
|
20
|
+
}
|
16
21
|
}
|
17
|
-
|
18
|
-
font-weight: $bolder;
|
19
|
-
}
|
20
|
-
}
|
22
|
+
}
|
21
23
|
}
|
22
24
|
}
|