Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added examples for usage of files/pictures in forms #1039

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
position: relative;
width: 100%;
background-color: var(--fieldset-background);
max-width: calc(100% - 1em);
height: calc(100% - 1em);
}
label{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,22 @@ svg {

.full-form-width{
grid-column: 1 / -1;
}

.filename{
display: flex;
gap: 1rem;
align-items: center;
}

.profile-pic{
display: flex;
flex-direction: column;
gap: 1rem;
dnn-button {
margin: 0 auto;
}
img {
max-width: 100%;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { Component, Host, h } from '@stencil/core';
import { Component, Host, h, State } from '@stencil/core';

/** Do not use this component in production, it is meant for testing purposes only and is not distributed in the production package. */
@Component({
tag: 'dnn-example-form',
styleUrl: 'dnn-example-form.scss',
})
export class DnnExampleForm {
@State() resume: File;
@State() profilePicData: string;
@State() profilePicConfirmed = false;

private fieldset: HTMLDnnFieldsetElement;

private resumeDropped(detail: File[]): void {
var singleFile = detail[0];
this.resume = singleFile;
}

private profilePicCropped(imageData: string): void {
this.profilePicData = imageData;
}

render() {
return (
<Host>
Expand Down Expand Up @@ -165,14 +178,43 @@ export class DnnExampleForm {
Subscribe to our newsletter
<dnn-toggle name="subscribe"/>
</label>
<label class="vertical">
Your Resume
<dnn-dropzone name="resume" />
</label>
<label class="vertical">
Your profile Picture
<dnn-image-cropper name="profilePic" />
</label>
<dnn-fieldset label="Your Resume">
{this.resume === undefined &&
<dnn-dropzone name="resume" onFilesSelected={e => this.resumeDropped(e.detail)} />
}
{this.resume &&
<p class="filename">
File: {this.resume.name}
<dnn-button type="danger" onClick={() => this.resume = undefined}>Remove</dnn-button>
</p>
}
</dnn-fieldset>
<dnn-fieldset label="Your profile Picture">
<div class="profile-pic">
{this.profilePicConfirmed === false &&
<dnn-image-cropper name="profilePic" onImageCropChanged={e => this.profilePicCropped(e.detail)}/>
}
{this.profilePicConfirmed === false && this.profilePicData != undefined &&
<dnn-button onClick={() => this.profilePicConfirmed = true}>Confirm Crop</dnn-button>
}
{this.profilePicConfirmed &&
[
<img src={this.profilePicData} alt="Profile Picture" />
,
<dnn-button type="danger"
onClick={
() => {
this.profilePicData = undefined;
this.profilePicConfirmed = false;
}
}
>
Remove
</dnn-button>
]
}
</div>
</dnn-fieldset>
<label class="vertical">
Some code
<dnn-monaco-editor name="code" value="<p>Some html</p>" />
Expand All @@ -191,5 +233,4 @@ export class DnnExampleForm {
</Host>
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Do not use this component in production, it is meant for testing purposes only a
- [dnn-textarea](../../dnn-textarea)
- [dnn-toggle](../../dnn-toggle)
- [dnn-dropzone](../../dnn-dropzone)
- [dnn-button](../../dnn-button)
- [dnn-image-cropper](../../dnn-image-cropper)
- [dnn-monaco-editor](../../dnn-monaco-editor)
- [dnn-richtext](../../dnn-richtext)
- [dnn-button](../../dnn-button)

### Graph
```mermaid
Expand All @@ -37,10 +37,10 @@ graph TD;
dnn-example-form --> dnn-textarea
dnn-example-form --> dnn-toggle
dnn-example-form --> dnn-dropzone
dnn-example-form --> dnn-button
dnn-example-form --> dnn-image-cropper
dnn-example-form --> dnn-monaco-editor
dnn-example-form --> dnn-richtext
dnn-example-form --> dnn-button
dnn-input --> dnn-fieldset
dnn-color-input --> dnn-fieldset
dnn-color-input --> dnn-modal
Expand Down
Loading