-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
772 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/presentation/ui/component/form/checkboxInputSwitchToggle.templ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package componentForm | ||
|
||
// Note: "bindModelPath" may be an array (in which case the "customValue" will be | ||
// pushed into the array) OR "bindModelPath" may be just a boolean state (in which | ||
// case the "customValue" is not necessary and will be ignored). | ||
templ CheckboxInputSwitchToggle(id, label, bindModelPath, customValue string) { | ||
<!-- CheckboxInputSwitchToggle --> | ||
<label class="inline-flex cursor-pointer items-center"> | ||
<input | ||
type="checkbox" | ||
name={ id } | ||
x-model={ bindModelPath } | ||
if customValue != "" { | ||
value={ customValue } | ||
} | ||
class="peer sr-only" | ||
/> | ||
<div class="peer-checked:bg-speedia-500 bg-os-100 peer relative h-6 w-11 rounded-full after:absolute after:start-[2px] after:top-0.5 after:h-5 after:w-5 after:rounded-full after:border after:bg-white after:transition-all after:content-[''] peer-checked:after:translate-x-full peer-checked:after:border-white"></div> | ||
<span class="ml-2 text-sm text-neutral-100">{ label }</span> | ||
</label> | ||
} |
60 changes: 60 additions & 0 deletions
60
src/presentation/ui/component/form/fileUploadTextInputFileContentReader.templ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package componentForm | ||
|
||
script FileUploadTextInputFileContentReaderLocalState() { | ||
document.addEventListener('alpine:init', () => { | ||
Alpine.data('fileUploadTextInputFileContentReader', () => ({ | ||
uploadedFileName: '', | ||
get uploadedFileNameLabel() { | ||
if (this.uploadedFileName == '') { | ||
return 'No file chosen'; | ||
} | ||
|
||
return this.uploadedFileName; | ||
}, | ||
init() { | ||
this.uploadedFileName = ''; | ||
}, | ||
handleFileUpload(event) { | ||
const inputFiles = Array.from(event.target.files); | ||
if (inputFiles.length == 0) { | ||
return; | ||
} | ||
|
||
const uploadedFile = inputFiles[0]; | ||
this.uploadedFileName = uploadedFile.name; | ||
|
||
const reader = new FileReader(); | ||
reader.onload = (event) => { | ||
this.$dispatch('file-content-readed', event.target.result); | ||
}; | ||
reader.readAsText(uploadedFile); | ||
} | ||
})); | ||
}); | ||
} | ||
|
||
templ FileUploadTextInputFileContentReader( | ||
id, label, bindValuePath, acceptAttr string, | ||
) { | ||
<!-- FileUploadTextInputFileContentReader --> | ||
@FileUploadTextInputFileContentReaderLocalState() | ||
<div class="relative w-full" x-data="fileUploadTextInputFileContentReader"> | ||
<input | ||
x-ref={ id + "FileInput" } | ||
type="file" | ||
accept={ acceptAttr } | ||
class="hidden" | ||
@change="handleFileUpload" | ||
@file-content-readed={ bindValuePath + " = $event.detail" } | ||
/> | ||
<div | ||
@click={ "$refs." + id + "fileInput.click()" } | ||
class="bg-os-300 border-os-200 hover:border-os-100 autofill:bg-os-300 focus:border-os-50 peer relative h-10 w-full cursor-default cursor-pointer rounded-md border px-3 pt-2 text-sm text-slate-400 placeholder-transparent outline-none transition-all" | ||
> | ||
<label class="cursor-pointer" x-text="uploadedFileNameLabel"></label> | ||
</div> | ||
<label class="from-os-300 via-os-300 absolute -top-2 left-1.5 cursor-text bg-gradient-to-t to-transparent to-50% px-1.5 text-xs font-bold text-neutral-50 text-opacity-80"> | ||
{ label } | ||
</label> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.