Skip to content

Commit a810d3e

Browse files
authored
feat:add Input.Password (#16)
1 parent 52ee8aa commit a810d3e

File tree

16 files changed

+159
-13
lines changed

16 files changed

+159
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"dependencies": {
1818
"core-js": "^3.25.1"
1919
}
20-
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Button, Input } from 'pivot-design';
2+
import React, { useState } from 'react';
3+
4+
const App: React.FC = () => {
5+
const [visible, setVisible] = useState(false);
6+
return (
7+
<>
8+
<Input.Password placeholder="请输入" />
9+
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
10+
<Input.Password visibilityToggle={{ visible, onVisibleChange: setVisible }} placeholder="不可选中" />
11+
<Button size="middle" onClick={() => setVisible(!visible)}>
12+
Show
13+
</Button>
14+
</div>
15+
</>
16+
);
17+
};
18+
export default App;

packages/demo/src/components/Input/index.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313
<div className="title">固定前缀和后缀</div>
1414
<CodeBlock line={'5-7'}>
1515
<Prepend/>
16-
</CodeBlock>
16+
</CodeBlock>
17+
18+
<div className="title">密码框</div>
19+
<CodeBlock line={'5-7'}>
20+
<Password/>
21+
</CodeBlock>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const PasswordHidden: React.FC<any> = (props) => {
2+
return (
3+
<svg
4+
viewBox="0 0 1024 1024"
5+
focusable="false"
6+
data-icon="eye-invisible"
7+
width={props.size ?? '16'}
8+
height={props.size ?? '16'}
9+
fill={props.color ?? 'currentColor'}
10+
aria-hidden="true"
11+
>
12+
<path d="M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 000-51.5zm-63.57-320.64L836 122.88a8 8 0 00-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 000 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 000 11.31L155.17 889a8 8 0 0011.31 0l712.15-712.12a8 8 0 000-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 00-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 01146.2-106.69L401.31 546.2A112 112 0 01396 512z"></path>
13+
<path d="M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 00227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 01-112 112z"></path>
14+
</svg>
15+
);
16+
};
17+
18+
export default PasswordHidden;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const PasswordHidden: React.FC<any> = (props) => {
2+
return (
3+
<svg
4+
viewBox="0 0 1024 1024"
5+
focusable="false"
6+
data-icon="eye"
7+
width={props.size ?? '16'}
8+
height={props.size ?? '16'}
9+
fill={props.color ?? 'currentColor'}
10+
aria-hidden="true"
11+
>
12+
<path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"></path>
13+
</svg>
14+
);
15+
};
16+
17+
export default PasswordHidden;

packages/design-icon/Icon/iconComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const Icon: React.FC<IconProps> = (props) => {
1313
[`${prefix}-icon-${theme}`]: theme,
1414
[`${prefix}-icon-rotate`]: rotate,
1515
});
16+
console.log(Icons, iconName, 'name');
1617

1718
return (
1819
<>

packages/design-icon/Icon/icons-svg.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import Close from './icon-svg/close';
44
import DefautError from './icon-svg/defautError';
55
import Warning from './icon-svg/warning';
66
import Search from './icon-svg/search';
7+
import PasswordHidden from './icon-svg/passwordHidden';
8+
import PasswordShow from './icon-svg/passwordShow';
79

8-
export { Loading, Back, Close, DefautError, Warning, Search };
10+
export { Loading, Back, Close, DefautError, Warning, Search, PasswordHidden, PasswordShow };
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Icon from '../iconComponent';
2+
3+
const Loading: React.FC<any> = (props) => {
4+
return <Icon icon="PasswordHidden" {...props} />;
5+
};
6+
7+
export default Loading;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Icon from '../iconComponent';
2+
3+
const Loading: React.FC<any> = (props) => {
4+
return <Icon icon="PasswordVisible" {...props} />;
5+
};
6+
7+
export default Loading;

packages/design-icon/Icon/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ import DefautError from './icons/DefautError';
44
import Loading from './icons/Loading';
55
import Search from './icons/Search';
66
import Warning from './icons/Warning';
7+
import Icon from './iconComponent';
78

8-
export { Back, Close, DefautError, Loading, Search, Warning };
9+
export { Back, Close, DefautError, Loading, Search, Warning, Icon };

0 commit comments

Comments
 (0)