playbook_ui 14.14.0.pre.alpha.pbntr500currencykithandlingofnullvalues6275 → 14.14.0.pre.alpha.pbntr500currencykithandlingofnullvalues6311

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c6ef102f160200110b47477b34a9a06798b4ef4f1122151a12341775c20c9a5
4
- data.tar.gz: 14eb41101975901c5f557d1d8b6721fc9301e9b54a30ec0c335b8717dccbe508
3
+ metadata.gz: 17fca453caefd685c9ed41cdcc066aa79f6623d5bf4c9a8601a1e9f95ab47c26
4
+ data.tar.gz: 2ed3fe8635e74c438de05d9c2d9c18d371d5e91abc0f43564f110cbc6ccaa381
5
5
  SHA512:
6
- metadata.gz: 301d0b715331e1e388be9b554865dc59f79b88f5ef11f3a7f038554f215c7b72d6541465d027adcf0c8f9a0fea2dd4e9e1e6f608c6b0d9b9f5360fc52a70ffc8
7
- data.tar.gz: 6e1bc33d1fbe6b1bebe4b112b42c73107685786fbc7ddd01df4f95fe302d015e1225edcfbe042e2931728dcd655fe97a9d3629417c639392fa3753a7cb533ee6
6
+ metadata.gz: c9da096a667206278c2029e809abad8cc4bd1e0923310d335532b8c8cfd267957bc77be6d1e3afffef2eb03d64ed1fb953cc5ebbff7e6f8e17336d85a5949d08
7
+ data.tar.gz: 55c2c623531974e1bab492e272b3fa1cfa9996d3ab5efcb65d34ba0a0037d6e86d0576ea1376eeef937d4047f6adc92abb6194ce1ff0edd16e6c3db05d11f027
@@ -120,7 +120,6 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
120
120
  id={id}
121
121
  >
122
122
  <Caption dark={dark}>{label}</Caption>
123
-
124
123
  <div className={`pb_currency_wrapper${variantClass || emphasizedClass}`}>
125
124
  {unstyled ? (
126
125
  nullDisplay && !amount ? (
@@ -175,7 +174,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
175
174
  )}
176
175
  </div>
177
176
  </div>
178
- );
177
+ )
179
178
  }
180
179
 
181
180
  export default Currency
@@ -11,7 +11,7 @@
11
11
  <% end %>
12
12
  <% else %>
13
13
  <% if object.null_display && object.amount.blank? %>
14
- <%= pb_rails("title", props: {text: object.null_display}) %>
14
+ <%= pb_rails("title", props: object.title_props) %>
15
15
  <% else %>
16
16
  <%= pb_rails("body", props: object.currency_wrapper_props) do %>
17
17
  <%= object.negative_sign %><%= object.symbol %>
@@ -68,10 +68,20 @@ module Playbook
68
68
  }
69
69
  end
70
70
 
71
+ def title_text
72
+ if null_display
73
+ null_display
74
+ elsif swap_negative
75
+ absolute_amount(abbr_or_format_amount)
76
+ else
77
+ abbr_or_format_amount
78
+ end
79
+ end
80
+
71
81
  def title_props
72
82
  {
73
83
  size: size_value,
74
- text: swap_negative ? absolute_amount(abbr_or_format_amount) : abbr_or_format_amount,
84
+ text: title_text,
75
85
  classname: "pb_currency_value",
76
86
  dark: dark,
77
87
  }
@@ -148,8 +158,10 @@ module Playbook
148
158
  1
149
159
  when "md"
150
160
  3
151
- else
161
+ when "sm"
152
162
  4
163
+ else
164
+ 3
153
165
  end
154
166
  end
155
167
 
@@ -3,6 +3,7 @@
3
3
  label: "Nil",
4
4
  margin_bottom: "md",
5
5
  null_display: "--",
6
+ size: "sm"
6
7
  }) %>
7
8
 
8
9
  <%= pb_rails("currency", props: {
@@ -10,11 +11,12 @@
10
11
  label: "Nil",
11
12
  margin_bottom: "md",
12
13
  null_display: "$0.00",
14
+ size: "sm"
13
15
  }) %>
14
16
 
15
17
  <%= pb_rails("currency", props: {
16
18
  amount: "",
17
19
  label: "Nil",
18
- margin_bottom: "md",
19
20
  null_display: " ",
21
+ size: "sm"
20
22
  }) %>
