Skip to content

Commit

Permalink
fix: name constants and delete text and change view for rigth positio…
Browse files Browse the repository at this point in the history
…n button
  • Loading branch information
NasgulNexus committed Aug 17, 2023
1 parent 3af76e4 commit a92d81f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/lib/kit/components/Inputs/ArrayBase/ArrayBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => {
arrayInput.onItemAdd(item);
};

const viewButton =
spec.viewSpec.addButtonPosition === 'right' ? 'flat-secondary' : 'normal';

if (!arrayInput.value && spec.defaultValue) {
return (
<Button
view="flat-secondary"
view={viewButton}
onClick={() =>
input.onChange(
transformArrIn<ArrayValue, FieldArrayValue>(spec.defaultValue!),
Expand All @@ -100,20 +103,24 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => {
qa={`${name}-init-arr`}
>
<Icon data={Plus} size={14} />
{spec.viewSpec.layoutTitle || null}
{spec.viewSpec.addButtonPosition === 'right'
? null
: spec.viewSpec.layoutTitle || null}
</Button>
);
}

return (
<Button
view="flat-secondary"
view={viewButton}
onClick={onItemAdd}
disabled={spec.viewSpec.disabled}
qa={`${name}-add-item`}
>
<Icon data={Plus} size={14} />
{spec.viewSpec.itemLabel || null}
{spec.viewSpec.addButtonPosition === 'right'
? null
: spec.viewSpec.itemLabel || null}
</Button>
);
}, [
Expand All @@ -122,6 +129,7 @@ export const ArrayBase: ArrayInput = ({spec, name, arrayInput, input}) => {
name,
spec.defaultValue,
spec.items,
spec.viewSpec.addButtonPosition,
spec.viewSpec.disabled,
spec.viewSpec.itemLabel,
spec.viewSpec.layoutTitle,
Expand Down
4 changes: 2 additions & 2 deletions src/stories/components/InputPreview/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const itemPrefix: StringSpec = {
const addButtonPosition: StringSpec = {
type: SpecTypes.String,
enum: ['―', 'down', 'right'],
viewSpec: {type: 'select', layout: 'row', layoutTitle: 'Format'},
viewSpec: {type: 'select', layout: 'row', layoutTitle: 'Add Button Position'},
};

const table: ArraySpec = {
Expand All @@ -201,7 +201,7 @@ const table: ArraySpec = {
viewSpec: {
type: 'table',
layout: 'accordeon',
layoutTitle: 'Enum description',
layoutTitle: 'Table',
table: [
{label: 'Property', property: 'property'},
{label: 'Label', property: 'label'},
Expand Down

0 comments on commit a92d81f

Please sign in to comment.