Skip to content

Commit d4e17f7

Browse files
authored
Merge pull request #1504 from dxc-technology/gomezivann-dialog-review
Dialog review
2 parents fd47ea5 + a8c37fa commit d4e17f7

File tree

13 files changed

+795
-358
lines changed

13 files changed

+795
-358
lines changed

app/src/pages/Dialog.jsx

Lines changed: 120 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,144 @@
11
import React, { useState } from "react";
2-
import { DxcDialog, DxcButton } from "@dxc-technology/halstack-react";
2+
import {
3+
DxcDialog,
4+
DxcButton,
5+
DxcTextInput,
6+
DxcFlex,
7+
DxcHeading,
8+
DxcParagraph,
9+
DxcAlert,
10+
DxcTextarea,
11+
DxcSelect,
12+
DxcDateInput,
13+
DxcDropdown,
14+
} from "@dxc-technology/halstack-react";
15+
16+
const options = [
17+
{
18+
value: 1,
19+
label: "Android",
20+
},
21+
{
22+
value: 2,
23+
label: "Windows",
24+
},
25+
{
26+
value: 3,
27+
label: "IOS",
28+
},
29+
];
330

431
function App() {
532
const [isDialog1Visible, setIsDialog1Visible] = useState(false);
33+
const [nameValue, setNameValue] = useState("");
34+
const [descriptionValue, setDescriptionValue] = useState("");
35+
636
const [isDialog2Visible, setIsDialog2Visible] = useState(false);
7-
const [isDialog3Visible, setIsDialog3Visible] = useState(false);
37+
const [isVisible, changeIsVisible] = useState(false);
38+
const [isDisabled, changeIsDisabled] = useState(false);
39+
const handleDisabled = () => {
40+
changeIsDisabled((isDisabled) => !isDisabled);
41+
};
842

43+
const handleVisibility = () => {
44+
changeIsVisible((isVisible) => !isVisible);
45+
};
946
const onClickDialog1 = () => {
1047
setIsDialog1Visible(!isDialog1Visible);
11-
};
12-
const onClickDialog2 = () => {
13-
setIsDialog2Visible(!isDialog2Visible);
14-
};
15-
const onClickDialog3 = () => {
16-
setIsDialog3Visible(!isDialog3Visible);
48+
changeIsVisible(false);
49+
setNameValue("");
50+
setDescriptionValue("");
1751
};
1852

1953
return (
20-
<div>
21-
<DxcButton
22-
label="Dialog 1"
23-
onClick={onClickDialog1}
24-
margin="medium"
25-
></DxcButton>
54+
<DxcFlex gap="1.5rem">
55+
<DxcButton label="Example" onClick={onClickDialog1} />
2656
{isDialog1Visible && (
27-
<DxcDialog isCloseVisible={true} onCloseClick={onClickDialog1}>
28-
Close Icon
57+
<DxcDialog onCloseClick={onClickDialog1}>
58+
<DxcFlex direction="column" gap="2rem">
59+
<DxcHeading level={4} text="User form" />
60+
<DxcFlex direction="column" gap="1rem">
61+
{isVisible && (
62+
<DxcAlert
63+
type="error"
64+
inlineText="To be valid, you need to fill every field."
65+
size="fillParent"
66+
onClose={handleVisibility}
67+
/>
68+
)}
69+
<DxcDropdown label="Options" options={options} />
70+
<DxcTextInput
71+
label="Name"
72+
value={nameValue}
73+
onChange={({ value }) => {
74+
setNameValue(value);
75+
}}
76+
size="fillParent"
77+
disabled={isDisabled}
78+
tabIndex={-1}
79+
/>
80+
<DxcDateInput label="Start date" size="fillParent" />
81+
<DxcSelect
82+
label="Example select"
83+
options={options}
84+
size="fillParent"
85+
/>
86+
<DxcTextarea
87+
label="Description"
88+
value={descriptionValue}
89+
onChange={({ value }) => {
90+
setDescriptionValue(value);
91+
}}
92+
size="fillParent"
93+
disabled={isDisabled}
94+
/>
95+
</DxcFlex>
96+
<DxcFlex justifyContent="flex-end" gap="0.5rem">
97+
<DxcButton
98+
label="Disable fields"
99+
mode="text"
100+
onClick={handleDisabled}
101+
/>
102+
<DxcButton
103+
label="Cancel"
104+
mode="secondary"
105+
onClick={onClickDialog1}
106+
/>
107+
<DxcButton
108+
label="Save"
109+
onClick={() => {
110+
if (nameValue === "" || nameValue === "")
111+
changeIsVisible(true);
112+
else {
113+
changeIsVisible(false);
114+
setIsDialog1Visible(false);
115+
}
116+
}}
117+
/>
118+
</DxcFlex>
119+
</DxcFlex>
29120
</DxcDialog>
30121
)}
31-
32122
<DxcButton
33-
label="Dialog 2"
34-
onClick={onClickDialog2}
35-
margin="medium"
36-
></DxcButton>
123+
label="Empty"
124+
onClick={() => {
125+
setIsDialog2Visible((isVisible) => !isVisible);
126+
}}
127+
/>
37128
{isDialog2Visible && (
38129
<DxcDialog
39-
padding="xxlarge"
40-
onBackgroundClick={onClickDialog2}
41130
isCloseVisible={false}
131+
onCloseClick={() => {
132+
setIsDialog2Visible((isVisible) => !isVisible);
133+
}}
134+
onBackgroundClick={() => {
135+
setIsDialog2Visible((isVisible) => !isVisible);
136+
}}
42137
>
43-
Overlay close
44-
</DxcDialog>
45-
)}
46-
47-
<DxcButton
48-
label="Dialog 3"
49-
onClick={onClickDialog3}
50-
margin="medium"
51-
></DxcButton>
52-
{isDialog3Visible && (
53-
<DxcDialog padding="xxlarge" isCloseVisible={false}>
54-
<DxcButton
55-
label="Close"
56-
onClick={onClickDialog3}
57-
margin="small"
58-
></DxcButton>
138+
<DxcParagraph>Example text</DxcParagraph>
59139
</DxcDialog>
60140
)}
61-
</div>
141+
</DxcFlex>
62142
);
63143
}
64144

