playbook_ui 12.33.0 → 12.33.1.pre.alpha.PLAY933navkitcollapsible994
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/_collapsible.tsx +6 -4
- data/app/pb_kits/playbook/pb_collapsible/_helper_functions.ts +25 -0
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +19 -11
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +27 -14
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +7 -2
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.rb +2 -7
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.html.erb +10 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +19 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.md +2 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_size.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_collapsible/index.js +3 -3
- data/app/pb_kits/playbook/pb_date/_date.tsx +8 -7
- data/app/pb_kits/playbook/pb_date/docs/_date_alignment.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +4 -4
- data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +2 -2
- data/app/pb_kits/playbook/pb_date/docs/_date_variants.jsx +5 -5
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +31 -45
- data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +3 -5
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +21 -24
- data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +1 -1
- data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +8 -6
- data/app/pb_kits/playbook/pb_kit/dateTime.ts +67 -139
- data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +31 -52
- data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +120 -0
- data/app/pb_kits/playbook/pb_message/_message.tsx +24 -24
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +6 -0
- data/app/pb_kits/playbook/pb_nav/_item.tsx +98 -49
- data/app/pb_kits/playbook/pb_nav/_nav.scss +1 -0
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +9 -11
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.html.erb +24 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +83 -0
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_custom_icons.jsx +86 -0
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_nav/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_nav/item.html.erb +34 -12
- data/app/pb_kits/playbook/pb_nav/item.rb +5 -0
- data/app/pb_kits/playbook/pb_time/_time.tsx +11 -9
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +49 -46
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +6 -4
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +11 -11
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +11 -8
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +2 -2
- metadata +16 -8
- data/app/pb_kits/playbook/pb_collapsible/types.d.ts +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33130ba9d6074894b7db63e664ca3a35730c9ac366285de0bcfb7bc78fbb88a9
|
4
|
+
data.tar.gz: e2b5fe4b62c4117d14b09cdd7e9ec93de3678c54b8575b4c1e6ccf26edac759f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec5221a8aa347f88b9483e371eefafae1fbdd9e340e7b8029fa077eac7f03c3ef5536564b677367698b58489dee4415b77298de4efa5ac62d08078eb8dde54e
|
7
|
+
data.tar.gz: e95ca7bbcba72fbc6fc2309a09aec09f4b9ae3ab616837192a520c1b337b221a2656062f9ebbb27ae4832df39b592453d56cc39c436f533e8f32490e0ca586a3
|
@@ -7,17 +7,18 @@ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
|
7
7
|
import CollapsibleContent from './child_kits/CollapsibleContent'
|
8
8
|
import CollapsibleMain from './child_kits/CollapsibleMain'
|
9
9
|
import CollapsibleContext from './context'
|
10
|
-
import IconSizes from "../pb_icon/_icon"
|
10
|
+
import { IconSizes } from "../pb_icon/_icon"
|
11
11
|
|
12
12
|
|
13
13
|
type CollapsibleProps = {
|
14
|
-
children?: JSX.Element | [],
|
14
|
+
children?: JSX.Element | [] | any,
|
15
15
|
aria?: {[key: string]: string},
|
16
16
|
className?: string,
|
17
17
|
collapsed?: boolean,
|
18
18
|
data?: object,
|
19
|
+
icon?: Object,
|
19
20
|
iconColor?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
|
20
|
-
iconSize?:
|
21
|
+
iconSize?: IconSizes
|
21
22
|
id?: string,
|
22
23
|
padding?: string,
|
23
24
|
}
|
@@ -37,6 +38,7 @@ const Collapsible = ({
|
|
37
38
|
children = [],
|
38
39
|
collapsed = true,
|
39
40
|
data = {},
|
41
|
+
icon,
|
40
42
|
iconColor = 'default',
|
41
43
|
iconSize,
|
42
44
|
id,
|
@@ -64,7 +66,7 @@ const Collapsible = ({
|
|
64
66
|
)
|
65
67
|
|
66
68
|
return (
|
67
|
-
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, collapse, iconSize, iconColor }}>
|
69
|
+
<CollapsibleContext.Provider value={{ collapsed: isCollapsed, collapse, icon, iconSize, iconColor }}>
|
68
70
|
<div
|
69
71
|
{...ariaProps}
|
70
72
|
{...dataProps}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export const showElement = (elem: any) => {
|
2
|
+
elem.style.display = 'block';
|
3
|
+
const height = elem.scrollHeight + 'px'; // Get its height
|
4
|
+
elem.style.height = height; // Update the max-height
|
5
|
+
elem.classList.add('is-visible')
|
6
|
+
// Once the transition is complete, remove the inline max-height so the content can scale responsively
|
7
|
+
window.setTimeout(() => {
|
8
|
+
elem.style.height = '';
|
9
|
+
}, 300);
|
10
|
+
};
|
11
|
+
|
12
|
+
export const hideElement = (elem:any) => {
|
13
|
+
elem.style.height = elem.scrollHeight + 'px';
|
14
|
+
|
15
|
+
window.setTimeout(() => {
|
16
|
+
elem.style.height = '0';
|
17
|
+
elem.style.paddingTop = '0';
|
18
|
+
elem.style.paddingBottom = '0';
|
19
|
+
}, 1);
|
20
|
+
|
21
|
+
// When the transition is complete, hide it
|
22
|
+
window.setTimeout(() => {
|
23
|
+
elem.classList.remove('is-visible');
|
24
|
+
}, 300);
|
25
|
+
};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import classnames from 'classnames'
|
2
|
-
import React, { useContext } from 'react'
|
3
|
-
import AnimateHeight from 'react-animate-height'
|
2
|
+
import React, { useContext, useRef, useEffect } from 'react'
|
4
3
|
import { buildCss } from '../../utilities/props'
|
5
4
|
import { globalProps } from '../../utilities/globalProps'
|
5
|
+
import { hideElement, showElement } from '../_helper_functions'
|
6
6
|
|
7
7
|
import CollapsibleContext from '../context'
|
8
8
|
|
@@ -21,17 +21,25 @@ const CollapsibleContent = ({
|
|
21
21
|
const context: {[key: string]: boolean | string} = useContext(CollapsibleContext)
|
22
22
|
const contentCSS = buildCss('pb_collapsible_content_kit')
|
23
23
|
const contentSpacing = globalProps(props, { padding })
|
24
|
+
const contentRef = useRef(null);
|
25
|
+
|
26
|
+
useEffect(() => {
|
27
|
+
// Use the showElement and hideElement functions based on the context value
|
28
|
+
if (contentRef.current) {
|
29
|
+
if (context.collapsed) {
|
30
|
+
hideElement(contentRef.current);
|
31
|
+
} else {
|
32
|
+
showElement(contentRef.current);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}, [context.collapsed]);
|
24
36
|
|
25
37
|
return (
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
>
|
31
|
-
<div className={classnames(contentCSS, className, contentSpacing)}>
|
32
|
-
{children}
|
33
|
-
</div>
|
34
|
-
</AnimateHeight>
|
38
|
+
<div ref={contentRef}
|
39
|
+
data-collapsible-content="true"
|
40
|
+
className={classnames(contentCSS, contentSpacing, "toggle-content", className)}>
|
41
|
+
{children}
|
42
|
+
</div>
|
35
43
|
)
|
36
44
|
}
|
37
45
|
|
@@ -7,6 +7,7 @@ import { globalProps } from '../../utilities/globalProps'
|
|
7
7
|
|
8
8
|
import Flex from '../../pb_flex/_flex'
|
9
9
|
import FlexItem from '../../pb_flex/_flex_item'
|
10
|
+
import Icon, { IconSizes } from "../../pb_icon/_icon"
|
10
11
|
import CollapsibleContext from '../context'
|
11
12
|
|
12
13
|
|
@@ -39,24 +40,35 @@ type IconColors = "default" | "light" | "lighter" | "link" | "error" | "success
|
|
39
40
|
|
40
41
|
type IconProps = {
|
41
42
|
collapsed: boolean | (()=> void)
|
43
|
+
icon?: string[] | string
|
42
44
|
iconColor?: IconColors
|
43
|
-
iconSize?:
|
45
|
+
iconSize?: IconSizes
|
44
46
|
}
|
45
47
|
|
46
|
-
const
|
47
|
-
const direction = collapsed ? 'down' : 'up'
|
48
|
-
const size = iconSize
|
48
|
+
const ToggleIcon = ({ collapsed, icon, iconSize, iconColor }: IconProps) => {
|
49
49
|
const color = colorMap[iconColor]
|
50
50
|
|
51
51
|
return (
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
<>
|
53
|
+
{collapsed ? (
|
54
|
+
<div
|
55
|
+
className="icon_wrapper"
|
56
|
+
key="chevron-down"
|
57
|
+
style={{ verticalAlign: "middle", color: color }}
|
58
|
+
>
|
59
|
+
<Icon icon={icon ? icon[0] : "chevron-down"} size={iconSize} />
|
60
|
+
</div>
|
61
|
+
) : (
|
62
|
+
<div
|
63
|
+
className="icon_wrapper"
|
64
|
+
key="chevron-up"
|
65
|
+
style={{ verticalAlign: "middle", color: color }}
|
66
|
+
>
|
67
|
+
<Icon icon={icon ? icon[1] : "chevron-up"} size={iconSize} />
|
68
|
+
</div>
|
69
|
+
)}
|
70
|
+
</>
|
71
|
+
);
|
60
72
|
}
|
61
73
|
|
62
74
|
const CollapsibleMain = ({
|
@@ -79,10 +91,11 @@ const CollapsibleMain = ({
|
|
79
91
|
>
|
80
92
|
<FlexItem>{children}</FlexItem>
|
81
93
|
<FlexItem>
|
82
|
-
<
|
94
|
+
<ToggleIcon
|
83
95
|
collapsed={context.collapsed as () => void}
|
84
96
|
iconColor={context.iconColor as IconColors}
|
85
|
-
iconSize={context.iconSize}
|
97
|
+
iconSize={context.iconSize as IconSizes}
|
98
|
+
icon={context.icon as string[] | string}
|
86
99
|
/>
|
87
100
|
</FlexItem>
|
88
101
|
</Flex>
|
@@ -10,8 +10,13 @@
|
|
10
10
|
<% end %>
|
11
11
|
<%= pb_rails("flex/flex_item") do %>
|
12
12
|
<div style="color: <%= object.icon_color %>">
|
13
|
-
|
14
|
-
|
13
|
+
<% if object.icon.present? %>
|
14
|
+
<%= pb_rails("icon", props: { icon: "#{icon[0]}", id:"collapsible_open_icon", size: object.size }) %>
|
15
|
+
<%= pb_rails("icon", props: { icon: "#{icon[1]}", id:"collapsible_close_icon", size: object.size }) %>
|
16
|
+
<% else %>
|
17
|
+
<%= pb_rails("icon", props: { icon: "chevron-down", id:"collapsible_open_icon", size: object.size }) %>
|
18
|
+
<%= pb_rails("icon", props: { icon: "chevron-up", id:"collapsible_close_icon", size: object.size }) %>
|
19
|
+
<% end %>
|
15
20
|
</div>
|
16
21
|
<% end %>
|
17
22
|
<% end %>
|
@@ -6,6 +6,8 @@ module Playbook
|
|
6
6
|
prop :color, type: Playbook::Props::Enum,
|
7
7
|
values: %w[default light lighter link success error],
|
8
8
|
default: "default"
|
9
|
+
prop :icon, type: Playbook::Props::Array,
|
10
|
+
default: []
|
9
11
|
prop :size, type: Playbook::Props::Enum,
|
10
12
|
values: ["lg", "xs", "sm", "1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x", nil],
|
11
13
|
default: nil
|
@@ -17,13 +19,6 @@ module Playbook
|
|
17
19
|
generate_classname("pb_collapsible_main_kit", padding, separator: " ")
|
18
20
|
end
|
19
21
|
|
20
|
-
def icon_size
|
21
|
-
return "" if size.nil?
|
22
|
-
|
23
|
-
size_object = { lg: "fa-lg", xs: "fa-xs", sm: "fa-sm", "1x": "fa-1x", "2x": "fa-2x", "3x": "fa-3x", "4x": "fa-4x", "5x": "fa-5x", "6x": "fa-6x", "7x": "fa-7x", "8x": "fa-8x", "9x": "fa-9x", "10x": "fa-10x" }
|
24
|
-
size_object[size.to_sym]
|
25
|
-
end
|
26
|
-
|
27
22
|
def icon_color
|
28
23
|
return "" if color.nil?
|
29
24
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= pb_rails("collapsible", props: { name: "custom-icons-example" }) do %>
|
2
|
+
<%= pb_rails("collapsible/collapsible_main", props: { padding: "md", name: "custom-icons-main", icon: ["plus", "minus"]}) do %>
|
3
|
+
<%= pb_rails("body", props: { text: "Main Section"}) %>
|
4
|
+
<% end %>
|
5
|
+
<%= pb_rails("collapsible/collapsible_content", props: { padding: "md" }) do %>
|
6
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis, risus a fringilla luctus, sapien eros sodales ex, quis molestie est nulla non turpis. Vestibulum aliquet at ipsum eget posuere. Morbi sed laoreet erat. Sed commodo posuere lectus, at porta nulla ornare a. Suspendisse quam est, sollicitudin ut enim sit amet, commodo placerat enim. Donec laoreet metus ac mauris pellentesque mattis. Pellentesque luctus vel mauris non aliquam. Mauris hendrerit mattis porttitor. Curabitur vehicula justo non ex consectetur commodo. Quisque posuere aliquet quam. Maecenas malesuada magna mauris, ac tempor metus euismod at.
|
7
|
+
<br><br>
|
8
|
+
Cras ornare fermentum magna mollis efficitur. Sed vitae nulla vel purus ultrices mollis. Maecenas id nulla id libero faucibus feugiat quis sit amet turpis. In commodo pellentesque risus at fringilla. Integer non interdum leo, non commodo ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut mi augue, dignissim at orci vel, egestas aliquam mi. Proin finibus aliquet tempor. Integer cursus, ex quis gravida rhoncus, nisi elit viverra ipsum, non efficitur est ex ac tortor. Praesent vitae odio massa.
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Collapsible } from '../..'
|
3
|
+
|
4
|
+
const CollapsibleIcons = () => (
|
5
|
+
<Collapsible icon={['plus','minus']}>
|
6
|
+
<Collapsible.Main>
|
7
|
+
<div>{'Main Section'}</div>
|
8
|
+
</Collapsible.Main>
|
9
|
+
<Collapsible.Content>
|
10
|
+
<div>
|
11
|
+
{
|
12
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel erat sed purus hendrerit viverra. Duis et vestibulum metus. Sed consequat ut ante non vehicula. Etiam nunc massa, pharetra vel quam id, posuere rhoncus quam. Quisque imperdiet arcu enim, nec aliquet justo auctor eget. Curabitur in metus nec nunc rhoncus faucibus vitae ac elit. Nulla facilisi. Vestibulum quis pretium nulla. Nulla ut accumsan velit. Duis varius urna sed sem tempor, sit amet fermentum nibh auctor. Praesent lorem arcu, egestas non ante quis, placerat pellentesque lectus.Vestibulum lacinia ipsum quis venenatis tristique. Vivamus suscipit, libero eu fringilla egestas, orci urna commodo arcu, vel gravida turpis ipsum molestie nibh. Donec cursus eu ante sagittis ultrices. Phasellus id sagittis risus. Mauris dapibus neque faucibus, tempor ligula vel, cursus ante. Donec faucibus gravida porta. Nullam egestas est quis aliquam feugiat. Sed eget metus diam. Cras eget placerat libero.'
|
13
|
+
}
|
14
|
+
</div>
|
15
|
+
</Collapsible.Content>
|
16
|
+
</Collapsible>
|
17
|
+
)
|
18
|
+
|
19
|
+
export default CollapsibleIcons
|
@@ -0,0 +1,2 @@
|
|
1
|
+
##### Prop
|
2
|
+
This kit uses 'chevron-up' and 'chevron-down' icons as default for the toggle icons. To customize these icons, use the `icon` prop to pass in an array of two icons, the first will render when the collapisble is closed and the second will render when the collapsible is open. In this example, we are using `icon: ['plus','minus']`
|
@@ -1,4 +1,4 @@
|
|
1
1
|
##### Prop
|
2
|
-
This kit uses `icon` sizes. If you don't give it a size, it will default to medium.
|
2
|
+
This kit uses `icon` sizes. If you don't give it a size, it will default to medium. This can be replaced with the sizes below:
|
3
3
|
|
4
4
|
* `lg` `xs` `sm` `1x` `2x` `3x` `4x` `5x` `6x` `7x` `8x` `9x` `10x`
|
@@ -4,8 +4,10 @@ examples:
|
|
4
4
|
- collapsible_default: Default
|
5
5
|
- collapsible_size: Size
|
6
6
|
- collapsible_color: Color
|
7
|
+
- collapsible_icons: Custom Icons
|
7
8
|
|
8
9
|
react:
|
9
10
|
- collapsible_default: Default
|
10
11
|
- collapsible_size: Size
|
11
|
-
- collapsible_color: Color
|
12
|
+
- collapsible_color: Color
|
13
|
+
- collapsible_icons: Custom Icons
|
@@ -1,3 +1,4 @@
|
|
1
1
|
export { default as CollapsibleDefault } from './_collapsible_default.jsx'
|
2
2
|
export { default as CollapsibleSize } from './_collapsible_size.jsx'
|
3
3
|
export { default as CollapsibleColor } from './_collapsible_color.jsx'
|
4
|
+
export { default as CollapsibleIcons } from './_collapsible_icons.jsx'
|
@@ -2,8 +2,8 @@ import PbEnhancedElement from '../pb_enhanced_element'
|
|
2
2
|
|
3
3
|
const MAIN_SELECTOR = '[data-collapsible-main]'
|
4
4
|
const CONTENT_SELECTOR = '[data-collapsible-content]'
|
5
|
-
const DOWN_ARROW_SELECTOR = '
|
6
|
-
const UP_ARROW_SELECTOR = '
|
5
|
+
const DOWN_ARROW_SELECTOR = '#collapsible_open_icon'
|
6
|
+
const UP_ARROW_SELECTOR = '#collapsible_close_icon'
|
7
7
|
|
8
8
|
export default class PbCollapsible extends PbEnhancedElement {
|
9
9
|
static get selector() {
|
@@ -75,5 +75,5 @@ export default class PbCollapsible extends PbEnhancedElement {
|
|
75
75
|
displayUpArrow() {
|
76
76
|
this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
|
77
77
|
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
|
78
|
-
|
78
|
+
}
|
79
79
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import classnames from "classnames";
|
3
3
|
|
4
|
+
import DateTime from "../pb_kit/dateTime";
|
4
5
|
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
5
6
|
import { globalProps } from "../utilities/globalProps";
|
6
|
-
import DateTime from '../pb_kit/dateTime';
|
7
7
|
|
8
8
|
import Body from "../pb_body/_body";
|
9
9
|
import Caption from "../pb_caption/_caption";
|
@@ -20,7 +20,7 @@ type PbDateProps = {
|
|
20
20
|
showIcon?: boolean;
|
21
21
|
size?: "sm" | "md" | "lg";
|
22
22
|
unstyled?: boolean;
|
23
|
-
value: Date;
|
23
|
+
value: string | Date;
|
24
24
|
};
|
25
25
|
|
26
26
|
const PbDate = (props: PbDateProps) => {
|
@@ -37,11 +37,12 @@ const PbDate = (props: PbDateProps) => {
|
|
37
37
|
value,
|
38
38
|
} = props;
|
39
39
|
|
40
|
-
const
|
41
|
-
const
|
42
|
-
const
|
43
|
-
const
|
44
|
-
const
|
40
|
+
const dateTimestamp = new DateTime({ value: value });
|
41
|
+
const weekday = dateTimestamp.toWeekday();
|
42
|
+
const month = dateTimestamp.toMonth();
|
43
|
+
const day = dateTimestamp.toDay();
|
44
|
+
const year = dateTimestamp.toYear();
|
45
|
+
const currentYear = new Date().getFullYear().toString();
|
45
46
|
|
46
47
|
const ariaProps = buildAriaProps(aria);
|
47
48
|
const dataProps = buildDataProps(data);
|
@@ -7,7 +7,7 @@ const DateAlignment = (props) => {
|
|
7
7
|
<FormattedDate
|
8
8
|
dayOfWeek
|
9
9
|
icon
|
10
|
-
value=
|
10
|
+
value="1995-12-25"
|
11
11
|
{...props}
|
12
12
|
/>
|
13
13
|
|
@@ -17,7 +17,7 @@ const DateAlignment = (props) => {
|
|
17
17
|
alignment="center"
|
18
18
|
dayOfWeek
|
19
19
|
icon
|
20
|
-
value=
|
20
|
+
value="2020-12-25"
|
21
21
|
{...props}
|
22
22
|
/>
|
23
23
|
|
@@ -14,7 +14,7 @@ const DateDefault = (props) => {
|
|
14
14
|
|
15
15
|
<FormattedDate
|
16
16
|
size="sm"
|
17
|
-
value=
|
17
|
+
value="2012-08-03"
|
18
18
|
{...props}
|
19
19
|
/>
|
20
20
|
|
@@ -23,7 +23,7 @@ const DateDefault = (props) => {
|
|
23
23
|
<FormattedDate
|
24
24
|
showDayOfWeek
|
25
25
|
size="sm"
|
26
|
-
value=
|
26
|
+
value="2017-12-03"
|
27
27
|
{...props}
|
28
28
|
/>
|
29
29
|
|
@@ -38,7 +38,7 @@ const DateDefault = (props) => {
|
|
38
38
|
<br />
|
39
39
|
|
40
40
|
<FormattedDate
|
41
|
-
value=
|
41
|
+
value="2012-08-03"
|
42
42
|
{...props}
|
43
43
|
/>
|
44
44
|
|
@@ -46,7 +46,7 @@ const DateDefault = (props) => {
|
|
46
46
|
|
47
47
|
<FormattedDate
|
48
48
|
showDayOfWeek
|
49
|
-
value=
|
49
|
+
value="2017-12-03"
|
50
50
|
{...props}
|
51
51
|
/>
|
52
52
|
</>
|
@@ -21,7 +21,7 @@ const DateUnstyled = (props) => {
|
|
21
21
|
<Title size={1}>
|
22
22
|
<FormattedDate
|
23
23
|
unstyled
|
24
|
-
value=
|
24
|
+
value="1995-12-25"
|
25
25
|
{...props}
|
26
26
|
/>
|
27
27
|
</Title>
|
@@ -36,7 +36,7 @@ const DateUnstyled = (props) => {
|
|
36
36
|
showDayOfWeek
|
37
37
|
showIcon
|
38
38
|
unstyled
|
39
|
-
value=
|
39
|
+
value="1995-12-25"
|
40
40
|
{...props}
|
41
41
|
/>
|
42
42
|
</Caption>
|
@@ -7,7 +7,7 @@ const DateVariants = (props) => {
|
|
7
7
|
<FormattedDate
|
8
8
|
showIcon
|
9
9
|
size="sm"
|
10
|
-
value=
|
10
|
+
value="1995-12-25"
|
11
11
|
{...props}
|
12
12
|
/>
|
13
13
|
|
@@ -15,7 +15,7 @@ const DateVariants = (props) => {
|
|
15
15
|
<br />
|
16
16
|
|
17
17
|
<FormattedDate
|
18
|
-
value=
|
18
|
+
value="1995-12-25"
|
19
19
|
{...props}
|
20
20
|
/>
|
21
21
|
|
@@ -24,7 +24,7 @@ const DateVariants = (props) => {
|
|
24
24
|
|
25
25
|
<FormattedDate
|
26
26
|
showIcon
|
27
|
-
value=
|
27
|
+
value="1995-12-25"
|
28
28
|
{...props}
|
29
29
|
/>
|
30
30
|
|
@@ -33,7 +33,7 @@ const DateVariants = (props) => {
|
|
33
33
|
|
34
34
|
<FormattedDate
|
35
35
|
showDayOfWeek
|
36
|
-
value=
|
36
|
+
value="1995-12-25"
|
37
37
|
{...props}
|
38
38
|
/>
|
39
39
|
|
@@ -43,7 +43,7 @@ const DateVariants = (props) => {
|
|
43
43
|
<FormattedDate
|
44
44
|
showDayOfWeek
|
45
45
|
showIcon
|
46
|
-
value=
|
46
|
+
value="1995-12-25"
|
47
47
|
{...props}
|
48
48
|
/>
|
49
49
|
</div>
|
@@ -3,7 +3,7 @@ import classnames from "classnames";
|
|
3
3
|
|
4
4
|
import { globalProps } from "../utilities/globalProps";
|
5
5
|
import { buildCss, buildDataProps } from "../utilities/props";
|
6
|
-
import DateTime from
|
6
|
+
import DateTime from "../pb_kit/dateTime";
|
7
7
|
|
8
8
|
import Body from "../pb_body/_body";
|
9
9
|
import Caption from "../pb_caption/_caption";
|
@@ -21,16 +21,18 @@ type DateRangeInlineProps = {
|
|
21
21
|
endDate?: Date;
|
22
22
|
};
|
23
23
|
|
24
|
-
const dateTimestamp = (dateValue: Date, includeYear: boolean) => {
|
24
|
+
const dateTimestamp = (dateValue: Date | string, includeYear: boolean) => {
|
25
|
+
const date = new DateTime({ value: dateValue });
|
25
26
|
if (includeYear) {
|
26
|
-
return `${
|
27
|
+
return `${date.toMonth()} ${date.toDay()}, ${date.toYear()}`;
|
27
28
|
} else {
|
28
|
-
return `${
|
29
|
+
return `${date.toMonth()} ${date.toDay()}`;
|
29
30
|
}
|
30
31
|
};
|
31
32
|
|
32
|
-
const dateTimeIso = (dateValue: Date) => {
|
33
|
-
|
33
|
+
const dateTimeIso = (dateValue: Date | string) => {
|
34
|
+
const date = new DateTime({ value: dateValue });
|
35
|
+
return date.toIso();
|
34
36
|
};
|
35
37
|
|
36
38
|
const DateRangeInline = (props: DateRangeInlineProps) => {
|
@@ -50,17 +52,14 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
50
52
|
<>
|
51
53
|
{icon && (
|
52
54
|
<>
|
53
|
-
<Body color="light"
|
54
|
-
key={Math.random()}
|
55
|
-
tag="span"
|
56
|
-
>
|
55
|
+
<Body color="light" key={Math.random()} tag="span">
|
57
56
|
<Icon
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
className="pb_date_range_inline_icon"
|
58
|
+
dark={dark}
|
59
|
+
fixedWidth
|
60
|
+
icon="calendar-alt"
|
61
|
+
size={size}
|
62
|
+
tag="span"
|
64
63
|
/>
|
65
64
|
</Body>
|
66
65
|
</>
|
@@ -79,7 +78,7 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
79
78
|
|
80
79
|
const dateRangeClasses = buildCss("pb_date_range_inline_kit", align);
|
81
80
|
const dataProps = buildDataProps(data)
|
82
|
-
const renderTime = (date: Date) => {
|
81
|
+
const renderTime = (date: Date | string) => {
|
83
82
|
return (
|
84
83
|
<time dateTime={dateTimeIso(date)}>
|
85
84
|
{dateInCurrentYear() ? (
|
@@ -93,30 +92,24 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
93
92
|
|
94
93
|
return (
|
95
94
|
<div
|
96
|
-
|
97
|
-
|
95
|
+
{...dataProps}
|
96
|
+
className={classnames(dateRangeClasses, globalProps(props), className)}
|
98
97
|
>
|
99
98
|
<div className="pb_date_range_inline_wrapper">
|
100
99
|
{size == "xs" && (
|
101
100
|
<>
|
102
101
|
{iconContent()}
|
103
|
-
<Caption dark={dark}
|
104
|
-
tag="span"
|
105
|
-
>
|
102
|
+
<Caption dark={dark} tag="span">
|
106
103
|
{renderTime(startDate)}
|
107
104
|
</Caption>
|
108
|
-
<Caption dark={dark}
|
109
|
-
tag="span"
|
110
|
-
>
|
105
|
+
<Caption dark={dark} tag="span">
|
111
106
|
<Icon
|
112
|
-
|
113
|
-
|
114
|
-
|
107
|
+
className="pb_date_range_inline_arrow"
|
108
|
+
fixedWidth
|
109
|
+
icon="long-arrow-right"
|
115
110
|
/>
|
116
111
|
</Caption>
|
117
|
-
<Caption dark={dark}
|
118
|
-
tag="span"
|
119
|
-
>
|
112
|
+
<Caption dark={dark} tag="span">
|
120
113
|
{renderTime(endDate)}
|
121
114
|
</Caption>
|
122
115
|
</>
|
@@ -125,25 +118,18 @@ const DateRangeInline = (props: DateRangeInlineProps) => {
|
|
125
118
|
{size == "sm" && (
|
126
119
|
<>
|
127
120
|
{iconContent()}
|
128
|
-
<Body dark={dark}
|
129
|
-
tag="span"
|
130
|
-
>
|
121
|
+
<Body dark={dark} tag="span">
|
131
122
|
{renderTime(startDate)}
|
132
123
|
</Body>
|
133
|
-
<Body color="light"
|
134
|
-
dark={dark}
|
135
|
-
tag="span"
|
136
|
-
>
|
124
|
+
<Body color="light" dark={dark} tag="span">
|
137
125
|
<Icon
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
126
|
+
className="pb_date_range_inline_arrow"
|
127
|
+
dark={dark}
|
128
|
+
fixedWidth
|
129
|
+
icon="long-arrow-right"
|
142
130
|
/>
|
143
131
|
</Body>
|
144
|
-
<Body dark={dark}
|
145
|
-
tag="span"
|
146
|
-
>
|
132
|
+
<Body dark={dark} tag="span">
|
147
133
|
{renderTime(endDate)}
|
148
134
|
</Body>
|
149
135
|
</>
|
@@ -14,9 +14,9 @@ type DateRangeStackedProps = {
|
|
14
14
|
className?: string | string[],
|
15
15
|
data?: string,
|
16
16
|
dark?: boolean,
|
17
|
-
endDate:
|
17
|
+
endDate: string,
|
18
18
|
id?: string,
|
19
|
-
startDate:
|
19
|
+
startDate: string,
|
20
20
|
}
|
21
21
|
|
22
22
|
const DateRangeStacked = (props: DateRangeStackedProps) => {
|
@@ -29,9 +29,7 @@ const DateRangeStacked = (props: DateRangeStackedProps) => {
|
|
29
29
|
const dataProps = buildDataProps(data)
|
30
30
|
|
31
31
|
return (
|
32
|
-
<div {...dataProps}
|
33
|
-
className={css}
|
34
|
-
>
|
32
|
+
<div {...dataProps} className={css}>
|
35
33
|
<Flex vertical="center">
|
36
34
|
<FlexItem>
|
37
35
|
<DateYearStacked
|