fix(editor): Fix design system form element sizing (#11040)

This commit is contained in:
Csaba Tuncsik 2024-10-03 10:50:53 +02:00 committed by GitHub
parent 86c632aabf
commit 67c3453885
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 320 additions and 6 deletions

View file

@ -0,0 +1,57 @@
import { createComponentRenderer } from '../../../__tests__/render';
import FormBox from '../FormBox.vue';
const render = createComponentRenderer(FormBox);
describe('FormBox', () => {
it('should render the component', () => {
const { container } = render({
props: {
title: 'Title',
inputs: [
{
name: 'name',
properties: {
label: 'Name',
type: 'text',
required: true,
showRequiredAsterisk: true,
validateOnBlur: false,
autocomplete: 'email',
capitalize: true,
labelSize: 'small',
tagSize: 'small',
},
},
{
name: 'email',
properties: {
label: 'Email',
type: 'email',
required: true,
showRequiredAsterisk: true,
validateOnBlur: false,
autocomplete: 'email',
capitalize: true,
labelSize: 'medium',
tagSize: 'medium',
},
},
{
name: 'password',
properties: {
label: 'Password',
type: 'password',
required: true,
showRequiredAsterisk: true,
validateOnBlur: false,
autocomplete: 'current-password',
capitalize: true,
},
},
],
},
});
expect(container).toMatchSnapshot();
});
});

View file

@ -0,0 +1,259 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`FormBox > should render the component 1`] = `
<div>
<div
class="n8n-form-box container"
>
<div
class="heading"
>
<span
class="n8n-heading size-xlarge regular"
>
Title
</span>
</div>
<div
class="inputsContainer"
>
<div>
<div
class="grid"
>
<div
class=""
>
<div
capitalize="true"
class="container"
data-test-id="name"
>
<label
class="n8n-input-label inputLabel heading small"
for="name"
>
<div
class="title"
>
<span
class="n8n-text size-small bold"
>
Name
<span
class="n8n-text primary size-small bold"
>
*
</span>
</span>
</div>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</label>
<div
class=""
>
<div
class="el-input el-input--small n8n-input"
>
<!-- input -->
<!-- prepend slot -->
<!--v-if-->
<div
class="el-input__wrapper"
>
<!-- prefix slot -->
<!--v-if-->
<input
autocomplete="email"
class="el-input__inner"
name="name"
placeholder=""
rows="2"
tabindex="0"
title=""
type="text"
/>
<!-- suffix slot -->
<!--v-if-->
</div>
<!-- append slot -->
<!--v-if-->
</div>
</div>
<!--v-if-->
</div>
</div>
<div
class=""
>
<div
capitalize="true"
class="container"
data-test-id="email"
>
<label
class="n8n-input-label inputLabel heading medium"
for="email"
>
<div
class="title"
>
<span
class="n8n-text size-medium bold"
>
Email
<span
class="n8n-text primary size-medium bold"
>
*
</span>
</span>
</div>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</label>
<div
class=""
>
<div
class="el-input el-input--default n8n-input"
>
<!-- input -->
<!-- prepend slot -->
<!--v-if-->
<div
class="el-input__wrapper"
>
<!-- prefix slot -->
<!--v-if-->
<input
autocomplete="email"
class="el-input__inner"
name="email"
placeholder=""
rows="2"
tabindex="0"
title=""
type="email"
/>
<!-- suffix slot -->
<!--v-if-->
</div>
<!-- append slot -->
<!--v-if-->
</div>
</div>
<!--v-if-->
</div>
</div>
<div
class=""
>
<div
capitalize="true"
class="container"
data-test-id="password"
>
<label
class="n8n-input-label inputLabel heading medium"
for="password"
>
<div
class="title"
>
<span
class="n8n-text size-medium bold"
>
Password
<span
class="n8n-text primary size-medium bold"
>
*
</span>
</span>
</div>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</label>
<div
class=""
>
<div
class="el-input el-input--large n8n-input ph-no-capture"
>
<!-- input -->
<!-- prepend slot -->
<!--v-if-->
<div
class="el-input__wrapper"
>
<!-- prefix slot -->
<!--v-if-->
<input
autocomplete="current-password"
class="el-input__inner"
name="password"
placeholder=""
rows="2"
tabindex="0"
title=""
type="password"
/>
<!-- suffix slot -->
<!--v-if-->
</div>
<!-- append slot -->
<!--v-if-->
</div>
</div>
<!--v-if-->
</div>
</div>
</div>
</div>
</div>
<!--v-if-->
<div
class="actionContainer"
>
<!--v-if-->
</div>
</div>
</div>
`;

View file

@ -49,7 +49,7 @@ export interface Props {
inactiveLabel?: string;
inactiveColor?: string;
teleported?: boolean;
tagSize?: 'small' | 'medium';
tagSize?: 'small' | 'medium' | 'large';
}
const props = withDefaults(defineProps<Props>(), {
@ -59,7 +59,7 @@ const props = withDefaults(defineProps<Props>(), {
showRequiredAsterisk: true,
validateOnBlur: true,
teleported: true,
tagSize: 'small',
tagSize: 'large',
});
const emit = defineEmits<{

View file

@ -13,7 +13,6 @@ export type FormInputsProps = {
columnView?: boolean;
verticalSpacing?: '' | 'xs' | 's' | 'm' | 'l' | 'xl';
teleported?: boolean;
tagSize?: 'small' | 'medium';
};
type Value = string | number | boolean | null | undefined;
@ -24,7 +23,6 @@ const props = withDefaults(defineProps<FormInputsProps>(), {
columnView: false,
verticalSpacing: '',
teleported: true,
tagSize: 'small',
});
const emit = defineEmits<{
@ -129,7 +127,6 @@ onMounted(() => {
:data-test-id="input.name"
:show-validation-warnings="showValidationWarnings"
:teleported="teleported"
:tag-size="tagSize"
@update:model-value="(value: Value) => onUpdateModelValue(input.name, value)"
@validate="(value: boolean) => onValidate(input.name, value)"
@enter="onSubmit"

View file

@ -39,7 +39,7 @@ const props = withDefaults(defineProps<InputProps>(), {
});
const resolvedSize = computed(
() => (props.size === 'xlarge' ? undefined : props.size) as ElementPlusSizePropType,
() => (props.size === 'medium' ? 'default' : props.size) as ElementPlusSizePropType,
);
const classes = computed(() => {

View file

@ -56,6 +56,7 @@ export type IFormInput = {
focusInitially?: boolean;
disabled?: boolean;
labelSize?: 'small' | 'medium' | 'large';
tagSize?: 'small' | 'medium' | 'large';
labelAlignment?: 'left' | 'right' | 'center';
tooltipText?: string;
};