Right to left mode (#611)

* Right to left mode

* Fix label

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala 2024-11-20 19:59:08 +05:30 committed by GitHub
parent fbf0831c6d
commit 62e980abae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 47 additions and 5 deletions

View File

@ -33,6 +33,7 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
'theme' => ['required', Rule::in(Form::THEMES)], 'theme' => ['required', Rule::in(Form::THEMES)],
'width' => ['required', Rule::in(Form::WIDTHS)], 'width' => ['required', Rule::in(Form::WIDTHS)],
'size' => ['required', Rule::in(Form::SIZES)], 'size' => ['required', Rule::in(Form::SIZES)],
'layout_rtl' => 'boolean',
'border_radius' => ['required', Rule::in(Form::BORDER_RADIUS)], 'border_radius' => ['required', Rule::in(Form::BORDER_RADIUS)],
'cover_picture' => 'url|nullable', 'cover_picture' => 'url|nullable',
'logo_picture' => 'url|nullable', 'logo_picture' => 'url|nullable',

View File

@ -74,6 +74,7 @@ class FormResource extends JsonResource
'is_password_protected' => true, 'is_password_protected' => true,
'has_password' => $this->has_password, 'has_password' => $this->has_password,
'width' => 'centered', 'width' => 'centered',
'layout_rtl' => $this->layout_rtl,
'no_branding' => $this->no_branding, 'no_branding' => $this->no_branding,
'properties' => [], 'properties' => [],
'logo_picture' => $this->logo_picture, 'logo_picture' => $this->logo_picture,

View File

@ -58,6 +58,7 @@ class Form extends Model implements CachableAttributes
'border_radius', 'border_radius',
'theme', 'theme',
'width', 'width',
'layout_rtl',
'cover_picture', 'cover_picture',
'logo_picture', 'logo_picture',
'dark_mode', 'dark_mode',

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('forms', function (Blueprint $table) {
$table->boolean('layout_rtl')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('forms', function (Blueprint $table) {
$table->dropColumn('layout_rtl');
});
}
};

View File

@ -2,7 +2,7 @@
<div <div
v-if="form" v-if="form"
class="open-complete-form" class="open-complete-form"
:style="{ '--font-family': form.font_family }" :style="{ '--font-family': form.font_family, 'direction': form?.layout_rtl ? 'rtl' : 'ltr' }"
> >
<link <link
v-if="adminPreview && form.font_family" v-if="adminPreview && form.font_family"

View File

@ -114,6 +114,14 @@
help="Useful when embedding your form" help="Useful when embedding your form"
/> />
<ToggleSwitchInput
name="layout_rtl"
:form="form"
class="mt-4"
label="Right-to-Left Layout"
help="Adjusts form layout for right-to-left languages."
/>
<EditorSectionHeader <EditorSectionHeader
icon="heroicons:tag-16-solid" icon="heroicons:tag-16-solid"
title="Branding & Media" title="Branding & Media"
@ -128,7 +136,8 @@
<image-input <image-input
name="cover_picture" name="cover_picture"
:form="form" :form="form"
label="Color (for buttons & inputs border)" label="Color image"
help="Not visible when form is embedded"
/> />
<toggle-switch-input <toggle-switch-input
name="hide_title" name="hide_title"

View File

@ -71,12 +71,13 @@
v-if="form.logo_picture" v-if="form.logo_picture"
class="w-full mx-auto py-5 relative" class="w-full mx-auto py-5 relative"
:class="{'pt-20':!form.cover_picture, 'max-w-lg': form && (form.width === 'centered'),'px-7': !isExpanded, 'px-3': isExpanded}" :class="{'pt-20':!form.cover_picture, 'max-w-lg': form && (form.width === 'centered'),'px-7': !isExpanded, 'px-3': isExpanded}"
:style="{ 'direction': form?.layout_rtl ? 'rtl' : 'ltr' }"
> >
<img <img
alt="Logo Picture" alt="Logo Picture"
:src="coverPictureSrc(form.logo_picture)" :src="coverPictureSrc(form.logo_picture)"
:class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}" :class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
class="max-w-60 h-20 object-contain absolute left-5 transition-all" class="max-w-60 h-20 object-contain absolute transition-all"
> >
</div> </div>
</div> </div>

View File

@ -13,6 +13,7 @@ export const initForm = (defaultValue = {}, withDefaultProperties = false) => {
font_family: null, font_family: null,
theme: "default", theme: "default",
width: "centered", width: "centered",
layout_rtl: false,
dark_mode: "auto", dark_mode: "auto",
color: DEFAULT_COLOR, color: DEFAULT_COLOR,
hide_title: false, hide_title: false,

View File

@ -20,12 +20,13 @@
v-if="form.logo_picture" v-if="form.logo_picture"
class="w-full p-5 relative mx-auto" class="w-full p-5 relative mx-auto"
:class="{'pt-20':!form.cover_picture, 'md:w-3/5 lg:w-1/2 md:max-w-2xl': form.width === 'centered', 'max-w-7xl': (form.width === 'full' && !isIframe) }" :class="{'pt-20':!form.cover_picture, 'md:w-3/5 lg:w-1/2 md:max-w-2xl': form.width === 'centered', 'max-w-7xl': (form.width === 'full' && !isIframe) }"
:style="{ 'direction': form?.layout_rtl ? 'rtl' : 'ltr' }"
> >
<img <img
alt="Logo Picture" alt="Logo Picture"
:src="form.logo_picture" :src="form.logo_picture"
:class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}" :class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
class="w-20 h-20 object-contain absolute left-5 transition-all" class="w-20 h-20 object-contain absolute transition-all"
> >
</div> </div>
</div> </div>