Skip to content

Commit 1df7b37

Browse files
committed
feat: Improved how description is shown and improved margins
1 parent 7384bd8 commit 1df7b37

5 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/Form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ export const Form: React.FC<FormProps> = props => {
151151
)}
152152
</Box>
153153
{!editingField && (
154-
<Box flexDirection="row">
154+
<Box flexDirection="row" marginTop={1}>
155155
<Box flexDirection="column" flexGrow={1} width='40%'>
156156
{!editingField && sections[currentTab].description && (
157-
<Box marginX={1} marginTop={1} flexDirection='column'>
157+
<Box marginX={1} flexDirection='column'>
158158
<Text underline>Description:</Text>
159159
<DescriptionRenderer description={sections[currentTab]?.description} />
160160
</Box>

src/FormHeader.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ export const FormHeader: React.FC<
3232
<Box borderStyle="double" width="100%" flexDirection="column" ref={props.headerRef}>
3333
<Box width="100%">
3434
<Box flexGrow={1}>
35-
<Text bold={true}>{props.form.title}</Text>
36-
</Box>
37-
<Box>
38-
<Text>
39-
{!props.editingField ? 'Use left and right arrow keys to navigate between resources' : 'Press ESC to cancel, or Enter to complete field'}
40-
</Text>
35+
<Text bold>{props.form.title}</Text>
36+
<Text color={'gray'}>{` (${props.form.description})`}</Text>
4137
</Box>
4238
</Box>
4339
<Box width="100%">

src/ScrollArea.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export function ScrollArea({height, isStart, children, numFields, editingMode})
4848
// Couple of custom logic baked into here to improve the user experience
4949
// isStart ensures that the first down event will not scroll. This is because initially nothing has focus so the first down gives focus to the first element
5050
// The children.length calculation calculates a rough estimate of the total height. The 3 is the height of the buttons at the bottom.
51-
// The 4 is the fixed length of the brackets in the display.
52-
if (isStart || ((numFields + (3 * 3) + 4) < height)) {
51+
// The 5 is the fixed length of the static elements
52+
if (isStart || ((numFields + (3 * 3) + 5) < height)) {
5353
setCanScroll(false);
5454
dispatch({
5555
type: 'RESET'

src/demo/Test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,27 @@ export function Test() {
3838
}, 1000)
3939
}}
4040
form={{
41-
title: "Form title",
41+
title: "codify import",
42+
description: 'some parameters are required to continue import',
4243
sections: [
4344
{
4445
title: "asdf-global",
4546
fields: [
4647
{ type: 'string', name: 'plugin', label: 'plugin', required: true },
4748
{ type: 'string', name: 'version', label: 'version', required: true },
48-
]
49+
],
50+
description: 'Asdf global sets the global version of a asdf installed plugin.'
4951
},
5052
{
5153
title: "asdf-install",
5254
description: 'Asdf install is responsible for installing an asdf resource',
5355
fields: [
54-
{ type: 'string', name: 'directory', label: 'directory', required: true },
56+
{ type: 'string', name: 'directory', label: 'directory', required: true, description: 'The directory to install.' },
5557
]
5658
},
5759
{
5860
title: "asdf-local",
61+
description: 'Asdf global sets the local version of a asdf installed plugin.',
5962
fields: [
6063
{ type: 'string', name: 'plugin', label: 'plugin', required: true },
6164
{ type: 'string', name: 'version', label: 'version', required: true },
@@ -65,6 +68,7 @@ export function Test() {
6568
},
6669
{
6770
title: "asdf-plugin",
71+
// description: 'Asdf plugin installs a plugin.',
6872
fields: [
6973
{ type: 'string', name: 'plugin', label: 'plugin', required: true },
7074
{ type: 'string', name: 'versions', label: 'version'},

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export interface FormStructure {
5050
title?: string;
5151
/** A form contains several sections, each displayed as a tab. */
5252
sections: FormSection[];
53+
/** A general description for the form */
54+
description?: string;
5355
}
5456

5557
/**

0 commit comments

Comments
 (0)