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

feat: add x-components XModal #150

Merged
merged 4 commits into from
Jul 25, 2022
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"test:unit": "vue-cli-service test:unit",
"lint": "eslint src tests build --ext .ts,.tsx,.vue,.js,.jsx",
"lint:fix": "npm run lint -- --fix",
"install:local": "npm install file:../x/packages/x-components/empathyco-x-components-3.0.0-alpha.124.tgz --no-save",
"install:local": "npm install file:../x/packages/x-components/empathyco-x-components-3.0.0-alpha.137.tgz --no-save",
"json:csv": "json-csv ./src/i18n/messages",
"csv:json": "csv-json ./output ./src/i18n/messages"
},
"dependencies": {
"@empathyco/x-adapter": "^8.0.0-alpha.3",
"@empathyco/x-components": "^3.0.0-alpha.132",
"@empathyco/x-components": "^3.0.0-alpha.137",
"@empathyco/x-adapter-platform": "^1.0.0-alpha.25",
"@empathyco/x-deep-merge": "^1.3.0-alpha.19",
"@empathyco/x-types": "^10.0.0-alpha.27",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default createConfig({
output: {
chunkFileNames: chunkInfo => {
switch (chunkInfo.name) {
case 'x-modal':
case 'custom-main-modal':
return 'x-empty-search-[hash].js';
case 'index':
return 'x-search-[hash].js';
Expand Down
11 changes: 5 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<DeviceDetector @DeviceProvided="$setLocaleDevice" :breakpoints="breakpoints" />
<Tagging />
<UrlHandler env="env" />
<XModal v-if="isOpen" :openEvents="openEvents" :closeEvents="closeEvents" />
<MainModal v-if="isOpen" />
</div>
</template>

<script lang="ts">
import { SnippetCallbacks, SnippetConfig, XEvent, XOn, XProvide } from '@empathyco/x-components';
import { SnippetCallbacks, SnippetConfig, XOn, XProvide } from '@empathyco/x-components';
import { DeviceDetector } from '@empathyco/x-components/device';
import { Tagging } from '@empathyco/x-components/tagging';
import { UrlHandler } from '@empathyco/x-components/url';
Expand All @@ -28,7 +28,7 @@
SnippetConfigExtraParams,
Tagging,
UrlHandler,
XModal: () => import('./components/x-modal.vue').then(m => m.default)
MainModal: () => import('./components/custom-main-modal.vue').then(m => m.default)
}
})
export default class Layer extends Vue {
Expand All @@ -37,10 +37,8 @@
desktop: Number.POSITIVE_INFINITY
};
protected isOpen = false;
protected openEvents: XEvent[] = ['UserOpenXProgrammatically', 'UserClickedOpenX'];
protected closeEvents: XEvent[] = ['UserClickedCloseX'];

@XOn((component: Vue) => (component as Layer).openEvents)
@XOn(['UserOpenXProgrammatically', 'UserClickedOpenX'])
open(): void {
this.isOpen = true;
}
Expand Down Expand Up @@ -100,6 +98,7 @@
width: 100%;
}
}

.x-modal__overlay {
background: var(--x-color-background-modal-overlay-default) !important;
opacity: 0.3 !important;
Expand Down
30 changes: 30 additions & 0 deletions src/components/custom-main-modal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<MainModal :animation="animation" :class="$x.device === 'mobile' ? 'x-mobile' : 'x-desktop'">
<Mobile v-if="$x.device === 'mobile'" />
<Desktop v-else />
</MainModal>
</template>

<script lang="ts">
import Component from 'vue-class-component';
import Vue from 'vue';
import { animateClipPath, MainModal } from '@empathyco/x-components';
import Mobile from './mobile/mobile.vue';
import Desktop from './desktop/desktop.vue';

@Component({
components: {
MainModal,
Mobile,
Desktop
}
})
export default class CustomMainModal extends Vue {
/**
* Animation to use for opening/closing the modal.
*
* @internal
*/
protected animation = animateClipPath();
}
</script>
8 changes: 4 additions & 4 deletions src/components/desktop/desktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
>
<EnvSelector />

<Close closingEvent="UserClickedCloseX" class="x-button--ghost x-padding--right-00">
<CloseMainModal class="x-button--ghost x-padding--right-00">
<CrossIcon class="x-icon--l" />
</Close>
</CloseMainModal>
</div>
</div>
</template>
Expand Down Expand Up @@ -81,7 +81,7 @@
<script lang="ts">
import {
animateTranslate,
BaseEventsModalClose,
CloseMainModal,
BaseIdModal,
BaseVariableColumnGrid,
CartIcon,
Expand Down Expand Up @@ -111,7 +111,7 @@
BaseVariableColumnGrid,
BaseIdModal,
CartIcon,
Close: BaseEventsModalClose,
CloseMainModal,
CrossIcon,
CrossTinyIcon,
DesktopToolbar,
Expand Down
9 changes: 4 additions & 5 deletions src/components/mobile/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
x-background--neutral-100
"
>
<Close
closingEvent="UserClickedCloseX"
<CloseMainModal
class="x-button--ghost x-padding--left-00"
:class="{ 'x-padding--right-03': $x.device === 'mobile' }"
>
<ArrowLeftIcon class="x-icon--l" />
</Close>
</CloseMainModal>
<SearchBox class="x-list__item--expand" />
</div>
</template>
Expand Down Expand Up @@ -84,7 +83,7 @@
import {
ArrowLeftIcon,
BaseColumnPickerList,
BaseEventsModalClose,
CloseMainModal,
BaseIdModalOpen,
BaseScroll,
FiltersIcon,
Expand Down Expand Up @@ -112,7 +111,7 @@
BaseIdModal,
BaseIdModalOpen,
BaseScroll,
Close: BaseEventsModalClose,
CloseMainModal,
ColumnPicker: BaseColumnPickerList,
FiltersIcon,
LocationProvider,
Expand Down
52 changes: 0 additions & 52 deletions src/components/x-modal.vue

This file was deleted.