Skip to content

Commit 0b673ae

Browse files
committed
Modified the structure of updates and label components
1 parent 44210a3 commit 0b673ae

File tree

15 files changed

+270
-248
lines changed

15 files changed

+270
-248
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ yarn-error.log*
2525
*storybook.log
2626
.storybook/
2727
/src/stories
28-
/src/components/UpdatesMenu/
28+
*.stories.js

src/Styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const fonts = {
1212
size: '16px',
1313
lineHeight: '24px',
1414
color: colors.darkGrey,
15-
fontWeight: 600
15+
fontWeight: 500
1616
},
1717
default: {
1818
size: '13px',

src/components/BasicMenus/MenuToggleButton.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { useState } from 'react';
55
import PropTypes from 'prop-types';
66

77
/**
8-
* Button component which displays a dropdown menu when toggled
8+
* Button component which displays a dropdown menu when toggled.
99
*
1010
* Props:
11-
* - label<String>: Text to be used for the button label
11+
* - label<String>: Text to be used for the button label.
1212
*
13-
* - menuComponent<Component>: Menu component to be displayed when button is toggled
13+
* - menuComponent<Component>: Menu component to be displayed when button is toggled.
1414
*
15-
* - icon<Component>: Optional prop for including an icon in the button label
15+
* - icon<Component>: Optional prop for including an icon in the button label.
1616
* Default: null
1717
*
18-
* - style<Object>: Optional prop for adding further inline styling
18+
* - style<Object>: Optional prop for adding further inline styling .
1919
* Default: {}
2020
*/
2121
export default function MenuToggleButton({label, menuComponent, icon, style}) {

src/components/Button/HRMButton.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {styled} from '@mui/system';
1+
import { styled } from '@mui/system';
22
import Button from '@mui/material/Button';
33
import PropTypes from 'prop-types';
44

@@ -12,13 +12,19 @@ import PropTypes from 'prop-types';
1212
*
1313
* - children<Any>: Text to be used for the button label.
1414
*
15-
* - style<Object>: Optional prop for adding further inline styling
15+
* - startIcon<Component>: Optional prop for including an icon on the left side of the button label.
16+
* Default: null
17+
*
18+
* - endIcon<Component>: Optional prop for including an icon on the right side of the button label.
19+
* Default: null
20+
*
21+
* - style<Object>: Optional prop for adding further inline styling.
1622
* Default: {}
1723
*
1824
* - enabled<Boolean>: Flag determining whether the button is enabled or disabled.
1925
* Default: true
2026
*/
21-
export default function HRMButton({mode, children, style, enabled}) {
27+
export default function HRMButton({mode, children, startIcon, endIcon, style, enabled}) {
2228
const primaryStyle = {
2329
textTransform: "none",
2430
backgroundColor: "#7F56D9",
@@ -93,17 +99,17 @@ export default function HRMButton({mode, children, style, enabled}) {
9399

94100
if (mode === "primary" || mode === "error") {
95101
return (
96-
<StyledButton variant="contained" disabled={!enabled} disableElevation>{children}</StyledButton>
102+
<StyledButton startIcon={startIcon} endIcon={endIcon} variant="contained" disabled={!enabled} disableElevation>{children}</StyledButton>
97103
);
98104
}
99105
else if (mode === "secondaryA" || mode === "secondaryB") {
100106
return (
101-
<StyledButton variant="outlined" disabled={!enabled}>{children}</StyledButton>
107+
<StyledButton startIcon={startIcon} endIcon={endIcon} variant="outlined" disabled={!enabled}>{children}</StyledButton>
102108
);
103109
}
104110
else {
105111
return (
106-
<StyledButton variant="text" disabled={!enabled}>{children}</StyledButton>
112+
<StyledButton startIcon={startIcon} endIcon={endIcon} variant="text" disabled={!enabled}>{children}</StyledButton>
107113
);
108114
}
109115
};
@@ -125,6 +131,8 @@ HRMButton.propTypes = {
125131

126132
//Default values for this component
127133
HRMButton.defaultProps = {
134+
startIcon: null,
135+
endIcon: null,
128136
style: {},
129137
enabled: true
130138
};
Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import HRMButton from './HRMButton';
2+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
3+
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
24

35
//Storybook display settings
46
export default {
@@ -14,39 +16,50 @@ export default {
1416
export const Primary = {
1517
args: {
1618
mode: 'primary',
17-
children: 'Button',
18-
enabled: true
19+
children: 'Button'
1920
}
2021
};
2122

2223
export const SecondaryA = {
2324
args: {
2425
mode: 'secondaryA',
25-
children: 'Button',
26-
enabled: true
26+
children: 'Button'
2727
}
2828
};
2929

3030
export const SecondaryB = {
3131
args: {
3232
mode: 'secondaryB',
33-
children: 'Button',
34-
enabled: true
33+
children: 'Button'
3534
}
3635
};
3736

3837
export const Tertiary = {
3938
args: {
4039
mode: 'tertiary',
41-
children: 'Button',
42-
enabled: true
40+
children: 'Button'
4341
}
4442
};
4543

4644
export const Error = {
4745
args: {
4846
mode: 'error',
49-
children: 'Button',
50-
enabled: true
47+
children: 'Button'
5148
}
5249
};
50+
51+
export const Previous = {
52+
args: {
53+
mode: 'secondaryB',
54+
children: 'Previous',
55+
startIcon: <ArrowBackIcon />
56+
}
57+
};
58+
59+
export const Next = {
60+
args: {
61+
mode: 'secondaryB',
62+
children: 'Next',
63+
endIcon: <ArrowForwardIcon />
64+
}
65+
};

src/components/Label/Label.jsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import Chip from '@mui/material/Chip';
2+
import { styled } from '@mui/system';
3+
import { colors, fonts } from '../../Styles';
4+
import PropTypes from 'prop-types';
5+
6+
/**
7+
* Label components for both HRM and Onboarding applications. Can be configured to be an orange,
8+
* gray, purple(brand), green(success), new, waiting or seen label using prop values.
9+
*
10+
* Props:
11+
* - mode<String>: Determines the type of the label.
12+
* Valid values: ['orange', 'gray', 'brand', 'success', 'new', 'waiting', 'seen']
13+
*
14+
* - label<String>: Text to be used for the label.
15+
*
16+
* - style<Object>: Optional prop for adding further inline styling.
17+
* Default: {}
18+
*/
19+
export default function Label({mode, label, style}) {
20+
//Label styles
21+
const StyledChip = styled(Chip)({...{
22+
backgroundColor: (mode === "orange") ? "#FEF6EE" :
23+
(mode === "gray") ? "#F9FAFB" :
24+
(mode === "brand") ? "#F9F5FF" :
25+
(mode === "success") ? "#ECFDF3" : "#FFFFFF",
26+
color: (mode === "orange") ? "#B42318" :
27+
(mode === "gray") ? "#475467" :
28+
(mode === "brand") ? colors.purple :
29+
(mode === "success") ? "#067647" : colors.darkGrey,
30+
border: (mode === "orange") ? "1px solid #F9DBAF" :
31+
(mode === "gray") ? "1px solid #EAECF0" :
32+
(mode === "brand") ? "1px solid #E9D7FE" :
33+
(mode === "success") ? "1px solid #ABEFC6" : "1px solid #D0D5DD",
34+
fontFamily: fonts.fontFamily,
35+
fontWeight: (mode === "new" || mode === "waiting" || mode === "seen") ?
36+
fonts.bold.fontWeight : fonts.default.fontWeight,
37+
fontSize: "12px",
38+
borderRadius: "4px"
39+
}, ...style});
40+
41+
//Colored dot styles if using a status label
42+
const coloredDot = <span style={{
43+
backgroundColor: (mode === "new") ? "#F79009" :
44+
(mode === "waiting") ? "#D92D20" :
45+
(mode === "seen") ? "#344054" : "#FFFFFF",
46+
height: "6px",
47+
width: "6px",
48+
borderRadius: "50%",
49+
marginLeft: "6px",
50+
}}/>;
51+
52+
return (
53+
<StyledChip
54+
icon={(mode === "new" || mode === "waiting" || mode === "seen") ? coloredDot : null}
55+
label={label}
56+
size="small"
57+
variant="outlined"
58+
/>
59+
);
60+
};
61+
62+
//Control panel settings for storybook
63+
Label.propTypes = {
64+
//Label type
65+
mode: PropTypes.oneOf(['orange', 'gray', 'brand', 'success']),
66+
67+
//Label text
68+
label: PropTypes.string.isRequired
69+
};
70+
71+
//Default values for this component
72+
Label.defaultProps = {
73+
style: {}
74+
};

src/components/LabelA/LabelA.css

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/components/LabelA/LabelA.jsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/components/LabelA/LabelA.stories.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/LabelB/LabelB.css

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)