playbook_ui 11.0.1 → 11.1.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_currency/_currency.jsx +7 -2
- data/app/pb_kits/playbook/pb_currency/currency.rb +8 -0
- data/app/pb_kits/playbook/pb_currency/currency.test.js +28 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals.html.erb +24 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals.jsx +38 -0
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +14 -60
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +0 -2
- data/lib/playbook/version.rb +2 -2
- metadata +4 -6
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx +0 -153
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.md +0 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.jsx +0 -130
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.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: f3c49612b5ff10431ef8ef79803f630de5aafe8dfcdfea74dc234cfba6920af1
|
4
|
+
data.tar.gz: e1199ebbc2ec5ecd70229ddef6500a1ebb9a0a31d0e25623d63a0e46034f36c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fe817795f69f7ab21303aa4f0f0f2a72378df01785421a49984bf4058e7253b2901747607c66ad49c8dcd20153fa746d717a67cfaf572fabd96e3910f2708ab
|
7
|
+
data.tar.gz: e6598e368c84ef4c8473470bcb756ca2313fccad7d3d8fde22c5df5013773b9e4a4e449daf0f2a25f323f98107f6a46073cb6f0c9372ff644f1e77b409c0959d
|
@@ -18,6 +18,7 @@ type CurrencyProps = {
|
|
18
18
|
className?: string,
|
19
19
|
dark?: boolean,
|
20
20
|
data?: object,
|
21
|
+
decimals?: 'default' | 'matching',
|
21
22
|
emphasized?: boolean,
|
22
23
|
id?: string,
|
23
24
|
label?: string,
|
@@ -40,6 +41,7 @@ const Currency = (props: CurrencyProps) => {
|
|
40
41
|
aria = {},
|
41
42
|
amount,
|
42
43
|
data = {},
|
44
|
+
decimals = 'default',
|
43
45
|
emphasized = true,
|
44
46
|
id,
|
45
47
|
unit,
|
@@ -85,9 +87,12 @@ const Currency = (props: CurrencyProps) => {
|
|
85
87
|
return isAmount ? num.slice(0, -1) : isUnit ? num.slice(-1) : ''
|
86
88
|
}
|
87
89
|
|
88
|
-
const
|
90
|
+
const getMatchingDecimalAmount = decimals === "matching" ? amount : whole,
|
91
|
+
getMatchingDecimalValue = decimals === "matching" ? '' : `.${decimal}`
|
92
|
+
|
93
|
+
const getAmount = abbreviate ? getAbbreviatedValue('amount') : getMatchingDecimalAmount,
|
89
94
|
getAbbreviation = abbreviate ? getAbbreviatedValue('unit') : null,
|
90
|
-
getDecimalValue = abbreviate ? '' :
|
95
|
+
getDecimalValue = abbreviate ? '' : getMatchingDecimalValue
|
91
96
|
|
92
97
|
return (
|
93
98
|
<div
|
@@ -36,6 +36,10 @@ module Playbook
|
|
36
36
|
prop :abbreviate, type: Playbook::Props::Boolean,
|
37
37
|
default: false
|
38
38
|
|
39
|
+
prop :decimals, type: Playbook::Props::Enum,
|
40
|
+
values: %w[default matching],
|
41
|
+
default: "default"
|
42
|
+
|
39
43
|
def classname
|
40
44
|
generate_classname("pb_currency_kit", align, size, dark_class)
|
41
45
|
end
|
@@ -84,6 +88,8 @@ module Playbook
|
|
84
88
|
private
|
85
89
|
|
86
90
|
def whole_value
|
91
|
+
return amount if decimals == "matching"
|
92
|
+
|
87
93
|
amount.split(".").first.to_s
|
88
94
|
end
|
89
95
|
|
@@ -94,6 +100,8 @@ module Playbook
|
|
94
100
|
end
|
95
101
|
|
96
102
|
def units_element
|
103
|
+
return "" if decimals == "matching" && !abbreviate && !unit
|
104
|
+
|
97
105
|
_, decimal_part = amount.split(".")
|
98
106
|
if unit.nil? && abbreviate == false
|
99
107
|
decimal_part.nil? ? ".00" : ".#{decimal_part}"
|
@@ -33,3 +33,31 @@ test('abbreviate prop returns proper abbreviated amount', () => {
|
|
33
33
|
expect(screen.getByTestId('test-billions')).toHaveTextContent('$3.2B')
|
34
34
|
expect(screen.getByTestId('test-trillions')).toHaveTextContent('$3.2T')
|
35
35
|
})
|
36
|
+
|
37
|
+
test('decimals matching prop returns decimals as title text', () => {
|
38
|
+
render(
|
39
|
+
<Currency
|
40
|
+
amount="320.20"
|
41
|
+
data={{ testid: 'test-decimals-matching' }}
|
42
|
+
decimals='matching'
|
43
|
+
/>
|
44
|
+
)
|
45
|
+
|
46
|
+
const currencyKit = screen.getByTestId('test-decimals-matching')
|
47
|
+
expect(currencyKit.querySelector('.pb_currency_value')).toHaveTextContent('320.20')
|
48
|
+
expect(currencyKit.querySelector('.unit')).toHaveTextContent('')
|
49
|
+
})
|
50
|
+
|
51
|
+
test('decimals default prop returns decimals as body text', () => {
|
52
|
+
render(
|
53
|
+
<Currency
|
54
|
+
amount="320.20"
|
55
|
+
data={{ testid: 'test-decimals-default' }}
|
56
|
+
decimals='default'
|
57
|
+
/>
|
58
|
+
)
|
59
|
+
|
60
|
+
const currencyKit = screen.getByTestId('test-decimals-default')
|
61
|
+
expect(currencyKit.querySelector('.pb_currency_value')).toHaveTextContent('320')
|
62
|
+
expect(currencyKit.querySelector('.unit')).toHaveTextContent('.20')
|
63
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%= pb_rails("currency", props: {
|
2
|
+
amount: "372.12",
|
3
|
+
decimals: "matching",
|
4
|
+
label: "Small",
|
5
|
+
margin_bottom: "md",
|
6
|
+
size: "sm",
|
7
|
+
unit: "/day",
|
8
|
+
}) %>
|
9
|
+
|
10
|
+
<%= pb_rails("currency", props: {
|
11
|
+
amount: "30,327.43",
|
12
|
+
decimals: "matching",
|
13
|
+
label: "Medium",
|
14
|
+
margin_bottom: "md",
|
15
|
+
size: "md",
|
16
|
+
symbol: "€",
|
17
|
+
}) %>
|
18
|
+
|
19
|
+
<%= pb_rails("currency", props: {
|
20
|
+
amount: "621,953.99",
|
21
|
+
decimals: "matching",
|
22
|
+
label: "Large",
|
23
|
+
size: "lg",
|
24
|
+
}) %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Currency from '../_currency'
|
4
|
+
|
5
|
+
const CurrencyMatchingDecimals = (props) => {
|
6
|
+
return (
|
7
|
+
<>
|
8
|
+
<Currency
|
9
|
+
amount="372.12"
|
10
|
+
decimals="matching"
|
11
|
+
label="Small"
|
12
|
+
marginBottom="md"
|
13
|
+
size="sm"
|
14
|
+
unit="/day"
|
15
|
+
{...props}
|
16
|
+
/>
|
17
|
+
<Currency
|
18
|
+
amount="30,327.43"
|
19
|
+
decimals="matching"
|
20
|
+
label="Medium"
|
21
|
+
marginBottom="md"
|
22
|
+
size="md"
|
23
|
+
symbol="€"
|
24
|
+
{...props}
|
25
|
+
/>
|
26
|
+
<Currency
|
27
|
+
amount="621,953.99"
|
28
|
+
decimals="matching"
|
29
|
+
label="Large"
|
30
|
+
size="lg"
|
31
|
+
{...props}
|
32
|
+
/>
|
33
|
+
</>
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
export default CurrencyMatchingDecimals
|
38
|
+
|
@@ -6,6 +6,7 @@ examples:
|
|
6
6
|
- currency_alignment: Alignment
|
7
7
|
- currency_no_symbol: No Symbol
|
8
8
|
- currency_abbreviated: Abbreviate Larger Amounts
|
9
|
+
- currency_matching_decimals: Matching Decimals
|
9
10
|
|
10
11
|
react:
|
11
12
|
- currency_variants: Variants
|
@@ -13,3 +14,4 @@ examples:
|
|
13
14
|
- currency_alignment: Alignment
|
14
15
|
- currency_no_symbol: No Symbol
|
15
16
|
- currency_abbreviated: Abbreviate Larger Amounts
|
17
|
+
- currency_matching_decimals: Matching Decimals
|
@@ -3,3 +3,4 @@ export { default as CurrencySize } from './_currency_size.jsx'
|
|
3
3
|
export { default as CurrencyAlignment } from './_currency_alignment.jsx'
|
4
4
|
export { default as CurrencyNoSymbol } from './_currency_no_symbol.jsx'
|
5
5
|
export { default as CurrencyAbbreviated } from './_currency_abbreviated.jsx'
|
6
|
+
export { default as CurrencyMatchingDecimals } from './_currency_matching_decimals.jsx'
|
@@ -1,5 +1,3 @@
|
|
1
|
-
/* eslint-disable react/jsx-handler-names */
|
2
|
-
/* eslint-disable react/no-multi-comp */
|
3
1
|
/* @flow */
|
4
2
|
|
5
3
|
import React, { useState } from 'react'
|
@@ -9,18 +7,13 @@ import Modal from 'react-modal'
|
|
9
7
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
10
8
|
import { globalProps } from '../utilities/globalProps'
|
11
9
|
|
12
|
-
import Body from '../pb_body/_body'
|
13
10
|
import Button from '../pb_button/_button'
|
14
11
|
import DialogHeader from './child_kits/_dialog_header'
|
15
12
|
import DialogFooter from './child_kits/_dialog_footer'
|
16
13
|
import DialogBody from './child_kits/_dialog_body'
|
17
|
-
import Flex from '../pb_flex/_flex'
|
18
|
-
import IconCircle from '../pb_icon_circle/_icon_circle'
|
19
|
-
import Title from '../pb_title/_title'
|
20
14
|
import { DialogContext } from './_dialog_context'
|
21
15
|
|
22
16
|
type DialogProps = {
|
23
|
-
alertStyle?: "link" | "single" | "stacked" | "default",
|
24
17
|
aria?: object,
|
25
18
|
cancelButton?: string,
|
26
19
|
children: array<React.ReactNode> | React.ReactNode | string,
|
@@ -38,7 +31,6 @@ type DialogProps = {
|
|
38
31
|
portalClassName?: string,
|
39
32
|
shouldCloseOnOverlayClick: boolean,
|
40
33
|
size?: "sm" | "md" | "lg" | "content",
|
41
|
-
status?: "info" | "caution" | "delete" | "error" | "success",
|
42
34
|
text?: string,
|
43
35
|
title?: string,
|
44
36
|
trigger?: string
|
@@ -46,7 +38,6 @@ type DialogProps = {
|
|
46
38
|
|
47
39
|
const Dialog = (props: DialogProps) => {
|
48
40
|
const {
|
49
|
-
alertStyle = "default",
|
50
41
|
aria = {},
|
51
42
|
cancelButton,
|
52
43
|
confirmButton,
|
@@ -62,7 +53,6 @@ const Dialog = (props: DialogProps) => {
|
|
62
53
|
onClose = () => {},
|
63
54
|
portalClassName,
|
64
55
|
shouldCloseOnOverlayClick = true,
|
65
|
-
status,
|
66
56
|
text,
|
67
57
|
title,
|
68
58
|
trigger,
|
@@ -88,15 +78,15 @@ const Dialog = (props: DialogProps) => {
|
|
88
78
|
className
|
89
79
|
)
|
90
80
|
|
91
|
-
const [triggerOpened, setTriggerOpened] = useState(false),
|
92
|
-
modalIsOpened = trigger ? triggerOpened : opened
|
93
|
-
|
94
81
|
const api = {
|
95
82
|
onClose: trigger ? function(){
|
96
83
|
setTriggerOpened(false)
|
97
84
|
} : onClose,
|
98
85
|
}
|
99
86
|
|
87
|
+
const [triggerOpened, setTriggerOpened] = useState(false),
|
88
|
+
modalIsOpened = trigger ? triggerOpened : opened
|
89
|
+
|
100
90
|
if (trigger) {
|
101
91
|
const modalTrigger = document.querySelector(trigger)
|
102
92
|
modalTrigger.addEventListener('click', () => {
|
@@ -107,29 +97,6 @@ const Dialog = (props: DialogProps) => {
|
|
107
97
|
}, { once: true })
|
108
98
|
}
|
109
99
|
|
110
|
-
const sweetAlertStatus = {
|
111
|
-
info: {
|
112
|
-
icon: "exclamation-circle",
|
113
|
-
variant: "default",
|
114
|
-
},
|
115
|
-
caution: {
|
116
|
-
icon: "triangle-warning",
|
117
|
-
variant: "yellow",
|
118
|
-
},
|
119
|
-
delete: {
|
120
|
-
icon: "trash",
|
121
|
-
variant: "red",
|
122
|
-
},
|
123
|
-
error: {
|
124
|
-
icon: "times-circle",
|
125
|
-
variant: "red",
|
126
|
-
},
|
127
|
-
success: {
|
128
|
-
icon: "check-circle",
|
129
|
-
variant: "green",
|
130
|
-
},
|
131
|
-
}
|
132
|
-
|
133
100
|
return (
|
134
101
|
<DialogContext.Provider value={api}>
|
135
102
|
<div
|
@@ -138,7 +105,6 @@ const Dialog = (props: DialogProps) => {
|
|
138
105
|
className={classes}
|
139
106
|
>
|
140
107
|
<Modal
|
141
|
-
alertStyle={alertStyle}
|
142
108
|
ariaHideApp={false}
|
143
109
|
className={dialogClassNames}
|
144
110
|
closeTimeoutMS={200}
|
@@ -149,28 +115,14 @@ const Dialog = (props: DialogProps) => {
|
|
149
115
|
overlayClassName={overlayClassNames}
|
150
116
|
portalClassName={portalClassName}
|
151
117
|
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
152
|
-
status={status}
|
153
118
|
>
|
154
|
-
<
|
155
|
-
<
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
variant={sweetAlertStatus[status].variant}
|
162
|
-
/>
|
163
|
-
</If>
|
164
|
-
<Title marginY='sm'
|
165
|
-
size={3}
|
166
|
-
>
|
167
|
-
{title}
|
168
|
-
</Title>
|
169
|
-
<Body marginY='xs'
|
170
|
-
text={text}
|
171
|
-
/>
|
172
|
-
</Flex>
|
173
|
-
</Dialog.Body>
|
119
|
+
<If condition={title}>
|
120
|
+
<Dialog.Header>{title}</Dialog.Header>
|
121
|
+
</If>
|
122
|
+
<If condition={text}>
|
123
|
+
<Dialog.Body>{text}</Dialog.Body>
|
124
|
+
</If>
|
125
|
+
|
174
126
|
<If condition={cancelButton && confirmButton}>
|
175
127
|
<Dialog.Footer>
|
176
128
|
<Button
|
@@ -179,14 +131,16 @@ const Dialog = (props: DialogProps) => {
|
|
179
131
|
>
|
180
132
|
{confirmButton}
|
181
133
|
</Button>
|
182
|
-
<Button
|
134
|
+
<Button
|
135
|
+
id="cancel-button"
|
183
136
|
onClick={onCancel}
|
184
|
-
variant=
|
137
|
+
variant="link"
|
185
138
|
>
|
186
139
|
{cancelButton}
|
187
140
|
</Button>
|
188
141
|
</Dialog.Footer>
|
189
142
|
</If>
|
143
|
+
|
190
144
|
{children}
|
191
145
|
</Modal>
|
192
146
|
</div>
|
@@ -4,5 +4,3 @@ export { default as DialogSizes } from './_dialog_sizes.jsx'
|
|
4
4
|
export { default as DialogScrollable } from './_dialog_scrollable.jsx'
|
5
5
|
export { default as DialogSeparators } from './_dialog_separators.jsx'
|
6
6
|
export { default as DialogShouldCloseOnOverlay } from './_dialog_should_close_on_overlay.jsx'
|
7
|
-
export { default as DialogStatus } from './_dialog_status.jsx'
|
8
|
-
export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.0
|
4
|
+
version: 11.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -604,6 +604,8 @@ files:
|
|
604
604
|
- app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.jsx
|
605
605
|
- app/pb_kits/playbook/pb_currency/docs/_currency_alignment.html.erb
|
606
606
|
- app/pb_kits/playbook/pb_currency/docs/_currency_alignment.jsx
|
607
|
+
- app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals.html.erb
|
608
|
+
- app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals.jsx
|
607
609
|
- app/pb_kits/playbook/pb_currency/docs/_currency_no_symbol.html.erb
|
608
610
|
- app/pb_kits/playbook/pb_currency/docs/_currency_no_symbol.jsx
|
609
611
|
- app/pb_kits/playbook/pb_currency/docs/_currency_size.html.erb
|
@@ -800,10 +802,6 @@ files:
|
|
800
802
|
- app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.jsx
|
801
803
|
- app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.md
|
802
804
|
- app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx
|
803
|
-
- app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx
|
804
|
-
- app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.md
|
805
|
-
- app/pb_kits/playbook/pb_dialog/docs/_dialog_status.jsx
|
806
|
-
- app/pb_kits/playbook/pb_dialog/docs/_dialog_status.md
|
807
805
|
- app/pb_kits/playbook/pb_dialog/docs/example.yml
|
808
806
|
- app/pb_kits/playbook/pb_dialog/docs/index.js
|
809
807
|
- app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx
|
@@ -1,153 +0,0 @@
|
|
1
|
-
/* eslint-disable react/jsx-handler-names */
|
2
|
-
|
3
|
-
import React, { useState } from "react"
|
4
|
-
import { Button, Dialog, Flex, FlexItem, SectionSeparator } from "../.."
|
5
|
-
|
6
|
-
const useDialog = (visible = false) => {
|
7
|
-
const [opened, setOpened] = useState(visible)
|
8
|
-
const toggle = () => setOpened(!opened)
|
9
|
-
return [opened, toggle]
|
10
|
-
}
|
11
|
-
|
12
|
-
const DialogStackedAlert = () => {
|
13
|
-
const [singleButtonOpen, toggleSingleButtonOpen] = useDialog()
|
14
|
-
const [stackedButtonOpen, toggleStackedButtonOpen] = useDialog()
|
15
|
-
const [singleLinkButtonOpen, toggleSingleLinkButtonOpen] = useDialog()
|
16
|
-
const [twoLinkButtonOpen, toggleTwoLinkButtonOpen] = useDialog()
|
17
|
-
|
18
|
-
|
19
|
-
const dialogs = [
|
20
|
-
{
|
21
|
-
status: "info",
|
22
|
-
text: "Text explaining why there is an alert",
|
23
|
-
title: "Are you sure?",
|
24
|
-
toggle: toggleSingleButtonOpen,
|
25
|
-
visible: singleButtonOpen,
|
26
|
-
confirmedButton:"Ok, Thanks",
|
27
|
-
},
|
28
|
-
{
|
29
|
-
status: "error",
|
30
|
-
text: "Text explaining the error",
|
31
|
-
title: "Error Message",
|
32
|
-
confirmedButton:"Yes, Action",
|
33
|
-
cancelledButton: "Ok, Cancel",
|
34
|
-
toggle: toggleStackedButtonOpen,
|
35
|
-
visible: stackedButtonOpen,
|
36
|
-
},
|
37
|
-
{
|
38
|
-
status: "caution",
|
39
|
-
text: "This is the action you will be taking",
|
40
|
-
title: "Are you sure?",
|
41
|
-
toggle: toggleSingleLinkButtonOpen,
|
42
|
-
visible: singleLinkButtonOpen,
|
43
|
-
linkConfirmedButton:"Ok, Thanks!"
|
44
|
-
},
|
45
|
-
{
|
46
|
-
status: "success",
|
47
|
-
text: "Text explaining what is successful",
|
48
|
-
title: "Success",
|
49
|
-
toggle: toggleTwoLinkButtonOpen,
|
50
|
-
visible: twoLinkButtonOpen,
|
51
|
-
linkConfirmedButton:"Ok",
|
52
|
-
linkCancelledButton: "Cancel"
|
53
|
-
}
|
54
|
-
]
|
55
|
-
|
56
|
-
return (
|
57
|
-
<div>
|
58
|
-
<Flex>
|
59
|
-
<Button
|
60
|
-
marginX="md"
|
61
|
-
onClick={toggleSingleButtonOpen}
|
62
|
-
>
|
63
|
-
{"1 Button Information Status"}
|
64
|
-
</Button>
|
65
|
-
<Button
|
66
|
-
marginX="md"
|
67
|
-
onClick={toggleStackedButtonOpen}
|
68
|
-
>
|
69
|
-
{"2 Button Error Status"}
|
70
|
-
</Button>
|
71
|
-
<Button
|
72
|
-
marginX="md"
|
73
|
-
onClick={toggleSingleLinkButtonOpen}
|
74
|
-
>
|
75
|
-
{"1 Link Button Caution"}
|
76
|
-
</Button>
|
77
|
-
<Button
|
78
|
-
marginX="md"
|
79
|
-
onClick={toggleTwoLinkButtonOpen}
|
80
|
-
>
|
81
|
-
{"2 Link Button Success"}
|
82
|
-
</Button>
|
83
|
-
</Flex>
|
84
|
-
<Flex>
|
85
|
-
{dialogs.map((dialog) => (
|
86
|
-
<Dialog
|
87
|
-
alertStyle={dialog.alertStyle}
|
88
|
-
key={dialog.status}
|
89
|
-
onClose={dialog.toggle}
|
90
|
-
opened={dialog.visible}
|
91
|
-
size="sm"
|
92
|
-
status={dialog.status}
|
93
|
-
text={dialog.text}
|
94
|
-
title={dialog.title}
|
95
|
-
>
|
96
|
-
<If condition={dialog.cancelledButton || dialog.confirmedButton}>
|
97
|
-
<Dialog.Footer>
|
98
|
-
<Button
|
99
|
-
fullWidth
|
100
|
-
onClick={dialog.toggle}
|
101
|
-
>
|
102
|
-
{dialog.confirmedButton}
|
103
|
-
</Button>
|
104
|
-
</Dialog.Footer>
|
105
|
-
<If condition={dialog.cancelledButton}>
|
106
|
-
<Dialog.Footer paddingTop="none">
|
107
|
-
<Button
|
108
|
-
fullWidth
|
109
|
-
onClick={dialog.toggle}
|
110
|
-
variant="secondary"
|
111
|
-
>
|
112
|
-
{dialog.cancelledButton}
|
113
|
-
</Button>
|
114
|
-
</Dialog.Footer>
|
115
|
-
</If>
|
116
|
-
</If>
|
117
|
-
<If condition={dialog.linkCancelledButton || dialog.linkConfirmedButton} >
|
118
|
-
<SectionSeparator />
|
119
|
-
<Flex
|
120
|
-
inline="flex-container"
|
121
|
-
vertical="stretch"
|
122
|
-
>
|
123
|
-
<FlexItem flex={1} >
|
124
|
-
<Button
|
125
|
-
fullWidth
|
126
|
-
onClick={dialog.toggle}
|
127
|
-
variant="link"
|
128
|
-
>
|
129
|
-
{dialog.linkConfirmedButton}
|
130
|
-
</Button>
|
131
|
-
</FlexItem>
|
132
|
-
<If condition={dialog.linkCancelledButton}>
|
133
|
-
<SectionSeparator orientation="vertical"/>
|
134
|
-
<FlexItem flex={1}>
|
135
|
-
<Button
|
136
|
-
fullWidth
|
137
|
-
onClick={dialog.toggle}
|
138
|
-
variant="link"
|
139
|
-
>
|
140
|
-
{dialog.linkCancelledButton}
|
141
|
-
</Button>
|
142
|
-
</FlexItem>
|
143
|
-
</If>
|
144
|
-
</Flex>
|
145
|
-
</If>
|
146
|
-
</Dialog>
|
147
|
-
))}
|
148
|
-
</Flex>
|
149
|
-
</div>
|
150
|
-
)
|
151
|
-
}
|
152
|
-
|
153
|
-
export default DialogStackedAlert
|
@@ -1 +0,0 @@
|
|
1
|
-
This is designed to show you how the buttons can stack with different alert styles. It also has a link style for the buttons for the mobile views.
|
@@ -1,130 +0,0 @@
|
|
1
|
-
/* eslint-disable react/jsx-handler-names */
|
2
|
-
/* @flow */
|
3
|
-
|
4
|
-
import React, { useState } from "react"
|
5
|
-
import { Button, Dialog, Flex } from "../.."
|
6
|
-
|
7
|
-
const useDialog = (visible = false) => {
|
8
|
-
const [opened, setOpened] = useState(visible)
|
9
|
-
const toggle = () => setOpened(!opened)
|
10
|
-
return [opened, toggle]
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
const DialogStatus = () => {
|
15
|
-
const [infoAlertOpened, toggleInfoAlert] = useDialog()
|
16
|
-
const [cautionAlertOpened, toggleCautionAlert] = useDialog()
|
17
|
-
const [successAlertOpened, toggleSuccessAlert] = useDialog()
|
18
|
-
const [errorAlertOpened, toggleErrorAlert] = useDialog()
|
19
|
-
const [deleteAlertOpened, toggleDeleteAlert] = useDialog()
|
20
|
-
|
21
|
-
const dialogs = [
|
22
|
-
{
|
23
|
-
status: "info",
|
24
|
-
text: "Text explaining why there is an alert",
|
25
|
-
title: "Are you Sure?",
|
26
|
-
toggle: toggleInfoAlert,
|
27
|
-
visible: infoAlertOpened,
|
28
|
-
buttonOneText:"No, Cancel",
|
29
|
-
buttonTwoText: "Yes, Action"
|
30
|
-
},
|
31
|
-
{
|
32
|
-
status: "caution",
|
33
|
-
text: "This is the action you will be taking",
|
34
|
-
title: "Are you Sure?",
|
35
|
-
toggle: toggleCautionAlert,
|
36
|
-
visible: cautionAlertOpened,
|
37
|
-
buttonOneText:"No, Cancel",
|
38
|
-
buttonTwoText: "Yes, Action"
|
39
|
-
},
|
40
|
-
{
|
41
|
-
status: "delete",
|
42
|
-
text: "You are about to delete ...",
|
43
|
-
title: "Delete",
|
44
|
-
toggle: toggleDeleteAlert,
|
45
|
-
visible: deleteAlertOpened,
|
46
|
-
buttonOneText:"No, Cancel",
|
47
|
-
buttonTwoText: "Yes, Delete"
|
48
|
-
},
|
49
|
-
{
|
50
|
-
status: "error",
|
51
|
-
text: "Text explaining the error",
|
52
|
-
title: "Error Message",
|
53
|
-
toggle: toggleErrorAlert,
|
54
|
-
visible: errorAlertOpened,
|
55
|
-
buttonOneText:"No, Cancel",
|
56
|
-
buttonTwoText: "Ok, Thanks"
|
57
|
-
},
|
58
|
-
{
|
59
|
-
status: "success",
|
60
|
-
text: "Text explaining what is successful",
|
61
|
-
title: "Success!",
|
62
|
-
toggle: toggleSuccessAlert,
|
63
|
-
visible: successAlertOpened,
|
64
|
-
buttonOneText:"No, Cancel",
|
65
|
-
buttonTwoText: "Ok, Thanks"
|
66
|
-
},
|
67
|
-
]
|
68
|
-
|
69
|
-
return (
|
70
|
-
<div>
|
71
|
-
<Flex>
|
72
|
-
<Button
|
73
|
-
marginX="md"
|
74
|
-
onClick={toggleInfoAlert}
|
75
|
-
>
|
76
|
-
{"Information Status"}
|
77
|
-
</Button>
|
78
|
-
<Button
|
79
|
-
marginX="md"
|
80
|
-
onClick={toggleCautionAlert}
|
81
|
-
>
|
82
|
-
{"Caution Status"}
|
83
|
-
</Button>
|
84
|
-
<Button
|
85
|
-
marginX="md"
|
86
|
-
onClick={toggleSuccessAlert}
|
87
|
-
>
|
88
|
-
{"Success Status"}
|
89
|
-
</Button>
|
90
|
-
<Button onClick={toggleErrorAlert}>
|
91
|
-
{"Error Status"}
|
92
|
-
</Button>
|
93
|
-
<Button
|
94
|
-
marginX="md"
|
95
|
-
onClick={toggleDeleteAlert}
|
96
|
-
>
|
97
|
-
{"Delete Status"}
|
98
|
-
</Button>
|
99
|
-
</Flex>
|
100
|
-
<Flex>
|
101
|
-
{dialogs.map((dialog) => (
|
102
|
-
<Dialog
|
103
|
-
key={dialog.status}
|
104
|
-
onClose={dialog.toggle}
|
105
|
-
opened={dialog.visible}
|
106
|
-
status={dialog.status}
|
107
|
-
text={dialog.text}
|
108
|
-
title={dialog.title}
|
109
|
-
>
|
110
|
-
<Dialog.Footer>
|
111
|
-
<Button
|
112
|
-
onClick={dialog.toggle}
|
113
|
-
variant="secondary"
|
114
|
-
>
|
115
|
-
{dialog.buttonOneText}
|
116
|
-
</Button>
|
117
|
-
<Button
|
118
|
-
onClick={dialog.toggle}
|
119
|
-
>
|
120
|
-
{dialog.buttonTwoText}
|
121
|
-
</Button>
|
122
|
-
</Dialog.Footer>
|
123
|
-
</Dialog>
|
124
|
-
))}
|
125
|
-
</Flex>
|
126
|
-
</div>
|
127
|
-
)
|
128
|
-
}
|
129
|
-
|
130
|
-
export default DialogStatus
|
@@ -1 +0,0 @@
|
|
1
|
-
This shows the different alert statuses that can be used for dialog boxes. These all have two buttons which is a default
|