@@ -0,0 +1,71 @@
1
+
2
+ import React from 'react'
3
+ import classnames from 'classnames'
4
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
+ import { globalProps } from '../utilities/globalProps'
6
+
7
+ import Button from '../pb_button/_button'
8
+ import Icon from '../pb_icon/_icon'
9
+ import { IconSizes } from "../pb_icon/_icon"
10
+
11
+ type IconButtonProps = {
12
+ aria?: { [key: string]: string },
13
+ className?: string,
14
+ data?: { [key: string]: string },
15
+ htmlType?: 'submit' | 'reset' | 'button' | undefined,
16
+ icon?: string,
17
+ id?: string,
18
+ link?: string,
19
+ newWindow?: boolean,
20
+ size?: IconSizes,
21
+ target?: string,
22
+ variant?: 'default' | 'link',
23
+ }
24
+
25
+ const IconButton = (props: IconButtonProps) => {
26
+ const {
27
+ aria = {},
28
+ className,
29
+ data = {},
30
+ htmlType = 'button',
31
+ icon = 'bars',
32
+ id,
33
+ link,
34
+ newWindow = false,
35
+ size = "2x",
36
+ target,
37
+ variant = "default",
38
+ } = props
39
+
40
+ const ariaProps = buildAriaProps(aria)
41
+ const dataProps = buildDataProps(data)
42
+ const classes = classnames(buildCss('pb_icon_button_kit', variant), globalProps(props), className)
43
+
44
+ return (
45
+ <div
46
+ {...ariaProps}
47
+ {...dataProps}
48
+ className={classes}
49
+ id={id}
50
+ >
51
+ <Button
52
+ borderRadius="lg"
53
+ htmlType={htmlType}
54
+ link={link}
55
+ newWindow={newWindow}
56
+ target={target}
57
+ >
58
+ <Icon
59
+ className="icon_button_icon"
60
+ fixedWidth
61
+ icon={icon}
62
+ paddingX="xxs"
63
+ paddingY="xs"
64
+ size={size}
65
+ />
66
+ </Button>
67
+ </div>
68
+ )
69
+ }
70
+
71
+ export default IconButton
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { IconButton } from 'playbook-ui'
3
+
4
+ const IconButtonDefault = (props) => (
5
+ <div>
6
+ <IconButton
7
+ {...props}
8
+ />
9
+ <IconButton
10
+ {...props}
11
+ marginTop="md"
12
+ variant="link"
13
+ />
14
+ </div>
15
+ )
16
+
17
+ export default IconButtonDefault
@@ -0,0 +1,61 @@
1
+ import React from 'react'
2
+ import { IconButton, Flex } from 'playbook-ui'
3
+
4
+ const IconButtonSizes = (props) => (
5
+ <div>
6
+ <Flex align="center">
7
+ <IconButton
8
+ {...props}
9
+ size="lg"
10
+ />
11
+ <span>Large</span>
12
+ </Flex>
13
+ <Flex align="center">
14
+ <IconButton
15
+ {...props}
16
+ size="sm"
17
+ />
18
+ <span>Small</span>
19
+ </Flex>
20
+ <Flex align="center">
21
+ <IconButton
22
+ {...props}
23
+ size="xs"
24
+ />
25
+ <span>XSmall</span>
26
+ </Flex>
27
+ <Flex
28
+ align="center"
29
+ marginTop="md"
30
+ >
31
+ <IconButton
32
+ {...props}
33
+ size="1x"
34
+ />
35
+ <span>1x</span>
36
+ </Flex>
37
+ <Flex align="center">
38
+ <IconButton
39
+ {...props}
40
+ size="2x"
41
+ />
42
+ <span>2x</span>
43
+ </Flex>
44
+ <Flex align="center">
45
+ <IconButton
46
+ {...props}
47
+ size="3x"
48
+ />
49
+ <span>3x</span>
50
+ </Flex>
51
+ <Flex align="center">
52
+ <IconButton
53
+ {...props}
54
+ size="4x"
55
+ />
56
+ <span>4x</span>
57
+ </Flex>
58
+ </div>
59
+ )
60
+
61
+ export default IconButtonSizes
@@ -3,3 +3,7 @@ examples:
3
3
  rails:
4
4
  - icon_button_default: Default
5
5
  - icon_button_sizes: Sizes
6
+
7
+ react:
8
+ - icon_button_default: Default
9
+ - icon_button_sizes: Sizes
@@ -0,0 +1,2 @@
1
+ export { default as IconButtonDefault } from './_icon_button_default.jsx'
2
+ export { default as IconButtonSizes } from './_icon_button_sizes.jsx'
@@ -0,0 +1,39 @@
1
+ import { ensureAccessible, renderKit } from '../utilities/test-utils'
2
+
3
+ import { IconButton } from 'playbook-ui'
4
+
5
+ const props = {
6
+ data: { testid: 'default', icon: 'plus' }
7
+ }
8
+
9
+ test('default test', () => {
10
+ const kit = renderKit(IconButton, props)
11
+
12
+ expect(kit).toBeInTheDocument()
13
+ expect(kit).toHaveClass('pb_icon_button_kit_default')
14
+
15
+ const iconElement = kit.querySelector('.icon_button_icon')
16
+ expect(iconElement).toBeInTheDocument()
17
+ })
18
+
19
+ it("should be accessible", async () => {
20
+ ensureAccessible(IconButton, props)
21
+ })
22
+
23
+ test('passes link variant prop', () => {
24
+ const kit = renderKit(IconButton, { ...props, variant: "link" })
25
+ expect(kit).toBeInTheDocument()
26
+ expect(kit).toHaveClass('pb_icon_button_kit_link')
27
+ })
28
+
29
+ test('should set button type to "submit" when htmlType prop is passed', () => {
30
+ const kit = renderKit(IconButton, { ...props, htmlType: 'submit' })
31
+ const buttonElement = kit.querySelector('button')
32
+ expect(buttonElement).toHaveAttribute('type', 'submit')
33
+ })
34
+
35
+ test('passes custom classname', () => {
36
+ const kit = renderKit(IconButton, { ...props, className: "extra_class" })
37
+ expect(kit).toBeInTheDocument()
38
+ expect(kit).toHaveClass('pb_icon_button_kit_default extra_class')
39
+ })
@@ -1,6 +1,6 @@
1
1
  <%= pb_content_tag(:li) do %>
2
- <div class="box" style="max-width: min-content;" id="<%= object.tooltip_trigger_class %>">
3
- <div class="circle">
2
+ <div class="box" style="max-width: min-content;">
3
+ <div class="circle" id="<%= object.tooltip_trigger_class %>" >
4
4
  <%= pb_rails("icon", props: { icon: object.icon, size: "xs" }) if object.icon.present? %>
5
5
  </div>
6
6
  <% if object.tooltip.present? %>
@@ -152,4 +152,4 @@ export default class PbTooltip extends PbEnhancedElement {
152
152
  get triggerMethod() {
153
153
  return this.element.dataset.pbTooltipTriggerMethod || 'hover'
154
154
  }
155
- }
155
+ }