mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-07 21:47:02 +09:00
JS-7171: code review
This commit is contained in:
parent
f74fedda01
commit
ec0c254942
2 changed files with 32 additions and 57 deletions
|
@ -41,6 +41,7 @@
|
|||
.icon.collapse.isClosed { transform: rotateZ(-90deg); }
|
||||
|
||||
.iconWrap:hover,
|
||||
.iconWrap.hover,
|
||||
.iconWrap.active {
|
||||
.icon.back { background-image: url('~img/icon/widget/back1.svg'); }
|
||||
.icon.options { background-image: url('~img/icon/widget/options1.svg'); }
|
||||
|
@ -55,7 +56,6 @@
|
|||
&.isEmpty {
|
||||
.head {
|
||||
.buttons { display: flex; }
|
||||
.iconWrap.more { display: none; }
|
||||
|
||||
.sides:hover {
|
||||
.iconWrap.more { display: flex; }
|
||||
|
@ -112,12 +112,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.widget.active {
|
||||
.head {
|
||||
.iconWrap.more { background-color: var(--color-shape-highlight-medium); }
|
||||
}
|
||||
}
|
||||
|
||||
.widget.isPreview {
|
||||
.head { border-bottom: 1px solid var(--color-shape-secondary); padding: 12px 16px 11px 8px !important; }
|
||||
.head::before { top: 18px; }
|
||||
|
|
|
@ -20,7 +20,7 @@ interface Props extends I.WidgetComponent {
|
|||
|
||||
const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
|
||||
|
||||
const { config, space } = S.Common;
|
||||
const { space } = S.Common;
|
||||
const spaceview = U.Space.getSpaceview();
|
||||
const { block, isPreview, isEditing, className, setEditing, onDragStart, onDragOver, setPreview } = props;
|
||||
const { viewId } = block.content;
|
||||
|
@ -139,6 +139,7 @@ const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
|
|||
return;
|
||||
};
|
||||
|
||||
const node = $(nodeRef.current);
|
||||
const route = param.route || analytics.route.widget;
|
||||
const isFavorite = object.id == J.Constant.widgetId.favorite;
|
||||
|
||||
|
@ -192,37 +193,36 @@ const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
|
|||
return;
|
||||
};
|
||||
|
||||
// Bookmark creation logic
|
||||
const isBookmark =
|
||||
(U.Object.isInSetLayouts(object.layout) && type && U.Object.isBookmarkLayout(type.recommendedLayout)) ||
|
||||
(!U.Object.isInSetLayouts(object.layout) && U.Object.isBookmarkLayout(details.layout));
|
||||
const cb = object => {
|
||||
if (isFavorite) {
|
||||
Action.setIsFavorite([ object.id ], true, route);
|
||||
};
|
||||
|
||||
if (isBookmark) {
|
||||
if (isCollection) {
|
||||
C.ObjectCollectionAdd(object.id, [ object.id ]);
|
||||
};
|
||||
|
||||
U.Object.openConfig(object);
|
||||
analytics.createObject(object.type, object.layout, route, 0);
|
||||
|
||||
if (layout == I.WidgetLayout.Tree) {
|
||||
C.BlockCreate(object.id, '', I.BlockPosition.Bottom, U.Data.getLinkBlockParam(object.id, object.layout, true), (message: any) => {
|
||||
if (!message.error.code) {
|
||||
analytics.event('CreateLink');
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
if (U.Object.isBookmarkLayout(type.recommendedLayout)) {
|
||||
U.Menu.onBookmarkMenu({
|
||||
element: `#widget-${block.id} .iconWrap.create`,
|
||||
onOpen: () => node.addClass('active'),
|
||||
onClose: () => node.removeClass('active'),
|
||||
className: 'fixed',
|
||||
classNameWrap: 'fromSidebar',
|
||||
data: { details },
|
||||
}, (object) => {
|
||||
if (isFavorite) {
|
||||
Action.setIsFavorite([ object.id ], true, route);
|
||||
};
|
||||
|
||||
if (isCollection) {
|
||||
C.ObjectCollectionAdd(object.id, [ object.id ]);
|
||||
};
|
||||
|
||||
U.Object.openConfig(object);
|
||||
analytics.createObject(object.type, object.layout, route, 0);
|
||||
|
||||
if (layout == I.WidgetLayout.Tree) {
|
||||
C.BlockCreate(object.id, '', I.BlockPosition.Bottom, U.Data.getLinkBlockParam(object.id, object.layout, true), (message: any) => {
|
||||
if (!message.error.code) {
|
||||
analytics.event('CreateLink');
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
}, cb);
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -236,29 +236,8 @@ const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
|
|||
};
|
||||
|
||||
C.ObjectCreate(details, flags, templateId, typeKey, S.Common.space, (message: any) => {
|
||||
if (message.error.code) {
|
||||
return;
|
||||
};
|
||||
|
||||
const newObject = message.details;
|
||||
|
||||
if (isFavorite) {
|
||||
Action.setIsFavorite([ newObject.id ], true, route);
|
||||
};
|
||||
|
||||
if (isCollection) {
|
||||
C.ObjectCollectionAdd(object.id, [ newObject.id ]);
|
||||
};
|
||||
|
||||
U.Object.openConfig(newObject);
|
||||
analytics.createObject(newObject.type, newObject.layout, route, message.middleTime);
|
||||
|
||||
if (layout == I.WidgetLayout.Tree) {
|
||||
C.BlockCreate(object.id, '', I.BlockPosition.Bottom, U.Data.getLinkBlockParam(newObject.id, newObject.layout, true), (message: any) => {
|
||||
if (!message.error.code) {
|
||||
analytics.event('CreateLink');
|
||||
};
|
||||
});
|
||||
if (!message.error.code) {
|
||||
cb(message.details);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -283,9 +262,11 @@ const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
|
|||
const { x, y } = keyboard.mouse.page;
|
||||
|
||||
S.Menu.open('widget', {
|
||||
rect: { width: 0, height: 0, x: x + 4, y },
|
||||
element: `#widget-${block.id} .iconWrap.more`,
|
||||
rect: { width: 0, height: 0, x, y: y + 14 },
|
||||
className: 'fixed',
|
||||
classNameWrap: 'fromSidebar',
|
||||
horizontal: I.MenuDirection.Center,
|
||||
subIds: J.Menu.widget,
|
||||
onOpen: () => node.addClass('active'),
|
||||
onClose: () => node.removeClass('active'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue