Skip to content

Commit d8595a8

Browse files
committed
fixup: remove object field type file, use field type content for it
1 parent 16fa8a8 commit d8595a8

File tree

2 files changed

+90
-118
lines changed

2 files changed

+90
-118
lines changed

src/components/field/field-type-content.tsx

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,84 @@
11
import { useMemo } from 'react';
2+
import styled from '@emotion/styled';
3+
import { spacing, transitionDuration } from '@leafygreen-ui/tokens';
4+
import { palette } from '@leafygreen-ui/palette';
25

3-
import { ObjectFieldType } from '@/components/field/object-field-type';
46
import { useEditableDiagramInteractions } from '@/hooks/use-editable-diagram-interactions';
7+
import { PlusWithSquare } from '@/components/icons/plus-with-square';
8+
9+
const ObjectTypeContainer = styled.div`
10+
display: flex;
11+
justify-content: flex-end;
12+
align-items: center;
13+
line-height: 20px;
14+
`;
15+
16+
const AddNestedFieldIconButton = styled.button`
17+
background: none;
18+
border: none;
19+
outline: none;
20+
padding: ${spacing[100]}px;
21+
margin: 0;
22+
margin-left: ${spacing[100]}px;
23+
cursor: pointer;
24+
color: inherit;
25+
display: flex;
26+
position: relative;
27+
color: ${props => props.theme.node.fieldIconButton};
28+
29+
&::before {
30+
content: '';
31+
transition: ${transitionDuration.default}ms all ease-in-out;
32+
position: absolute;
33+
top: 0;
34+
bottom: 0;
35+
left: 0;
36+
right: 0;
37+
border-radius: 100%;
38+
transform: scale(0.8);
39+
}
40+
41+
&:active::before,
42+
&:hover::before,
43+
&:focus::before,
44+
&[data-hover='true']::before,
45+
&[data-focus='true']::before {
46+
transform: scale(1);
47+
}
48+
49+
&:active,
50+
&:hover,
51+
&[data-hover='true'],
52+
&:focus-visible,
53+
&[data-focus='true'] {
54+
color: ${palette.black};
55+
56+
&::before {
57+
background-color: ${props => props.theme.node.fieldIconButtonHoverBackground};
58+
}
59+
}
60+
61+
// Focus ring styles.
62+
&::after {
63+
position: absolute;
64+
content: '';
65+
pointer-events: none;
66+
top: 3px;
67+
right: 3px;
68+
bottom: 3px;
69+
left: 3px;
70+
border-radius: ${spacing[100]}px;
71+
box-shadow: 0 0 0 0 transparent;
72+
transition: box-shadow 0.16s ease-in;
73+
z-index: 1;
74+
}
75+
&:focus-visible {
76+
&::after {
77+
box-shadow: 0 0 0 3px ${palette.blue.light1} !important;
78+
transition-timing-function: ease-out;
79+
}
80+
}
81+
`;
582

683
export const FieldTypeContent = ({
784
type,
@@ -18,6 +95,7 @@ export const FieldTypeContent = ({
1895
() =>
1996
_onClickAddFieldToObjectField
2097
? (event: React.MouseEvent<HTMLButtonElement>) => {
98+
// Don't click on the field element.
2199
event.stopPropagation();
22100
_onClickAddFieldToObjectField(event, nodeId, Array.isArray(id) ? id : [id]);
23101
}
@@ -27,10 +105,17 @@ export const FieldTypeContent = ({
27105

28106
if (type === 'object' && !!onClickAddFieldToObject) {
29107
return (
30-
<ObjectFieldType
31-
data-testid={`object-field-type-${nodeId}-${typeof id === 'string' ? id : id.join('.')}`}
32-
onClickAddFieldToObject={onClickAddFieldToObject}
33-
/>
108+
<ObjectTypeContainer>
109+
{'{}'}
110+
<AddNestedFieldIconButton
111+
data-testid={`object-field-type-${nodeId}-${typeof id === 'string' ? id : id.join('.')}`}
112+
onClick={onClickAddFieldToObject}
113+
aria-label="Add new field"
114+
title="Add Field"
115+
>
116+
<PlusWithSquare />
117+
</AddNestedFieldIconButton>
118+
</ObjectTypeContainer>
34119
);
35120
}
36121

src/components/field/object-field-type.tsx

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)