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
import { Component, Prop } from '@stencil/core'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) | |
export class MyComponent { | |
@Prop({mutable: true}) isActive = false; |
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
<!DOCTYPE html> | |
<html dir="ltr" lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"> | |
<title>Stencil Component Starter</title> | |
<script src="/build/mycomponent.js"></script> | |
</head> |
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
<!DOCTYPE html> | |
<html dir="ltr" lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"> | |
<title>Stencil Component Starter</title> | |
<script src="/build/mycomponent.js"></script> | |
<script> | |
document.addEventListener('onUploadCompleted', (e) => console.log(e)); | |
</script> |
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
import { Component, Element, Event, EventEmitter } from '@stencil/core'; | |
const MAX_UPLOAD_SIZE = 1024; // bytes | |
const ALLOWED_FILE_TYPES = 'image.*'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) |
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
import { Component, Element } from '@stencil/core'; | |
const MAX_UPLOAD_SIZE = 1024; // bytes | |
const ALLOWED_FILE_TYPES = 'image.*'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) |
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
import { Component } from '@stencil/core'; | |
const MAX_UPLOAD_SIZE = 1024; // bytes | |
const ALLOWED_FILE_TYPES = 'image.*'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) |
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
import { Component } from '@stencil/core'; | |
const MAX_UPLOAD_SIZE = 1024; // bytes | |
const ALLOWED_FILE_TYPES = 'image.*'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) |
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
import { Component} from '@stencil/core'; | |
@Component({ | |
tag: 'my-component', | |
styleUrl: 'my-component.css', | |
shadow: true | |
}) | |
export class MyComponent { | |
public onInputChange(files: FileList) { | |
// check if 1 image is uploaded |
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
.image-upload { | |
position: relative; | |
max-width: 205px; | |
margin: 50px auto; | |
} | |
.image-upload__edit { | |
position: absolute; | |
top: 10px; | |
right: 12px; |
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
render() { | |
return <div class="image-upload"> | |
<div class="image-upload__edit"> | |
<label htmlFor="file"></label> | |
<input type="file" name="files[]" id="file" accept="image/*" class="image-upload__input" | |
onChange={($event: any) => this.onInputChange($event.target.files)} /> | |
</div> | |
<div class="image-upload__preview"> | |
<div id="image-preview"></div> |