Skip to content

Commit f7c219e

Browse files
committed
Merge branch 'rarrojolopez-fix' of https://github.com/dxc-technology/halstack-react into rarrojolopez-fix
2 parents 19ad0c4 + 3fa9e5c commit f7c219e

File tree

10 files changed

+72
-57
lines changed

10 files changed

+72
-57
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Halstack React CDK
1+
# Halstack React CDK
22

33
Halstack React CDK is a npm library of reusable React components, made with the purpose of helping React developers with the task of implementing User Interfaces following the DXC Design Guidelines.
44

docs/src/pages/overview/Overview.jsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,21 @@ function CustomThemes() {
102102
</p>
103103

104104
<p>
105-
You will need to create an object with your colors preferences. The
106-
variables are documented in each component's documentation. You will
107-
also need to import ThemeProvider, and use it to wrap the component and
108-
pass your colors object as the theme property.
105+
You will need to create an object with your colors preferences. In this
106+
object, you will have as much objects as components you want to
107+
customize, using the next structure:
108+
<SyntaxHighlighter language="javascript" style={docco}>
109+
{`componentName: {
110+
themeInput: "value",
111+
}`}
112+
</SyntaxHighlighter>
113+
The theme inputs for each component are documented in the themes
114+
guidelines.
115+
</p>
116+
117+
<p>
118+
You will also need to import ThemeProvider, and use it to wrap the
119+
component and pass your colors object as the theme property.
109120
</p>
110121

111122
<p>This is an example that includes the necessary code:</p>

lib/src/common/variables.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ export const componentTokens = {
277277
disabledUnselectedFontColor: globalTokens.lighterBlack,
278278
disabledSelectedFontColor: globalTokens.white,
279279
},
280+
upload: {
281+
fontColor: globalTokens.darkGrey,
282+
shadowColor: globalTokens.lightWhite,
283+
backgroundDragColor: globalTokens.lightWhite,
284+
accentColor: globalTokens.lightGrey,
285+
fileHoverColor: globalTokens.darkWhite,
286+
scrollBarThumbColor: globalTokens.darkGrey,
287+
scrollBarTrackColor: globalTokens.lightGrey,
288+
errorColor: globalTokens.red,
289+
},
280290
wizard: {
281291
selectedBackgroundColor: globalTokens.purple,
282292
selectedFont: globalTokens.white,

lib/src/toggle/Toggle.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* eslint-disable no-else-return */
2-
import React, { useContext } from "react";
2+
import React from "react";
33
import { ToggleButton } from "@material-ui/lab";
44
import PropTypes from "prop-types";
55
import styled, { ThemeProvider } from "styled-components";
66
import "../common/OpenSans.css";
7-
import { globalTokens, spaces } from "../common/variables.js";
87
import { getMargin } from "../common/utils.js";
9-
import ThemeContext from "../ThemeContext.js";
8+
import useTheme from "../useTheme.js";
109

1110
const DxcToggle = ({
1211
label = "",
@@ -21,7 +20,7 @@ const DxcToggle = ({
2120
margin,
2221
size = "fitContent",
2322
}) => {
24-
const colorsTheme = useContext(ThemeContext) || globalTokens;
23+
const colorsTheme = useTheme();
2524

2625
const handlerToggleClick = () => {
2726
if (!disabled && typeof onClick === "function") {

lib/src/upload/buttons-upload/ButtonsUpload.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/* eslint-disable no-undef */
2-
import React, { useContext } from "react";
2+
import React from "react";
33
import PropTypes from "prop-types";
44
import styled, { ThemeProvider } from "styled-components";
55
import "../../common/OpenSans.css";
66
import Button from "../../button/Button";
77
import uploadIcon from "./upload-button.svg";
88
import dragAndDropIcon from "./drag-drop-icon.svg";
9-
import { globalTokens } from "../../common/variables.js";
10-
import ThemeContext from "../../ThemeContext.js";
9+
import useTheme from "../../useTheme.js";
1110

1211
const DxcButtonsUpload = ({ addFile, onUpload }) => {
13-
const colorsTheme = useContext(ThemeContext) || globalTokens;
12+
const colorsTheme = useTheme();
1413

1514
const selectFile = (e) => {
1615
const filesObject = e.target.files;
@@ -25,7 +24,7 @@ const DxcButtonsUpload = ({ addFile, onUpload }) => {
2524
};
2625

2726
return (
28-
<ThemeProvider theme={colorsTheme}>
27+
<ThemeProvider theme={colorsTheme.upload}>
2928
<DXCButtonsUpload>
3029
<DragAndDropLabel>
3130
<DragAndDropIcon />
@@ -58,7 +57,7 @@ const DragAndDropLabel = styled.div`
5857
align-items: center;
5958
font-style: italic;
6059
font-size: 12px;
61-
color: ${(props) => props.theme.darkGrey};
60+
color: ${(props) => props.theme.fontColor};
6261
margin-right: 50px;
6362
`;
6463

lib/src/upload/dragAndDropArea/DragAndDropArea.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* eslint-disable no-undef */
2-
import React, { useContext } from "react";
2+
import React from "react";
33
import styled, { ThemeProvider } from "styled-components";
44
import PropTypes from "prop-types";
55
import "../../common/OpenSans.css";
6-
import { globalTokens } from "../../common/variables.js";
6+
import {} from "../../common/variables.js";
77
import uploadFile from "./upload_file.svg";
88
import dropFile from "./upload_drop.svg";
99
import Button from "../../button/Button";
10-
import ThemeContext from "../../ThemeContext.js";
10+
import useTheme from "../../useTheme.js";
1111

1212
const DxcDragAndDropArea = ({ dashed = false, addFile }) => {
1313
const [dragging, setDragging] = React.useState(false);
14-
const colorsTheme = useContext(ThemeContext) || globalTokens;
14+
const colorsTheme = useTheme();
1515

1616
const text = "There are no files to upload";
1717
const description = "Drag and drop your files here or choose one from your computer";
@@ -60,7 +60,7 @@ const DxcDragAndDropArea = ({ dashed = false, addFile }) => {
6060
};
6161

6262
return (
63-
<ThemeProvider theme={colorsTheme}>
63+
<ThemeProvider theme={colorsTheme.upload}>
6464
<DXCDragAndDrop
6565
onDrop={handleDrop}
6666
onDragEnter={handleDragIn}
@@ -126,7 +126,7 @@ const DXCDragAndDropArea = styled.div`
126126
display: flex;
127127
justify-content: center;
128128
border-radius: 4px;
129-
box-shadow: 0px 3px 6px ${(props) => props.theme.black}29;
129+
box-shadow: 0px 3px 6px ${(props) => props.theme.shadowColor};
130130
`;
131131

132132
const DragAndDropContent = styled.div`
@@ -158,7 +158,7 @@ const DragAndDropTitle = styled.div`
158158
const DragAndDropDescription = styled.div`
159159
font-size: 16px;
160160
margin-bottom: 40px;
161-
color: ${(props) => props.theme.darkGrey};
161+
color: ${(props) => props.theme.fontColor};
162162
font-style: italic;
163163
`;
164164

@@ -212,7 +212,7 @@ const DragAndDropContentHover = styled.div`
212212
background-size: var(--dash-size) var(--border-weight), calc(var(--dash-size) + var(--gap-size)) var(--border-weight),
213213
var(--dash-size) var(--border-weight), var(--border-weight) var(--dash-size),
214214
var(--border-weight) calc(var(--dash-size) + var(--gap-size)), var(--border-weight) var(--dash-size);
215-
background-color: ${(props) => props.theme.black}0F;
215+
background-color: ${(props) => props.theme.backgroundDragColor};
216216
display: flex;
217217
flex-direction: column;
218218
justify-content: center;
@@ -231,7 +231,7 @@ const DragAndDropIconHover = styled.div`
231231
const DragAndDropTextHover = styled.div`
232232
font-size: 16px;
233233
margin-bottom: 20px;
234-
color: ${(props) => props.theme.darkGrey};
234+
color: ${(props) => props.theme.fontColor};
235235
font-style: italic;
236236
`;
237237

lib/src/upload/file-upload/FileToUpload.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/* eslint-disable react/require-default-props */
2-
import React, { useContext } from "react";
2+
import React from "react";
33
import PropTypes from "prop-types";
44
import "../../common/OpenSans.css";
55
import styled, { ThemeProvider } from "styled-components";
6-
import { globalTokens } from "../../common/variables.js";
76
import closeIcon from "./close.svg";
87
import defaultIcon from "./file-icon.svg";
98
import videoIcon from "./video-icon.svg";
109
import audioIcon from "./audio-icon.svg";
11-
import ThemeContext from "../../ThemeContext.js";
10+
import useTheme from "../../useTheme.js";
1211

1312
const DxcFileToUpload = ({ name = "", type = "", image, onDelete }) => {
1413
const icon = (type.includes("video") && videoIcon) || (type.includes("audio") && audioIcon) || defaultIcon;
1514
const hasImage = image && image.includes("image");
16-
const colorsTheme = useContext(ThemeContext) || globalTokens;
15+
const colorsTheme = useTheme();
1716

1817
return (
19-
<ThemeProvider theme={colorsTheme}>
18+
<ThemeProvider theme={colorsTheme.upload}>
2019
<DXCFileToUpload>
2120
<FileContent>
2221
{(hasImage && <FileImage src={image} />) || <FileImage src={icon} />}
@@ -46,14 +45,14 @@ const DXCFileToUpload = styled.div`
4645
flex-direction: column;
4746
padding-bottom: 25px;
4847
padding-top: 25px;
49-
border-bottom: 1px solid ${(props) => props.theme.lightGrey};
48+
border-bottom: 1px solid ${(props) => props.theme.accentColor};
5049
:hover {
5150
cursor: pointer;
52-
background: ${(props) => props.theme.darkWhite};
51+
background: ${(props) => props.theme.fileHoverColor};
5352
.delete-file {
5453
display: flex;
5554
margin-right: 30px;
56-
background: url('${closeIcon}') no-repeat padding-box;
55+
background: url("${closeIcon}") no-repeat padding-box;
5756
width: 30px;
5857
height: 30px;
5958
margin-top: 11px;
@@ -88,7 +87,7 @@ const FileInfo = styled.div`
8887
const FileType = styled.div`
8988
text-transform: uppercase;
9089
font-size: 12px;
91-
color: ${(props) => props.theme.black}99;
90+
color: ${(props) => props.theme.fontColor};
9291
`;
9392

9493
const DeleteFile = styled.div`

lib/src/upload/files-upload/FilesToUpload.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import React, { useContext } from "react";
1+
import React from "react";
22
import styled, { ThemeProvider } from "styled-components";
33
import "../../common/OpenSans.css";
44
import PropTypes from "prop-types";
55
import FileToUpload from "../file-upload/FileToUpload";
66
import ButtonsUpload from "../buttons-upload/ButtonsUpload";
7-
import { globalTokens } from "../../common/variables.js";
8-
import ThemeContext from "../../ThemeContext.js";
7+
import useTheme from "../../useTheme.js";
98

109
const DxcFilesToUpload = ({ filesToUpload, onUpload, addFile }) => {
11-
const colorsTheme = useContext(ThemeContext) || globalTokens;
10+
const colorsTheme = useTheme();
1211

1312
const handleDrag = (e) => {
1413
e.preventDefault();
@@ -37,7 +36,7 @@ const DxcFilesToUpload = ({ filesToUpload, onUpload, addFile }) => {
3736
};
3837

3938
return (
40-
<ThemeProvider theme={colorsTheme}>
39+
<ThemeProvider theme={colorsTheme.upload}>
4140
<DXCFilesToUpload
4241
onDrop={handleDrop}
4342
onDragEnter={handleDragIn}
@@ -73,7 +72,7 @@ const DXCFilesToUpload = styled.div`
7372
width: 100%;
7473
padding: 20px;
7574
border-radius: 4px 4px 0px 4px;
76-
box-shadow: 0px 0px 1px ${(props) => props.theme.black}29;
75+
box-shadow: 0px 0px 1px ${(props) => props.theme.shadowColor};
7776
`;
7877

7978
const FilesToUpload = styled.div`
@@ -85,11 +84,11 @@ const FilesToUpload = styled.div`
8584
}
8685
::-webkit-scrollbar-track {
8786
border-radius: 3px;
88-
background-color: ${(props) => props.theme.lightGrey};
87+
background-color: ${(props) => props.theme.scrollBarTrackColor};
8988
}
9089
::-webkit-scrollbar-thumb {
9190
border-radius: 3px;
92-
background-color: ${(props) => props.theme.darkGrey};
91+
background-color: ${(props) => props.theme.scrollBarThumbColor};
9392
}
9493
`;
9594

lib/src/upload/transaction/Transaction.jsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from "react";
1+
import React from "react";
22
import PropTypes from "prop-types";
33
import styled, { ThemeProvider } from "styled-components";
44
import "../../common/OpenSans.css";
@@ -14,11 +14,10 @@ import imageIconError from "./image-icon-err.svg";
1414
import videoIconError from "./video-icon-err.svg";
1515
import audioIconError from "./audio-icon-err.svg";
1616
import Spinner from "../../spinner/Spinner";
17-
import { globalTokens } from "../../common/variables.js";
18-
import ThemeContext from "../../ThemeContext.js";
17+
import useTheme from "../../useTheme.js";
1918

2019
const DxcTransaction = ({ name = "", type = "", status = "", message = "" }) => {
21-
const colorsTheme = useContext(ThemeContext) || globalTokens;
20+
const colorsTheme = useTheme();
2221
const icon =
2322
(status === "error" &&
2423
((type.includes("image") && imageIconError) ||
@@ -31,7 +30,7 @@ const DxcTransaction = ({ name = "", type = "", status = "", message = "" }) =>
3130
defaultIcon;
3231

3332
return (
34-
<ThemeProvider theme={colorsTheme}>
33+
<ThemeProvider theme={colorsTheme.upload}>
3534
<DXCTransaction status={status}>
3635
<FileImage src={icon} />
3736
{(status === "processing" && (
@@ -72,7 +71,7 @@ const DXCTransaction = styled.div`
7271
display: flex;
7372
flex-direction: row;
7473
margin-bottom: 16px;
75-
color: ${(props) => props.status === "error" && `${props.theme.red}`};
74+
color: ${(props) => props.status === "error" && `${props.theme.errorColor}`};
7675
overflow: hidden;
7776
white-space: nowrap;
7877
text-overflow: ellipsis;
@@ -87,7 +86,7 @@ const FileImage = styled.img`
8786
width: 24px;
8887
margin-right: 16px;
8988
svg {
90-
fill: ${(props) => (props.status === "error" && "#D0011B") || `${props.theme.lightGrey}`};
89+
fill: ${(props) => (props.status === "error" && "#D0011B") || `${props.theme.accentColor}`};
9190
}
9291
`;
9392

lib/src/upload/transactions/Transactions.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import React, { useContext } from "react";
1+
import React from "react";
22
import styled, { ThemeProvider } from "styled-components";
33
import "../../common/OpenSans.css";
44
import PropTypes from "prop-types";
55
import Transaction from "../transaction/Transaction";
6-
import { globalTokens } from "../../common/variables.js";
7-
import ThemeContext from "../../ThemeContext.js";
6+
import useTheme from "../../useTheme.js";
87

98
const DxcTransactions = ({ transactions }) => {
10-
const colorsTheme = useContext(ThemeContext) || globalTokens;
9+
const colorsTheme = useTheme();
1110

1211
return (
13-
<ThemeProvider theme={colorsTheme}>
12+
<ThemeProvider theme={colorsTheme.upload}>
1413
<DXCTransactions>
1514
<TransactionsText>
1615
<TransactionsTitle>Files uploaded</TransactionsTitle>
@@ -47,18 +46,18 @@ const DXCTransactions = styled.div`
4746
padding-top: 46px;
4847
padding-left: 65px;
4948
border-radius: 4px 0px 4px 4px;
50-
box-shadow: 0px 0px 1px ${(props) => props.theme.black}29;
49+
box-shadow: 0px 0px 1px ${(props) => props.theme.lightWhite};
5150
overflow: auto;
5251
::-webkit-scrollbar {
5352
width: 3px;
5453
}
5554
::-webkit-scrollbar-track {
5655
border-radius: 3px;
57-
background-color: ${(props) => props.theme.lightGrey};
56+
background-color: ${(props) => props.theme.scrollBarTrackColor};
5857
}
5958
::-webkit-scrollbar-thumb {
6059
border-radius: 3px;
61-
background-color: ${(props) => props.theme.darkGrey};
60+
background-color: ${(props) => props.theme.scrollBarThumbColor};
6261
}
6362
`;
6463

@@ -75,7 +74,7 @@ const TransactionsTitle = styled.span`
7574

7675
const TransactionsSubTitle = styled.span`
7776
font-size: 12px;
78-
color: ${(props) => props.theme.darkGrey};
77+
color: ${(props) => props.theme.fontColor};
7978
`;
8079

8180
const TransactionsNumber = styled.span`

0 commit comments

Comments
 (0)