Skip to content

Commit e9dceba

Browse files
authoredMay 17, 2024
feat: Allow to hide the file picker button (#130)
1 parent cffe661 commit e9dceba

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed
 

‎src/components.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ export namespace Components {
1717
"facingMode": string;
1818
"handleNoDeviceError": (e?: any) => void;
1919
"handlePhoto": (photo: Blob) => void;
20+
"hidePicker": boolean;
2021
"noDevicesButtonText": string;
2122
"noDevicesText": string;
2223
}
2324
interface PwaCameraModal {
2425
"dismiss": () => Promise<void>;
2526
"facingMode": string;
27+
"hidePicker": boolean;
2628
"present": () => Promise<void>;
2729
}
2830
interface PwaCameraModalInstance {
2931
"facingMode": string;
32+
"hidePicker": boolean;
3033
"noDevicesButtonText": string;
3134
"noDevicesText": string;
3235
}
@@ -97,16 +100,19 @@ declare namespace LocalJSX {
97100
"facingMode"?: string;
98101
"handleNoDeviceError"?: (e?: any) => void;
99102
"handlePhoto"?: (photo: Blob) => void;
103+
"hidePicker"?: boolean;
100104
"noDevicesButtonText"?: string;
101105
"noDevicesText"?: string;
102106
}
103107
interface PwaCameraModal {
104108
"facingMode"?: string;
109+
"hidePicker"?: boolean;
105110
"onNoDeviceError"?: (event: PwaCameraModalCustomEvent<any>) => void;
106111
"onOnPhoto"?: (event: PwaCameraModalCustomEvent<any>) => void;
107112
}
108113
interface PwaCameraModalInstance {
109114
"facingMode"?: string;
115+
"hidePicker"?: boolean;
110116
"noDevicesButtonText"?: string;
111117
"noDevicesText"?: string;
112118
"onNoDeviceError"?: (event: PwaCameraModalInstanceCustomEvent<any>) => void;

‎src/components/camera-modal/camera-modal-instance.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class PWACameraModal {
1010
@Event() onPhoto: EventEmitter;
1111
@Event() noDeviceError: EventEmitter;
1212
@Prop() facingMode: string = 'user';
13+
@Prop() hidePicker: boolean = false;
1314
@Prop() noDevicesText = 'No camera found';
1415
@Prop() noDevicesButtonText = 'Choose image';
1516

@@ -45,6 +46,7 @@ export class PWACameraModal {
4546
<pwa-camera
4647
onClick={e => this.handleComponentClick(e)}
4748
facingMode={this.facingMode}
49+
hidePicker={this.hidePicker}
4850
handlePhoto={this.handlePhoto}
4951
handleNoDeviceError={this.handleNoDeviceError}
5052
noDevicesButtonText={this.noDevicesButtonText}

‎src/components/camera-modal/camera-modal.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { h, Event, EventEmitter, Component, Method, Prop } from '@stencil/core';
77
})
88
export class PWACameraModal {
99
@Prop() facingMode: string = 'user';
10+
@Prop() hidePicker: boolean = false;
1011

1112
@Event() onPhoto: EventEmitter;
1213
@Event() noDeviceError: EventEmitter;
@@ -17,6 +18,7 @@ export class PWACameraModal {
1718
async present() {
1819
const camera = document.createElement('pwa-camera-modal-instance');
1920
camera.facingMode = this.facingMode;
21+
camera.hidePicker = this.hidePicker;
2022

2123
camera.addEventListener('onPhoto', async (e: any) => {
2224
if (!this._modal) {

‎src/components/camera/camera.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class CameraPWA {
1818
@Prop() facingMode: string = 'user';
1919

2020
@Prop() handlePhoto: (photo: Blob) => void;
21+
@Prop() hidePicker: boolean = false;
2122
@Prop() handleNoDeviceError: (e?: any) => void;
2223
@Prop() noDevicesText = 'No camera found';
2324
@Prop() noDevicesButtonText = 'Choose image';
@@ -463,7 +464,7 @@ export class CameraPWA {
463464
{this.hasCamera && (
464465
<div class="camera-footer">
465466
{!this.photo ? ([
466-
<div class="pick-image" onClick={this.handlePickFile}>
467+
!this.hidePicker && (<div class="pick-image" onClick={this.handlePickFile}>
467468
<label htmlFor="_pwa-elements-file-pick">
468469
{this.iconPhotos()}
469470
</label>
@@ -473,7 +474,7 @@ export class CameraPWA {
473474
onChange={this.handleFileInputChange}
474475
accept="image/*"
475476
class="pick-image-button" />
476-
</div>,
477+
</div>),
477478
<div class="shutter" onClick={this.handleShutterClick}>
478479
<div class="shutter-button"></div>
479480
</div>,

0 commit comments

Comments
 (0)
Please sign in to comment.