Skip to content

Commit 2736619

Browse files
authored
Merge pull request #26 from BeeInventor/feature/phone-light-mode
feat: add light mode
2 parents e092038 + 0c2dafe commit 2736619

File tree

5 files changed

+72
-10
lines changed

5 files changed

+72
-10
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": "@beeinventor/dasiot-react-component-lib",
3-
"version": "1.1.10",
3+
"version": "1.1.11",
44
"module": "lib/index.js",
55
"types": "lib/index.d.ts",
66
"files": [

src/components/TextField/PhoneTextField/PhoneTextField.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ Default.args = {
118118
countryCodeList,
119119
};
120120

121+
export const ModeLight: Story<PhoneTextFieldProps> = Template.bind({});
122+
123+
ModeLight.args = {
124+
value: '',
125+
placeholder: 'Phone Number',
126+
countryCodeList,
127+
mode: 'light',
128+
};
129+
121130
export const Error: Story<PhoneTextFieldProps> = Template.bind({});
122131

123132
Error.args = {

src/components/TextField/PhoneTextField/PhoneTextField.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
1111
import { CountryCodeData } from '../../../Theme.types';
1212
import ComponentIcPhoneDbg from '../../../svg/ComponentIcPhoneDbg';
1313
import IcErrorIfo from '../../../svg/IcErrorIfo';
14+
import ComponentIcPhoneDbgBlack from '../../../svg/ComponentIcPhoneDbgBlack';
15+
import { Mode } from 'components/main.types';
1416

1517
const DEFAULT_WIDTH = 320;
1618
const DEFAULT_HEIGHT = 50;
@@ -20,15 +22,19 @@ const Root = styled(Box)(({}) => ({
2022
flexDirection: 'column',
2123
}));
2224

23-
const TextField = styled(Box)(({ theme }) => ({
25+
interface ModeProps {
26+
mode?: Mode;
27+
}
28+
29+
const TextField = styled(Box)<ModeProps>(({ theme, mode }) => ({
2430
...theme.text.Body_16_Reg,
2531
display: 'flex',
2632
alignItems: 'center',
2733
minWidth: DEFAULT_WIDTH,
2834
height: DEFAULT_HEIGHT,
2935
minHeight: DEFAULT_HEIGHT,
30-
color: '#FFFFFF',
31-
backgroundColor: 'rgba(0, 0, 0, .5)',
36+
color: mode === 'light' ? theme.color.secondary.$100 : '#FFF',
37+
backgroundColor: mode === 'light' ? '#F5F5F5' : 'rgba(0, 0, 0, .5)',
3238
borderRadius: 4,
3339
padding: '13px 24px',
3440
'&.container--error': {
@@ -48,10 +54,10 @@ const PhoneCode = styled(Box)(({}) => ({
4854
},
4955
}));
5056

51-
const Input = styled(InputBase)(({ theme }) => ({
57+
const Input = styled(InputBase)<ModeProps>(({ theme, mode }) => ({
5258
...theme.text.Body_16_Reg,
5359
flex: 1,
54-
color: 'white',
60+
color: mode === 'light' ? theme.color.secondary.$100 : 'white',
5561
backgroundColor: 'transparent',
5662
outline: 'none',
5763
border: 'none',
@@ -60,10 +66,10 @@ const Input = styled(InputBase)(({ theme }) => ({
6066
},
6167
}));
6268

63-
const Separator = styled(Box)(({}) => ({
69+
const Separator = styled(Box)<ModeProps>(({ mode }) => ({
6470
width: 2,
6571
height: '100%',
66-
border: '1px solid #FFFFFF',
72+
border: `1px solid ${mode === 'light' ? '#3E3E3E' : '#FFFFFF'} `,
6773
borderRadius: 1,
6874
}));
6975

@@ -122,6 +128,7 @@ const PhoneTextField: VFC<PhoneTextFieldProps> = (props) => {
122128
error,
123129
errorMessage,
124130
popperProps,
131+
mode,
125132
...otherProps
126133
} = props;
127134
const containerDOM = useRef<HTMLDivElement>(null);
@@ -186,23 +193,29 @@ const PhoneTextField: VFC<PhoneTextFieldProps> = (props) => {
186193
className={classnames({
187194
'container--error': error,
188195
})}
196+
mode={mode}
189197
{...otherProps}
190198
>
191-
<ComponentIcPhoneDbg style={{ marginRight: 6 }} />
199+
{mode === 'light' ? (
200+
<ComponentIcPhoneDbgBlack style={{ marginRight: 6 }} />
201+
) : (
202+
<ComponentIcPhoneDbg style={{ marginRight: 6 }} />
203+
)}
192204
<PhoneCode onClick={() => setShowMenu(!showMenu)}>
193205
<span className="code-text">{`+${selectedCode}`}</span>
194206
{showMenu ? (
195207
<KeyboardArrowUp style={{ margin: '0 6px' }} />
196208
) : (
197209
<KeyboardArrowDownIcon style={{ margin: '0 6px' }} />
198210
)}
199-
<Separator />
211+
<Separator mode={mode} />
200212
</PhoneCode>
201213
<Input
202214
type="tel"
203215
placeholder={placeholder}
204216
value={inputValue}
205217
onChange={handleInputOnChange}
218+
mode={mode}
206219
{...inputProps}
207220
/>
208221
</TextField>

src/components/TextField/PhoneTextField/PhoneTextField.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BoxProps, InputBaseProps, PopperProps } from '@mui/material';
2+
import { Mode } from 'components/main.types';
23
import { CountryCodeData } from '../../../Theme.types';
34

45
export interface phoneData {
@@ -19,4 +20,5 @@ export interface PhoneTextFieldProps extends Omit<BoxProps, 'onChange'> {
1920
errorMessage?: string;
2021
inputProps?: InputBaseProps;
2122
popperProps?: Omit<PopperProps, 'open' | 'anchorEl'>;
23+
mode?: Mode;
2224
}

src/svg/ComponentIcPhoneDbgBlack.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React, { CSSProperties, VFC } from 'react';
2+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
3+
4+
interface Props {
5+
width?: CSSProperties['width'];
6+
height?: CSSProperties['height'];
7+
}
8+
9+
const ComponentIcPhoneDbgBlack: VFC<Props & Omit<SvgIconProps, keyof Props>> = (
10+
props,
11+
) => {
12+
const { viewBox = '0 0 40 40', ...otherProps } = props;
13+
14+
return (
15+
<SvgIcon
16+
viewBox={viewBox}
17+
fill="none"
18+
xmlns="http://www.w3.org/2000/svg"
19+
sx={{
20+
width: props.width ?? 40,
21+
height: props.height ?? 40,
22+
}}
23+
{...otherProps}
24+
>
25+
<path
26+
d="M26 12L26 28L14 28L14 12L26 12Z"
27+
stroke="#3E3E3E"
28+
strokeWidth="2"
29+
strokeLinejoin="round"
30+
fill="none"
31+
/>
32+
<rect x="17" y="24" width="6" height="2" rx="1" fill="#3E3E3E" />
33+
{/* <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> */}
34+
</SvgIcon>
35+
);
36+
};
37+
38+
export default ComponentIcPhoneDbgBlack;

0 commit comments

Comments
 (0)