lib/src/common/variables.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,19 +455,16 @@ export const componentTokens = {
455455
closeIconHeight: "24px",
456456
closeIconTopPosition: "20px",
457457
closeIconRightPosition: "20px",
458-
closeIconBackgroundColor: "none",
458+
closeIconBackgroundColor: globalTokens.transparent,
459459
closeIconBorderColor: globalTokens.border_none,
460460
closeIconColor: globalTokens.hal_black,
461461
closeIconBorderThickness: globalTokens.border_width_0,
462462
closeIconBorderStyle: globalTokens.border_solid,
463-
closeIconBorderRadius: "0px",
463+
closeIconBorderRadius: "2px",
464464
boxShadowOffsetX: "0px",
465465
boxShadowOffsetY: "1px",
466466
boxShadowBlur: "3px",
467467
boxShadowColor: globalTokens.color_grey_a_300,
468-
fontFamily: globalTokens.type_sans,
469-
fontSize: globalTokens.type_scale_03,
470-
fontWeight: globalTokens.type_regular,
471468
},
472469
dropdown: {
473470
buttonBackgroundColor: globalTokens.hal_white,
@@ -1477,6 +1474,9 @@ export const defaultTranslatedComponentLabels = {
14771474
dateInput: {
14781475
invalidDateErrorMessage: "Invalid date.",
14791476
},
1477+
dialog: {
1478+
closeIconAriaLabel: "Close dialog",
1479+
},
14801480
fileInput: {
14811481
fileSizeGreaterThanErrorMessage: "File size must be greater than min size.",
14821482
fileSizeLessThanErrorMessage: "File size must be less than max size.",

0 commit comments

Comments
 (0)