playbook_ui 13.2.0.pre.alpha.PLAY986dateTimeRounding1150 → 13.3.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_body/_body.scss +5 -0
- data/app/pb_kits/playbook/pb_body/_body.tsx +4 -1
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +19 -0
- data/app/pb_kits/playbook/pb_body/body.rb +8 -1
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +23 -54
- data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +54 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_header.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_table_header.scss +31 -0
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +64 -0
- data/app/pb_kits/playbook/pb_table/table_header.rb +53 -0
- data/app/pb_kits/playbook/pb_title/_title.scss +5 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +4 -1
- data/app/pb_kits/playbook/pb_title/_title_mixin.scss +19 -0
- data/app/pb_kits/playbook/pb_title/title.rb +9 -2
- data/dist/playbook-rails.js +5 -5
- data/lib/playbook/version.rb +1 -1
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f58a60dbe08112a0b7b1cea36c7838386d7b7577809d4030a9b139b179df83d
|
4
|
+
data.tar.gz: 4bfb13a37f222531335ffa4b950026c1f0c7daeb2b33aecf3cf06fd02fa3684a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8554a0a8db1af2d8ca5e08f92f03354c68df334eeea9c8d33f103e825295fabc25e28c8a2466dadb381e4a11810d0059771ddeff2dd60505ba3f181f1af5e211
|
7
|
+
data.tar.gz: 06dd58fecce7e733a01e77d54cdad22b051f7ec5036e881726ecc283407d28451c98fce6b05b4649fa13bd7868d601d9d1767dc0cb52393f55352314177b7210
|
@@ -37,10 +37,15 @@
|
|
37
37
|
font-size: $font_smaller;
|
38
38
|
letter-spacing: $lspace_loose;
|
39
39
|
}
|
40
|
+
|
41
|
+
&[class*=_truncate] {
|
42
|
+
@include body_truncate;
|
43
|
+
}
|
40
44
|
|
41
45
|
@each $status_name, $status_value in $pb_body_status {
|
42
46
|
&[class*=#{$status_name}] {
|
43
47
|
@include pb_body($status_value);
|
48
|
+
@include body_truncate;
|
44
49
|
}
|
45
50
|
}
|
46
51
|
|
@@ -19,6 +19,7 @@ type BodyProps = {
|
|
19
19
|
status?: 'neutral' | 'negative' | 'positive',
|
20
20
|
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
|
21
21
|
text?: string,
|
22
|
+
truncate?: null | '1' | '2' | '3' | '4' | '5',
|
22
23
|
variant?: null | 'link',
|
23
24
|
} & GlobalProps
|
24
25
|
|
@@ -36,13 +37,15 @@ const Body = (props: BodyProps): React.ReactElement => {
|
|
36
37
|
status = null,
|
37
38
|
tag = 'div',
|
38
39
|
text = '',
|
40
|
+
truncate = null,
|
39
41
|
variant = null,
|
40
42
|
} = props
|
41
43
|
|
42
44
|
const ariaProps: {[key: string]: any} = buildAriaProps(aria)
|
43
45
|
const dataProps: {[key: string]: any} = buildDataProps(data)
|
46
|
+
const isTruncated = truncate ? `truncate_${truncate}` : ''
|
44
47
|
const classes = classnames(
|
45
|
-
buildCss('pb_body_kit', color, variant, status),
|
48
|
+
buildCss('pb_body_kit', color, variant, status, isTruncated),
|
46
49
|
globalProps(props),
|
47
50
|
className
|
48
51
|
)
|
@@ -36,6 +36,25 @@ $pb_body_status: (
|
|
36
36
|
font-family: $font-family-base;
|
37
37
|
}
|
38
38
|
|
39
|
+
$pb_body_truncate: (
|
40
|
+
truncate_1: 1,
|
41
|
+
truncate_2: 2,
|
42
|
+
truncate_3: 3,
|
43
|
+
truncate_4: 4,
|
44
|
+
truncate_5: 5
|
45
|
+
);
|
46
|
+
|
47
|
+
@mixin body_truncate {
|
48
|
+
@each $name, $number in $pb_body_truncate {
|
49
|
+
&[class*=_#{$name}] {
|
50
|
+
overflow: hidden;
|
51
|
+
display: -webkit-box;
|
52
|
+
-webkit-line-clamp: $number;
|
53
|
+
-webkit-box-orient: vertical;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
39
58
|
|
40
59
|
// Colors ======================
|
41
60
|
@mixin pb_body_light {
|
@@ -18,9 +18,12 @@ module Playbook
|
|
18
18
|
default: false
|
19
19
|
prop :highlighted_text, type: Playbook::Props::Array,
|
20
20
|
default: []
|
21
|
+
prop :truncate, type: Playbook::Props::Enum,
|
22
|
+
values: [nil, "1", "2", "3", "4", "5"],
|
23
|
+
default: nil
|
21
24
|
|
22
25
|
def classname
|
23
|
-
generate_classname("pb_body_kit", color_class, status_class)
|
26
|
+
generate_classname("pb_body_kit", color_class, status_class, is_truncated)
|
24
27
|
end
|
25
28
|
|
26
29
|
def content
|
@@ -28,6 +31,10 @@ module Playbook
|
|
28
31
|
highlighting ? apply_highlight(body_text) : body_text
|
29
32
|
end
|
30
33
|
|
34
|
+
def is_truncated
|
35
|
+
truncate ? "truncate_#{truncate}" : nil
|
36
|
+
end
|
37
|
+
|
31
38
|
private
|
32
39
|
|
33
40
|
def apply_highlight(text)
|
@@ -121,61 +121,30 @@ export const toIso = (newDate: Date | string): string => {
|
|
121
121
|
}
|
122
122
|
|
123
123
|
export const fromNow = (newDate: Date | string): string => {
|
124
|
-
const
|
125
|
-
const
|
126
|
-
|
127
|
-
const startDate = formattedDate.getTime()
|
128
|
-
const endDate = today.getTime()
|
124
|
+
const startDate = formatDate(newDate).getTime()
|
125
|
+
const endDate = new Date().getTime()
|
129
126
|
const elapsedTime = endDate - startDate
|
130
|
-
|
131
|
-
|
132
|
-
const
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
const
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
127
|
+
let elapsedTimeString = `${Math.round(elapsedTime / (365.25 * 24 * 60 * 60 * 1000))} years ago`; // 730+ days
|
128
|
+
|
129
|
+
const MILLISECONDS_IN_A_MONTH = 30.44 * 24 * 60 * 60 * 1000
|
130
|
+
|
131
|
+
const elapsedTimeData = [
|
132
|
+
{ min: 0, max: 44999, value: "a few seconds ago" }, // 0-44 seconds
|
133
|
+
{ min: 45000, max: 89999, value: "a minute ago" }, // 45-89 seconds
|
134
|
+
{ min: 90000, max: 2649999, value: `${Math.round(elapsedTime / 60000)} minutes ago`}, // 90s-44 minutes
|
135
|
+
{ min: 2650000, max: 7299999, value: "an hour ago" }, // 45-120 minutes
|
136
|
+
{ min: 7300000, max: 75699999, value: `${Math.round(elapsedTime / 3600000)} hours ago`}, // 2-21 hours
|
137
|
+
{ min: 75700000, max: 172899999, value: "a day ago" }, // 22-48 hours
|
138
|
+
{ min: 172900000, max: 2169999999, value: `${Math.round(elapsedTime / 86400000)} days ago`}, // 2-25 days
|
139
|
+
{ min: 2170000000, max: 5184999999, value: "a month ago"}, // 26-60 days
|
140
|
+
{ min: 5185000000, max: 27561699999, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_MONTH)} months ago`}, // 60-319 days
|
141
|
+
{ min: 27561700000, max: 63072999999, value: "a year ago"}, // 320-730 days
|
142
|
+
];
|
143
|
+
|
144
|
+
for (const timeDate of elapsedTimeData) {
|
145
|
+
if (elapsedTime >= timeDate.min && elapsedTime <= timeDate.max) {
|
146
|
+
elapsedTimeString = timeDate.value;
|
147
|
+
break;
|
179
148
|
}
|
180
149
|
}
|
181
150
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "lg"} ) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<%= pb_rails("table/table_header", props: {
|
5
|
+
id: "name",
|
6
|
+
colspan: 2,
|
7
|
+
sort_menu: [
|
8
|
+
{ item: "Name", link: "?q[sorts]=name+desc", active: false, direction: "desc" },
|
9
|
+
{ item: "Name", link: "?q[sorts]=name+asc", active: true, direction: "asc" },
|
10
|
+
],
|
11
|
+
}) %>
|
12
|
+
<%= pb_rails("table/table_header", props: {
|
13
|
+
text: "Age",
|
14
|
+
id: "age",
|
15
|
+
sort_menu: [
|
16
|
+
{ item: "Age", link: "?q[sorts]=age+desc", active: false, direction: "desc" },
|
17
|
+
{ item: "Age", link: "?q[sorts]=age+asc", active: false, direction: "asc" },
|
18
|
+
],
|
19
|
+
}) %>
|
20
|
+
<%= pb_rails("table/table_header", props: {
|
21
|
+
text: "Territory",
|
22
|
+
id: "territory",
|
23
|
+
sort_menu: [
|
24
|
+
{ item: "Territory", link: "?q[sorts]=territory+desc", active: false, direction: "desc" },
|
25
|
+
{ item: "Territory", link: "?q[sorts]=territory+asc", active: false, direction: "asc" },
|
26
|
+
],
|
27
|
+
}) %>
|
28
|
+
<%= pb_rails("table/table_header", props: { text: "Job Title" }) %>
|
29
|
+
</tr>
|
30
|
+
</thead>
|
31
|
+
<tbody>
|
32
|
+
<tr>
|
33
|
+
<td>Name 1</td>
|
34
|
+
<td>Name 2</td>
|
35
|
+
<td>Value 3</td>
|
36
|
+
<td>Value 4</td>
|
37
|
+
<td>Value 5</td>
|
38
|
+
</tr>
|
39
|
+
<tr>
|
40
|
+
<td>Name 1</td>
|
41
|
+
<td>Name 2</td>
|
42
|
+
<td>Value 3</td>
|
43
|
+
<td>Value 4</td>
|
44
|
+
<td>Value 5</td>
|
45
|
+
</tr>
|
46
|
+
<tr>
|
47
|
+
<td>Name 1</td>
|
48
|
+
<td>Name 2</td>
|
49
|
+
<td>Value 3</td>
|
50
|
+
<td>Value 4</td>
|
51
|
+
<td>Value 5</td>
|
52
|
+
</tr>
|
53
|
+
</tbody>
|
54
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
A kit that produces a `<th>` tag. You can also use the `sort_menu` prop to make the header a sortable link, just like <a href="https://playbook.powerapp.cloud/kits/filter#sort-only" target="_blank">our filter kit.</a>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
$text_align_values: (
|
3
|
+
start: start,
|
4
|
+
end: end,
|
5
|
+
left: left,
|
6
|
+
right: right,
|
7
|
+
center: center,
|
8
|
+
justify: justify,
|
9
|
+
justify-all: justify-all,
|
10
|
+
match-parent: match-parent,
|
11
|
+
);
|
12
|
+
|
13
|
+
[class^=pb_table] {
|
14
|
+
thead {
|
15
|
+
[class^=pb_table_header_kit] {
|
16
|
+
@each $align_name, $align_value in $text_align_values {
|
17
|
+
&[class*=_align_#{$align_name}] {
|
18
|
+
text-align: $align_value;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
[class^=pb_table] {
|
26
|
+
thead {
|
27
|
+
[class^=pb_th_active] {
|
28
|
+
color: $primary !important;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<%= content_tag(:th,
|
2
|
+
colspan: object.colspan,
|
3
|
+
aria: object.aria,
|
4
|
+
class: object.classname,
|
5
|
+
data: object.data,
|
6
|
+
id: "pb-th#{object.id}") do %>
|
7
|
+
<% object.sort_menu.each do |item| %>
|
8
|
+
<% if item[:active] == true %>
|
9
|
+
<%= pb_rails("flex", props:{ align: object.align_content }) do %>
|
10
|
+
<%= content.presence || content_tag(:span, item[:item], class: "pb_th_active") %>
|
11
|
+
<span class="pb_th_active">
|
12
|
+
<%= pb_rails("icon", props: { icon: object.sort_icon(item[:direction]),
|
13
|
+
fixed_width: true,
|
14
|
+
classname: "pb_th_active",
|
15
|
+
padding_left: "xs" }) %>
|
16
|
+
</span>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% if object.sort_menu.all? { |item| item[:active] == false } %>
|
21
|
+
<%= pb_rails("flex", props:{ align: object.align_content }) do %>
|
22
|
+
<%= content.presence || object.text %>
|
23
|
+
<%= pb_rails("icon", props: { icon: "arrow-up-arrow-down",
|
24
|
+
fixed_width: true,
|
25
|
+
padding_left: "xs" }) %>
|
26
|
+
<% end %>
|
27
|
+
<% else %>
|
28
|
+
<%= content.presence || object.text %>
|
29
|
+
<% end %>
|
30
|
+
<% if object.sort_menu != [{}] && object.colspan > 1 %>
|
31
|
+
<%= pb_rails("popover", props: { classname: "pb_filter_sort_menu",
|
32
|
+
close_on_click: "outside",
|
33
|
+
trigger_element_id: "pb-th#{object.id}",
|
34
|
+
tooltip_id: "sort-filter-btn-tooltip#{object.id}",
|
35
|
+
position: object.placement ,
|
36
|
+
padding: 'none'}) do %>
|
37
|
+
<%= pb_rails("list") do %>
|
38
|
+
<% object.sort_menu.each do |item| %>
|
39
|
+
<%= pb_rails("list/item") do %>
|
40
|
+
<%= pb_rails("button", props: { variant: "link" ,
|
41
|
+
classname: "p-0",
|
42
|
+
text: item[:item],
|
43
|
+
link: item[:link],
|
44
|
+
icon: sort_icon(item[:direction]),
|
45
|
+
icon_right: true }) %>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
50
|
+
<% end %>
|
51
|
+
<% end %>
|
52
|
+
<% if object.sort_menu != [{}] && object.colspan == 1 %>
|
53
|
+
<script>
|
54
|
+
document.addEventListener("DOMContentLoaded", function() {
|
55
|
+
var thId = `<%= "#pb-th#{object.id}" %>`
|
56
|
+
var firstLink = `<%= next_link %>`
|
57
|
+
var thElement = document.querySelector(thId);
|
58
|
+
|
59
|
+
thElement.addEventListener("click", function() {
|
60
|
+
window.location.href = firstLink;
|
61
|
+
});
|
62
|
+
});
|
63
|
+
</script>
|
64
|
+
<% end %>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbTable
|
5
|
+
class TableHeader < Playbook::KitBase
|
6
|
+
prop :align, type: Playbook::Props::Enum,
|
7
|
+
values: %w[start center end stretch baseline none],
|
8
|
+
default: "start"
|
9
|
+
prop :align_content, type: Playbook::Props::Enum,
|
10
|
+
values: %w[start center end stretch baseline none],
|
11
|
+
default: "center"
|
12
|
+
prop :colspan, type: Playbook::Props::Number,
|
13
|
+
default: 1
|
14
|
+
prop :placement, type: Playbook::Props::Enum,
|
15
|
+
values: %w[top bottom left right top-start top-end bottom-start bottom-end right-start right-end left-start left-end],
|
16
|
+
default: "bottom-start"
|
17
|
+
prop :sort_menu, type: Playbook::Props::HashArray,
|
18
|
+
default: [{}]
|
19
|
+
prop :text, type: Playbook::Props::String,
|
20
|
+
default: ""
|
21
|
+
|
22
|
+
def classname
|
23
|
+
generate_classname("pb_table_header_kit", align_class)
|
24
|
+
end
|
25
|
+
|
26
|
+
def align_class
|
27
|
+
align.present? ? "align_#{align}" : nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def next_link
|
31
|
+
return sort_menu[0][:link] if sort_menu.all? { |item| item[:active] == false }
|
32
|
+
|
33
|
+
sort_menu.each_with_index do |item, index|
|
34
|
+
if item[:active] == true
|
35
|
+
next_index = (index + 1) % sort_menu.length
|
36
|
+
sort_menu[next_index][:link]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def sort_icon(direction)
|
42
|
+
case direction
|
43
|
+
when "asc"
|
44
|
+
"sort-amount-up"
|
45
|
+
when "desc"
|
46
|
+
"sort-amount-down"
|
47
|
+
else
|
48
|
+
""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -35,6 +35,10 @@
|
|
35
35
|
@include pb_title_thin;
|
36
36
|
}
|
37
37
|
|
38
|
+
&[class*=_truncate] {
|
39
|
+
@include title_truncate;
|
40
|
+
}
|
41
|
+
|
38
42
|
@each $size, $size_value in $breakpoints_grid {
|
39
43
|
@each $title_size_value in [1, 2, 3, 4] {
|
40
44
|
$min_size: map-get($size_value, "min");
|
@@ -46,6 +50,7 @@
|
|
46
50
|
@else if $title_size_value == 3 { @include pb_title_3; }
|
47
51
|
@else if $title_size_value == 4 { @include pb_title_4; }
|
48
52
|
@include title_colors;
|
53
|
+
@include title_truncate;
|
49
54
|
@if $title_size_value != 4 { @include pb_title_bold; }
|
50
55
|
}
|
51
56
|
}
|
@@ -17,6 +17,7 @@ type TitleProps = {
|
|
17
17
|
size?: SizeType | SizeResponsiveType,
|
18
18
|
tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
|
19
19
|
text?: string,
|
20
|
+
truncate?: null | '1' | '2' | '3' | '4' | '5',
|
20
21
|
variant?: null | "link",
|
21
22
|
} & GlobalProps
|
22
23
|
|
@@ -33,12 +34,14 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
33
34
|
bold = true,
|
34
35
|
tag = 'h3',
|
35
36
|
text,
|
37
|
+
truncate = null,
|
36
38
|
variant = null,
|
37
39
|
} = props
|
38
40
|
|
39
41
|
const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
|
40
42
|
const dataProps: {[key: string]: string | number} = buildDataProps(data)
|
41
43
|
const getBold = bold ? '' : 'thin'
|
44
|
+
const isTruncated = truncate ? `truncate_${truncate}` : null
|
42
45
|
const isSizeNumberOrString = typeof size === "number" || typeof size === "string"
|
43
46
|
|
44
47
|
const buildResponsiveSizeCss = () => {
|
@@ -54,7 +57,7 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
54
57
|
}
|
55
58
|
|
56
59
|
const classes = classnames(
|
57
|
-
buildCss('pb_title_kit', isSizeNumberOrString ? `size_${size}` : "", variant, color, getBold),
|
60
|
+
buildCss('pb_title_kit', isSizeNumberOrString ? `size_${size}` : "", variant, color, getBold, isTruncated),
|
58
61
|
globalProps(props),
|
59
62
|
buildResponsiveSizeCss(),
|
60
63
|
className
|
@@ -15,4 +15,23 @@ $pb_title_colors: (
|
|
15
15
|
color: $color
|
16
16
|
}
|
17
17
|
}
|
18
|
+
}
|
19
|
+
|
20
|
+
$pb_title_truncate: (
|
21
|
+
truncate_1: 1,
|
22
|
+
truncate_2: 2,
|
23
|
+
truncate_3: 3,
|
24
|
+
truncate_4: 4,
|
25
|
+
truncate_5: 5
|
26
|
+
);
|
27
|
+
|
28
|
+
@mixin title_truncate {
|
29
|
+
@each $name, $number in $pb_title_truncate {
|
30
|
+
&[class*=_#{$name}] {
|
31
|
+
overflow: hidden;
|
32
|
+
display: -webkit-box;
|
33
|
+
-webkit-line-clamp: $number;
|
34
|
+
-webkit-box-orient: vertical;
|
35
|
+
}
|
36
|
+
}
|
18
37
|
}
|
@@ -16,12 +16,15 @@ module Playbook
|
|
16
16
|
default: nil,
|
17
17
|
deprecated: true
|
18
18
|
prop :bold, type: Playbook::Props::Boolean, default: true
|
19
|
+
prop :truncate, type: Playbook::Props::Enum,
|
20
|
+
values: [nil, "1", "2", "3", "4", "5"],
|
21
|
+
default: nil
|
19
22
|
|
20
23
|
def classname
|
21
24
|
if is_size_responsive
|
22
|
-
generate_classname("pb_title_kit", variant, color, is_bold) + generate_responsive_size_classname
|
25
|
+
generate_classname("pb_title_kit", variant, color, is_bold, is_truncated) + generate_responsive_size_classname
|
23
26
|
else
|
24
|
-
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
27
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold, is_truncated)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -29,6 +32,10 @@ module Playbook
|
|
29
32
|
bold ? nil : "thin"
|
30
33
|
end
|
31
34
|
|
35
|
+
def is_truncated
|
36
|
+
truncate ? "truncate_#{truncate}" : nil
|
37
|
+
end
|
38
|
+
|
32
39
|
def is_size_responsive
|
33
40
|
try(:size).is_a?(::Hash)
|
34
41
|
end
|