- {label && (
-
- {label}
-
- )}
+
{value?.map((item, itemIndex) =>
Children.map(children, (child, childIndex) =>
diff --git a/src/components/uniforms-frontmatter/NestField.tsx b/src/components/uniforms-frontmatter/NestField.tsx
index a548fdc2..26a786f3 100644
--- a/src/components/uniforms-frontmatter/NestField.tsx
+++ b/src/components/uniforms-frontmatter/NestField.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms';
import AutoField from './AutoField';
-import { LabelStyles } from './component-styles';
+import { LabelField } from './LabelField';
export type NestFieldProps = HTMLFieldProps<
object,
@@ -19,7 +19,8 @@ function Nest({
}: NestFieldProps) {
return (
- {label &&
}
+
+
{children ||
fields.map(field => (
diff --git a/src/components/uniforms-frontmatter/NumField.tsx b/src/components/uniforms-frontmatter/NumField.tsx
index 09f2bc0d..4af552a5 100644
--- a/src/components/uniforms-frontmatter/NumField.tsx
+++ b/src/components/uniforms-frontmatter/NumField.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Ref } from 'react';
import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms';
-import { LabelStyles } from './component-styles';
+import { LabelField } from './LabelField';
export type NumFieldProps = HTMLFieldProps<
number,
@@ -27,7 +27,7 @@ function Num({
}: NumFieldProps) {
return (
- {label &&
}
+
- {label &&
}
+
{allowedValues?.map(item => (
diff --git a/src/components/uniforms-frontmatter/SelectField.css b/src/components/uniforms-frontmatter/SelectField.css
new file mode 100644
index 00000000..a4af6f2b
--- /dev/null
+++ b/src/components/uniforms-frontmatter/SelectField.css
@@ -0,0 +1,5 @@
+
+
+.autoform__select_field {
+ color: var(--frontmatter-select-foreground, var(--vscode-editor-foreground));
+}
\ No newline at end of file
diff --git a/src/components/uniforms-frontmatter/SelectField.tsx b/src/components/uniforms-frontmatter/SelectField.tsx
index 31addad1..09f4eb2a 100644
--- a/src/components/uniforms-frontmatter/SelectField.tsx
+++ b/src/components/uniforms-frontmatter/SelectField.tsx
@@ -2,7 +2,8 @@ import xor = require('lodash.xor');
import * as React from 'react';
import { Ref } from 'react';
import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms';
-import { LabelStyles } from './component-styles';
+import { LabelField } from './LabelField';
+import './SelectField.css';
const base64: typeof btoa =
typeof btoa === 'undefined'
@@ -42,8 +43,8 @@ function Select({
}: SelectFieldProps) {
const multiple = fieldType === Array;
return (
-
- {label &&
}
+
+
{checkboxes ? (
allowedValues!.map(item => (
diff --git a/src/components/uniforms-frontmatter/TextField.tsx b/src/components/uniforms-frontmatter/TextField.tsx
index c71f1839..1345ff9e 100644
--- a/src/components/uniforms-frontmatter/TextField.tsx
+++ b/src/components/uniforms-frontmatter/TextField.tsx
@@ -1,7 +1,7 @@
import { Ref } from 'react';
import * as React from 'react';
import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms';
-import { LabelStyles } from './component-styles';
+import { LabelField } from './LabelField';
export type TextFieldProps = HTMLFieldProps<
string,
@@ -23,9 +23,12 @@ function Text({
value,
...props
}: TextFieldProps) {
+
+ console.log('TextFieldProps', props);
+
return (
- {label && }
+
form?.reset()}>
{
- (model && selectedIndex !== null) && (
+ (model && selectedIndex !== null) ? (
Editing: Record {selectedIndex + 1}
+ ) : (
+ Create a new record
)
}
@@ -109,31 +113,11 @@ export const DataCollectionField: React.FunctionComponent
- {
- value && (
-
-
-
- {
- value.map((v: any, i: number) => (
- -
- Record {i+1}
-
-
-
-
- ))
- }
-
-
- )
- }
+
setSelectedIndex(null)}
+ onEdit={(index: number) => setSelectedIndex(index)}
+ onDelete={deleteItem} />
);
};
\ No newline at end of file
diff --git a/src/panelWebView/components/DataCollection/DataCollectionRecord.tsx b/src/panelWebView/components/DataCollection/DataCollectionRecord.tsx
new file mode 100644
index 00000000..8f9a1ab3
--- /dev/null
+++ b/src/panelWebView/components/DataCollection/DataCollectionRecord.tsx
@@ -0,0 +1,27 @@
+import * as React from 'react';
+import { PencilIcon, TrashIcon } from '@heroicons/react/outline';
+
+export interface IDataCollectionRecordProps {
+ id: number;
+ onEdit: (id: number) => void;
+ onDelete: (id: number) => void;
+}
+
+export const DataCollectionRecord: React.FunctionComponent
= ({ id, onEdit, onDelete }: React.PropsWithChildren) => {
+ return (
+
+ Record {id+1}
+
+
+
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/src/panelWebView/components/DataCollection/DataCollectionRecords.tsx b/src/panelWebView/components/DataCollection/DataCollectionRecords.tsx
new file mode 100644
index 00000000..d762805c
--- /dev/null
+++ b/src/panelWebView/components/DataCollection/DataCollectionRecords.tsx
@@ -0,0 +1,47 @@
+import { CollectionIcon, PlusIcon } from '@heroicons/react/outline';
+import * as React from 'react';
+import { VsLabel } from '../VscodeComponents';
+import { DataCollectionRecord } from './DataCollectionRecord';
+
+export interface IDataCollectionRecordsProps {
+ records: any[];
+ onAdd: () => void;
+ onEdit: (id: number) => void;
+ onDelete: (id: number) => void;
+}
+
+export const DataCollectionRecords: React.FunctionComponent = ({ records, onAdd, onEdit, onDelete }: React.PropsWithChildren) => {
+
+ if (!records || !records.length) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+ Records
+
+
+
+
+
+
+
+ {
+ records.map((v: any, i: number) => (
+
+ ))
+ }
+
+
+ );
+};
\ No newline at end of file
diff --git a/src/panelWebView/styles.css b/src/panelWebView/styles.css
index b4fd8631..5f011dc7 100644
--- a/src/panelWebView/styles.css
+++ b/src/panelWebView/styles.css
@@ -1,6 +1,7 @@
.data_collection__field {
- border: 1px dashed rgba(255, 255, 255, 0.2);
+ border: 1px dashed var(--vscode-button-secondaryBackground);
+ color: var(--vscode--settings-headerForeground);
padding: .5rem 1rem;
margin-bottom: .5rem;
@@ -9,6 +10,12 @@
border: 1px dashed var(--vscode-button-background);
padding: 1rem;
filter: brightness(85%);
+
+ h3 {
+ font-size: 1rem;
+ font-weight: bold;
+ text-align: center;
+ }
}
.fields > div {
@@ -63,27 +70,65 @@
font-weight: bold;
}
+ ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
li {
- margin-bottom: .5rem;
+ border-bottom: 1px solid var(--vscode-button-secondaryBackground);
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: .5rem 0;
span {
margin-right: .5rem;
}
+ > div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ button:last-child {
+ margin-left: .5rem;
+ }
+ }
+
&:last-child {
margin-bottom: 0;
+ border-bottom: 0;
}
}
}
+.data_collection__list .metadata_field__label {
+ justify-content: space-between;
+
+ > div {
+ display: flex;
+ align-items: center;
+ }
+
+ button svg {
+ margin-right: 0;
+ }
+}
+
.data_collection__list__button {
width: auto;
background: none;
- color: var(--vscode-editor-foreground);
+ color: inherit;
+ outline: none !important;
+ outline-offset: inherit !important;
+ padding: 0;
+ margin: 0;
&:hover {
- color: var(--vscode-button-secondaryForeground);
- background: var(--vscode-button-secondaryHoverBackground);
+ color: var(--vscode-editor-foreground);
+ background: none;
}
}