Skip to content

Commit b424253

Browse files
committed
style: 更新按钮位置相关东西
1 parent 532f83b commit b424253

5 files changed

Lines changed: 17 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default () => {
3333
### InlineEditProps
3434

3535
| 名称 | 类型 | 默认值 | 说明 |
36-
| -------------- | -------------------- | --------- | ------------------ | ---- |
36+
| -------------- | -------------------- | --------- | ------------------ |
3737
| className | string | - | 类名 |
3838
| style | React.CSSProperties | - | 样式 |
3939
| keepOpenOnBlur | `boolean` | `false` | 失去焦点时保持打开 |
@@ -43,7 +43,7 @@ export default () => {
4343
| defaultValue | `string` | - | 默认值 |
4444
| isEditing | `boolean` | - | 是否正在编辑 |
4545
| loading | `boolean` | - | 加载中 |
46-
| placement | `'top' | 'bottom'` | - | 位置 |
46+
| placement | `top` \| `bottom` | - | 按钮位置 |
4747
| readView | `React.ReactNode` | - | 查看视图 |
4848
| editView | `React.ReactNode` | - | 编辑视图 |
4949
| onEdit | `() => void` | - | 编辑事件 |

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
{
22
"name": "@twp0217/react-inline-edit",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Inline edit component for React",
55
"scripts": {
66
"start": "dumi dev",
77
"docs:build": "dumi build",
88
"docs:deploy": "gh-pages -d docs-dist",
99
"build": "father-build",
1010
"deploy": "npm run docs:build && npm run docs:deploy",
11+
"release": "npm run build && npm publish --access public",
1112
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
1213
"test": "umi-test",
1314
"test:coverage": "umi-test --coverage",
14-
"prepublishOnly": "npm run build",
15-
"publish": "npm publish --access public",
1615
"commit": "git-cz",
1716
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
1817
},

src/InlineEdit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ InlineEdit.defaultProps = {
101101
hideActions: false,
102102
confirmText: 'Confirm',
103103
cancelText: 'Cancel',
104+
placement: 'bottom',
104105
};
105106

106107
export default InlineEdit;

src/components/EditView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ const EditView = (props: EditViewProps) => {
5555

5656
return (
5757
<div
58-
className={classNames('inline-edit-edit-view-actions', {
59-
'inline-edit-edit-view-actions-placement-top': placement === 'top',
60-
})}
58+
className={classNames(
59+
'inline-edit-edit-view-actions',
60+
`inline-edit-edit-view-actions-placement-${placement}`,
61+
)}
6162
>
6263
<button
6364
title={confirmText}

src/index.less

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@margin: 4px;
33
@margin-top-actions: @margin / 2;
44
@button-size: 24px;
5+
@button-bg: #fff;
56

67
.inline-edit {
78
&-container {
@@ -15,7 +16,7 @@
1516
line-height: 0;
1617
text-align: center;
1718
text-transform: none;
18-
vertical-align: -0.125em;
19+
vertical-align: -3px;
1920
text-rendering: optimizeLegibility;
2021

2122
svg {
@@ -53,8 +54,10 @@
5354

5455
&-placement {
5556
&-top {
56-
top: -100%;
57-
margin-top: -@margin-top-actions;
57+
top: auto;
58+
bottom: 100%;
59+
margin-top: 0;
60+
margin-bottom: @margin-top-actions;
5861
}
5962
}
6063

@@ -65,8 +68,7 @@
6568
margin-right: @margin;
6669
padding: 0;
6770
font-size: 14px;
68-
line-height: @button-size;
69-
background: #fff;
71+
background-color: @button-bg;
7072
border: 1px solid @border-color;
7173
border-radius: 2px;
7274
cursor: pointer;
@@ -76,7 +78,7 @@
7678
}
7779

7880
&:hover {
79-
background-color: fade(@border-color, 85%);
81+
background-color: fade(@border-color, 25%);
8082
}
8183
}
8284
}

0 commit comments

Comments
 (0)