Skip to content

Commit f1b7ce1

Browse files
authored
Merge pull request #113 from opensrc0/develop
Added support of default theme, user custom theme and override theme property custom property by adding in cssProps object
2 parents 5b6f3e1 + 7698504 commit f1b7ce1

9 files changed

Lines changed: 368 additions & 76 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ __build-es
88

99
**/index.js
1010

11+
!__application/**/index.js
12+
1113
CHANGELOG.md
14+
15+
themePrepare_bck.js
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import styled from 'styled-components';
4-
import cx from 'classnames';
5-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1+
import React from "react"
2+
import PropTypes from "prop-types"
3+
import styled from "styled-components"
4+
import cx from "classnames"
5+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
66

77
const styles = {
8-
size: { s: 'xs', m: 's', l: 's' },
9-
padding: { s: [1, 2], m: [1.5, 2], l: [2, 2] },
8+
"size": { "s": "xs", "m": "s", "l": "s" },
9+
"padding": { "s": [1, 2], "m": [1.5, 2], "l": [2, 2] },
1010

1111
pointerEvents(props) {
1212
if (props.disabled) {
13-
return 'none';
13+
return "none"
1414
}
15-
return '';
15+
return ""
1616
},
1717
opacity(props) {
1818
if (props.disabled) {
19-
return '0.5';
19+
return "0.5"
2020
}
21-
return '';
21+
return ""
2222
},
23-
hover: {
23+
"hover": {
2424
color(props) {
25-
if (props.kind === 'filled') {
26-
return props.theme.color.white;
25+
if (props.kind === "filled") {
26+
return props.theme.color.white
2727
}
28-
if (props.kind === 'outlined') {
29-
return props.theme.color.white;
28+
if (props.kind === "outlined") {
29+
return props.theme.color.white
3030
}
31-
return '';
31+
return ""
3232
},
3333
backgroundColor(props) {
34-
if (props.kind === 'filled') {
35-
return props.theme.color[`${props.color}Dark`];
34+
if (props.kind === "filled") {
35+
return props.theme.color[`${props.color}Dark`]
3636
}
37-
if (props.kind === 'outlined') {
38-
return props.theme.color[props.color];
37+
if (props.kind === "outlined") {
38+
return props.theme.color[props.color]
3939
}
40-
return '';
40+
return ""
4141
},
4242
borderColor(props) {
43-
if (props.kind === 'filled') {
44-
return props.theme.color[`${props.color}Dark`];
43+
if (props.kind === "filled") {
44+
return props.theme.color[`${props.color}Dark`]
4545
}
46-
if (props.kind === 'outlined') {
47-
return props.theme.color[props.color];
46+
if (props.kind === "outlined") {
47+
return props.theme.color[props.color]
4848
}
49-
return '';
50-
},
51-
},
52-
};
49+
return ""
50+
}
51+
}
52+
}
5353

5454
const StyledButton = styled(
5555
({
@@ -60,7 +60,7 @@ const StyledButton = styled(
6060
fluid,
6161
isLoading,
6262
...props
63-
}) => <button {...props} />,
63+
}) => <button {...props} />
6464
)`
6565
display: inline-flex;
6666
align-items: center;
@@ -71,10 +71,10 @@ const StyledButton = styled(
7171
background-color: ${(props) => props.theme.Universal.Color[props.variant]};
7272
font-size: ${(props) => props.theme.Universal.FontSize[styles.size[props.size]]};
7373
padding: ${(props) => props.theme.Universal.PXL(styles.padding[props.size])};
74-
width: ${(props) => props.fluid ? '100%' : ''};
74+
width: ${(props) => props.fluid ? "100%" : ""};
7575
border-width: 1px;
7676
border-style: solid;
77-
border-color: ${(props) => props.theme.Button[props.variant].borderColor};
77+
border-color: ${(props) => props.theme.Universal.Color[props.variant]};
7878
border-radius: ${(props) => props.theme.Button.borderRadius};
7979
pointer-events: ${styles.pointerEvents};
8080
opacity: ${styles.opacity};
@@ -84,7 +84,7 @@ const StyledButton = styled(
8484
background-color: ${styles.hover.backgroundColor};
8585
border-color: ${styles.hover.borderColor};
8686
}
87-
`;
87+
`
8888

8989
function Button({ label, disabled, className, onClick, spin, ...props }) {
9090
return (
@@ -108,31 +108,31 @@ function Button({ label, disabled, className, onClick, spin, ...props }) {
108108
}
109109
{label}
110110
</StyledButton>
111-
);
111+
)
112112
}
113113

114114
Button.propTypes = {
115-
label: PropTypes.string,
116-
onClick: PropTypes.func,
117-
fluid: PropTypes.bool,
118-
disabled: PropTypes.bool,
119-
spin: PropTypes.bool,
120-
className: PropTypes.string,
121-
type: PropTypes.oneOf(['submit', 'button']),
122-
variant: PropTypes.string,
123-
size: PropTypes.oneOf(['s', 'm', 'l']),
124-
};
115+
"label": PropTypes.string,
116+
"onClick": PropTypes.func,
117+
"fluid": PropTypes.bool,
118+
"disabled": PropTypes.bool,
119+
"spin": PropTypes.bool,
120+
"className": PropTypes.string,
121+
"type": PropTypes.oneOf(["submit", "button"]),
122+
"variant": PropTypes.string,
123+
"size": PropTypes.oneOf(["s", "m", "l"])
124+
}
125125

126126
Button.defaultProps = {
127-
label: 'Button',
128-
onClick: () => {},
129-
fluid: false,
130-
disabled: false,
131-
spin: false,
132-
className: '',
133-
type: 'submit',
134-
variant: 'secondary',
135-
size: 'm',
136-
};
127+
"label": "Button",
128+
"onClick": () => {},
129+
"fluid": false,
130+
"disabled": false,
131+
"spin": false,
132+
"className": "",
133+
"type": "submit",
134+
"variant": "secondary",
135+
"size": "m"
136+
}
137137

138-
export default Button;
138+
export default Button

0 commit comments

Comments
 (0)