Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit 03ae1c1

Browse files
authored
Merge pull request #139 from Groww/develop
Develop
2 parents 91dc19c + 569acd4 commit 03ae1c1

File tree

8 files changed

+186
-64
lines changed

8 files changed

+186
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@groww-tech/ui-toolkit",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "A lightning nature UI",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

src/components/atoms/Popup/Popup.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,28 @@ class Popup extends React.PureComponent<Props> {
2626
const {
2727
visible,
2828
width,
29+
height,
2930
customStyles,
3031
closeMaskOnClick,
3132
closeOnEsc,
3233
showCloseButton,
3334
children,
34-
popupClass
35+
popupClass,
36+
animation
3537
} = this.props;
3638

3739
return (
3840
<Rodal
3941
visible={visible}
4042
onClose={this.onClose}
4143
width={width}
44+
height={height}
4245
customStyles={customStyles}
4346
closeMaskOnClick={closeMaskOnClick}
4447
closeOnEsc={closeOnEsc}
4548
showCloseButton={showCloseButton}
4649
popupClass={popupClass}
50+
animation={animation}
4751
>
4852
{children}
4953
</Rodal>
@@ -61,19 +65,22 @@ class Popup extends React.PureComponent<Props> {
6165

6266
Popup.defaultProps = {
6367
width: 400,
64-
onLoad: () => { },
65-
onUnLoad: () => { },
66-
onClose: () => { },
6768
closeMaskOnClick: true,
6869
closeOnEsc: true,
69-
showCloseButton: true,
7070
customStyles: {},
71-
popupClass: ''
71+
animation: 'zoom',
72+
showCloseButton: true,
73+
popupClass: 'popup-border',
74+
onLoad: () => { },
75+
onUnLoad: () => { },
76+
onClose: () => { }
7277
} as DefaultProps;
7378

7479

7580
type DefaultProps = {
76-
width: number;
81+
width: number | string;
82+
height?: number | string;
83+
animation?: string;
7784
onLoad: () => void;
7885
onUnLoad: () => void;
7986
onClose: () => void;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
3+
4+
const Dialog = (props: Props) => {
5+
const animation =
6+
(props.animationType === 'enter'
7+
? props.enterAnimation
8+
: props.leaveAnimation) || props.animation;
9+
10+
11+
const className = `rodal-dialog rodal-${animation}-${props.animationType}`;
12+
13+
const { width, height, duration, customStyles } = props;
14+
15+
const style = {
16+
width: width,
17+
height: height,
18+
animationDuration: duration + 'ms',
19+
WebkitAnimationDuration: duration + 'ms'
20+
// borderTopLeftRadius: '7px',
21+
// borderTopRightRadius: '7px'
22+
};
23+
24+
const mergedStyles = { ...style, ...customStyles };
25+
26+
return (
27+
<div style={mergedStyles}
28+
className={className}
29+
>
30+
{props.children}
31+
</div>
32+
);
33+
};
34+
35+
36+
type Props = {
37+
animation: string;
38+
animationType: string;
39+
enterAnimation: string;
40+
leaveAnimation: string;
41+
width: number | string;
42+
height: number | string;
43+
duration: number;
44+
children: React.ReactNode;
45+
customStyles: React.CSSProperties;
46+
}
47+
48+
export default Dialog;

src/components/atoms/Popup/Rodal/Rodal.tsx

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import cn from 'classnames';
33

4+
import Dialog from './Dialog';
5+
46
import './rodal.css';
57

68
// env
@@ -9,35 +11,6 @@ const UA = IN_BROWSER && window.navigator.userAgent.toLowerCase();
911
const IS_IE_9 = UA && UA.indexOf('msie 9.0') > 0;
1012

1113

12-
const Dialog = (props: DialogProps) => {
13-
const animation =
14-
(props.animationType === 'enter'
15-
? props.enterAnimation
16-
: props.leaveAnimation) || props.animation;
17-
18-
const className = `rodal-dialog rodal-${animation}-${props.animationType}`;
19-
20-
const { width, height, measure, duration } = props;
21-
22-
const style = {
23-
width: width + measure,
24-
height: height + measure,
25-
animationDuration: duration + 'ms',
26-
WebkitAnimationDuration: duration + 'ms'
27-
};
28-
29-
const mergedStyles = { ...style };
30-
31-
return (
32-
<div style={mergedStyles}
33-
className={className}
34-
>
35-
{props.children}
36-
</div>
37-
);
38-
};
39-
40-
4114
class Rodal extends React.Component<Props, State> {
4215
el: HTMLDivElement | null = null;
4316

@@ -126,7 +99,6 @@ class Rodal extends React.Component<Props, State> {
12699
duration,
127100
className,
128101
children,
129-
customStyles,
130102
showCloseButton,
131103
popupClass
132104
} = this.props;
@@ -154,7 +126,7 @@ class Rodal extends React.Component<Props, State> {
154126
return (
155127
<div
156128
style={style}
157-
className={cn('rodal', `rodal-fade-${animationType}`, className)}
129+
className={cn('rodal', `rodal-fade-${animationType}`, className, 'rodal-background')}
158130
onAnimationEnd={this.animationEnd}
159131
tabIndex={-1}
160132
ref={
@@ -168,9 +140,7 @@ class Rodal extends React.Component<Props, State> {
168140
<Dialog {...this.props}
169141
animationType={animationType}
170142
>
171-
<div className={`child-wrapper ${popupClass}`}
172-
style={{ ...customStyles }}
173-
>
143+
<div className={`child-wrapper ${popupClass}`}>
174144
{children}
175145
{CloseButton}
176146
</div>
@@ -184,46 +154,32 @@ class Rodal extends React.Component<Props, State> {
184154
Rodal.defaultProps = {
185155
width: 400,
186156
height: 240,
187-
measure: 'px',
188157
visible: false,
189158
showMask: true,
190159
closeOnEsc: false,
191160
closeMaskOnClick: true,
192161
showCloseButton: true,
193-
animation: 'zoom',
194-
enterAnimation: '',
195-
leaveAnimation: '',
196-
onAnimationEnd: () => { },
162+
animation: 'zoom', // slideup for msite;
197163
duration: 300,
198164
className: '',
199165
customStyles: {},
200-
customMaskStyles: {}
166+
customMaskStyles: {},
167+
popupClass: 'popup-border',
168+
enterAnimation: '',
169+
leaveAnimation: '',
170+
onAnimationEnd: () => { }
201171
} as DefaultProps;
202172

203173

204-
type DialogProps = {
205-
animation: string;
206-
animationType: string;
207-
enterAnimation: string;
208-
leaveAnimation: string;
209-
width: number;
210-
height: number;
211-
measure: string;
212-
duration: number;
213-
children: React.ReactNode;
214-
}
215-
216-
217174
type State = {
218175
isShow: boolean;
219176
animationType: string;
220177
}
221178

222179

223180
type DefaultProps = {
224-
width: number;
225-
height: number;
226-
measure: string;
181+
width: number | string;
182+
height: number | string;
227183
visible: boolean;
228184
showMask: boolean;
229185
closeOnEsc: boolean;

src/components/atoms/Popup/Rodal/rodal.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,3 +540,11 @@
540540
position: relative;
541541
width: 100%;
542542
}
543+
544+
.popup-border {
545+
border-radius: 6px;
546+
}
547+
548+
.rodal-background {
549+
background: var(--constantHalfTransparent);
550+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React from 'react';
2+
3+
4+
import './toggleSelection.css';
5+
6+
7+
const ToggleSelection = (props: Props) => {
8+
const { leftText, rightText, isActive, onChange, parentClass } = props;
9+
10+
const choiceClasses = 'fs16 fw500 fullWidth absolute-center tc341ChoiceClass ';
11+
const activeChoiceClasses = choiceClasses + 'clrGreen tc341ActiveChoice';
12+
const inActiveChoiceClasses = choiceClasses + 'clrText tc341InactiveChoice';
13+
14+
const leftTextClasses = isActive ? activeChoiceClasses : inActiveChoiceClasses;
15+
const rightTextClasses = !isActive ? activeChoiceClasses : inActiveChoiceClasses;
16+
17+
18+
const changeChoice = (turnActive: boolean) => {
19+
if (onChange && (turnActive !== isActive)) {
20+
onChange(isActive);
21+
}
22+
};
23+
24+
25+
return (
26+
<div className={`valign-wrapper tc341ToggleWrapper ${parentClass}`}>
27+
<div
28+
className={leftTextClasses}
29+
onClick={() => changeChoice(true)}
30+
>
31+
{leftText}
32+
</div>
33+
34+
<div className="tc341Divider"></div>
35+
36+
<div
37+
className={rightTextClasses}
38+
onClick={() => changeChoice(false)}
39+
>
40+
{rightText}
41+
</div>
42+
</div>
43+
);
44+
45+
};
46+
47+
48+
const defaultProps: DefaultProps = {
49+
parentClass: '',
50+
leftText: 'En',
51+
rightText: 'हि',
52+
activeBackgroundColor: 'var(--primaryClr)',
53+
inactiveBackgroundColor: 'var(--subText)'
54+
};
55+
56+
57+
type RequiredProps = {
58+
isActive: boolean;
59+
onChange: (isActive: boolean) => void;
60+
}
61+
62+
63+
type DefaultProps = {
64+
parentClass: string;
65+
leftText: React.ReactNode;
66+
rightText: React.ReactNode;
67+
activeBackgroundColor: string;
68+
inactiveBackgroundColor: string;
69+
}
70+
71+
72+
ToggleSelection.defaultProps = defaultProps;
73+
74+
export type Props = RequiredProps & DefaultProps;
75+
76+
export default ToggleSelection;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as ToggleSelection } from './ToggleSelection';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.tc341ToggleWrapper {
2+
width: 88px;
3+
height: 32px;
4+
border-radius: 30px;
5+
border: 1px solid var(--primaryClr);
6+
justify-content: space-evenly;
7+
overflow: hidden;
8+
}
9+
10+
11+
.tc341Divider {
12+
height: 100%;
13+
width: 1px;
14+
background-color: var(--primaryClr);
15+
z-index: var(--zindex300);
16+
}
17+
18+
19+
.tc341ActiveChoice {
20+
background-color: var(--primaryClr10);
21+
}
22+
23+
24+
.tc341ChoiceClass {
25+
height: 100%;
26+
}

0 commit comments

Comments
 (0)