Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit dad8185

Browse files
jfnadeausimardo
authored andcommitted
File Uploader (#80)
* file-select * $file * file-upload * progress * file-drop * drag-drop zone vector * filesize dependency * spec to jest * file extension to method * Add error message under the progress bar * visual hint after file is completed * remove setTimeout * translation filesize * file-upload spec * extract file mocking utils * Style modifications * update shapshot * meta: support optional prop * line break * extra typing * extension - convert to getter * Typing getters * update package-lock (to resolve conflict)
1 parent 85be464 commit dad8185

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3308
-432
lines changed

package-lock.json

Lines changed: 618 additions & 408 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"css-loader": "^0.28.7",
6262
"enquire.js": "^2.1.6",
6363
"file-loader": "^1.1.5",
64+
"filesize": "^3.6.0",
6465
"moment": "^2.19.3",
6566
"node-sass": "^4.7.2",
6667
"popper.js": "^1.12.9",
@@ -76,9 +77,11 @@
7677
},
7778
"devDependencies": {
7879
"@types/es6-promise": "^0.0.33",
80+
"@types/filesize": "^3.6.0",
7981
"@types/jest": "^22.1.1",
8082
"@types/node": "^8.0.54",
8183
"@vue/test-utils": "^1.0.0-beta.11",
84+
"ajv": "^6.1.1",
8285
"awesome-typescript-loader": "^3.4.1",
8386
"axios": "^0.17.1",
8487
"bundle-loader": "^0.5.5",
@@ -90,6 +93,7 @@
9093
"enquire.js": "^2.1.6",
9194
"es6-promise": "^4.1.1",
9295
"file-loader": "^1.1.5",
96+
"filesize": "^3.6.0",
9397
"html-webpack-plugin": "^2.30.1",
9498
"jest": "^22.1.4",
9599
"jest-junit": "^3.6.0",

src/assets/icons/sprites-default.svg

Lines changed: 38 additions & 0 deletions
Loading

src/components/component-names.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const DROPDOWN_NAME: string = 'm-dropdown';
1313
export const DROPDOWN_ITEM_NAME: string = 'm-dropdown-item';
1414
export const DROPDOWN_GROUP_NAME: string = 'm-dropdown-group';
1515
export const DYNAMIC_TEMPLATE_NAME: string = 'm-dynamic-template';
16+
export const FILE_SELECT_NAME: string = 'm-file-select';
17+
export const FILE_UPLOAD_NAME: string = 'm-file-upload';
1618
export const EDIT_WINDOW_NAME: string = 'm-edit-window';
1719
export const FLEX_TEMPLATE_NAME: string = 'm-flex-template';
1820
export const I18N_NAME: string = 'm-i18n';
@@ -31,6 +33,7 @@ export const PANEL_NAME: string = 'm-panel';
3133
export const PHONE_NUMBER_NAME: string = 'm-phone-number';
3234
export const POPPER_NAME: string = 'm-popper';
3335
export const POPUP_NAME: string = 'm-popup';
36+
export const PROGRESS_NAME: string = 'm-progress';
3437
export const RADIO_NAME: string = 'm-radio';
3538
export const RADIO_GROUP_NAME: string = 'm-radio-group';
3639
export const RADIO_STYLE_NAME: string = 'm-radio-style';

src/components/dialog/dialog.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { ModulVue } from '../../utils/vue/vue';
21
import { PluginObject } from 'vue';
32
import Component from 'vue-class-component';
4-
import WithRender from './dialog.html?style=./dialog.scss';
53
import { Prop } from 'vue-property-decorator';
6-
import { DIALOG_NAME } from '../component-names';
7-
import { Portal, PortalMixin, PortalMixinImpl, BackdropMode, PortalTransitionDuration } from '../../mixins/portal/portal';
4+
85
import { MediaQueriesMixin } from '../../mixins/media-queries/media-queries';
6+
import { BackdropMode, Portal, PortalMixin, PortalMixinImpl, PortalTransitionDuration } from '../../mixins/portal/portal';
7+
import { ModulVue } from '../../utils/vue/vue';
8+
import { DIALOG_NAME } from '../component-names';
9+
import WithRender from './dialog.html?style=./dialog.scss';
910

1011
export enum MDialogSize {
1112
FullScreen = 'full-screen',
@@ -45,6 +46,10 @@ export class MDialog extends ModulVue implements PortalMixinImpl {
4546
@Prop({ default: true })
4647
public paddingFooter: boolean;
4748

49+
public closeDialog(): void {
50+
this.as<PortalMixin>().tryClose();
51+
}
52+
4853
public handlesFocus(): boolean {
4954
return true;
5055
}
@@ -102,10 +107,6 @@ export class MDialog extends ModulVue implements PortalMixinImpl {
102107
this.as<PortalMixin>().tryClose();
103108
}
104109
}
105-
106-
private closeDialog(): void {
107-
this.as<PortalMixin>().tryClose();
108-
}
109110
}
110111

111112
const DialogPlugin: PluginObject<any> = {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`file-select should render correctly 1`] = `
4+
<div class="m-file-select">
5+
<input type="file" id="mFileSelect-uuid" tabindex="-1" class="m-file-select__hidden">
6+
<label for="mFileSelect-uuid" class="m-file-select__hidden"><span class="m-i18n">Browse</span></label>
7+
<button type="button" aria-hidden="true" class="m-button m--is-skin-secondary"> <span class="m-button__text"><span class="m-i18n">Browse</span> </span>
8+
</button>
9+
</div>
10+
`;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="m-file-select">
2+
<input ref="inputFile" type="file" :id="id" class="m-file-select__hidden" @change="processFile" :disabled="disabled || isWaiting" tabindex="-1" :multiple="multiple">
3+
<label :for="id" class="m-file-select__hidden">
4+
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n>
5+
<template v-else>{{ label }}</template>
6+
</label>
7+
<m-button @click="onClick" @focus="onFocus" @blur="onBlur" aria-hidden="true"
8+
:skin="skin"
9+
:disabled="disabled"
10+
:waiting="waiting"
11+
:fullSize="fullSize"
12+
:iconName="iconName"
13+
:iconPosition="iconPosition"
14+
:iconSize="iconSize">
15+
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n>
16+
<template v-else>{{ label }}</template>
17+
</m-button>
18+
<m-validation-message ref="validation"
19+
:disabled="isDisabled"
20+
:error="hasError"
21+
:error-message="errorMessage"
22+
:valid-message="validMessage"
23+
:helper-message="helperMessage"></m-validation-message>
24+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"m-select-file": {
3+
"label": "Browse"
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"m-select-file": {
3+
"label": "Parcourir"
4+
}
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import 'abstracts/variables';
2+
3+
.m-file-select {
4+
&__hidden {
5+
@include m-visually-hidden;
6+
}
7+
}

0 commit comments

Comments
 (0)