Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@justeat/f-mega-modal

justeat338Apache-2.07.7.1

Fozzie Mega Modal – A Vue.js modal component

fozzie

readme

f-mega-modal

Fozzie Bear

A Vue.js modal component


npm version CircleCI


Usage

Installation

Install the module using NPM or Yarn:

yarn add @justeat/f-mega-modal
npm install @justeat/f-mega-modal

The package also has dependencies that need to be installed by consuming components/applications:

Dependency Command to install Styles to include
f-button yarn add @justeat/f-button import '@justeat/f-button/dist/f-button.css';

Vue Applications

You can import it in your Vue SFC like this (please note that styles have to be imported separately):

import MegaModal from '@justeat/f-mega-modal';
import '@justeat/f-mega-modal/dist/f-mega-modal.css';

export default {
    components: {
        MegaModal
    }
}

If you are using Webpack, you can import the component dynamically to separate the mega-modal bundle from the main bundle.client.js:

import '@justeat/f-mega-modal/dist/f-mega-modal.css';

export default {
    components: {
// …
        MegaModal: () => import(/* webpackChunkName: "mega-modal" */ '@justeat/f-mega-modal')
    }
}

Non-Vue Applications

This module can be ran as a micro front-end for applications that don't make use of the Vue framework.

The following rudimentary example can be used as a guide for implementing this component in an existing static application:

<!doctype html>
<html lang="en">
<head>
    <title>Mega Modal Example</title>
    <link rel="stylesheet" href="https://unpkg.com/@justeat/f-mega-modal/dist/f-mega-modal.css">
</head>
<body>
    <div data-app>
        <mega-modal is-open>
          <p>Modal content</p>
        </mega-modal>
    </div>
    <script src="https://unpkg.com/vue@2.6.11/dist/vue.js"></script>
    <script src="https://unpkg.com/@justeat/f-mega-modal/dist/f-mega-modal.umd.min.js"></script>
    <script>
        (function() {
            if (typeof Vue === 'undefined') return null;

            Vue.config.devtools = false;
            Vue.config.productionTip = false;

            return new Vue({
                el: '[data-app]'
            });
        })();
    </script>
</body>
</html>

Configuration

Props

f-mega-modal has a number of props that allow you to customise its functionality.

The props that can be defined are as follows:

Prop Type Default Description
is-open Boolean false Sets the modal to open or closed state.
is-narrow Boolean false Use the narrow visual style.
is-wide Boolean false Use the wide visual style.
is-flush Boolean false Removes passing around the modal content.
is-full-height Boolean false Sets the modal content to full height of the screen.

Note this only applies to small screen devices.
is-scrollable Boolean false Makes the modal content scrollable.
is-close-fixed Boolean false Sets the modal close button position to fixed.
is-positioned-bottom Boolean false Sets the modal position to the bottom of the viewport for all screen widths.
has-overlay Boolean true Controls whether or not to display an overlay behind the modal.
close-button-style String cross Controls the style of the button. Accepts cross & chevron.
close-on-blur Boolean true Controls whether or not to close the modal when the user clicks outside of the modal.
close-button-copy String "Close modal" Sets the hidden text value for the close button which is used by screen-readers.
title String '' When set, will add a title to the top of the component. If you need to define a custom heading, ignore this prop.
titleHtmlTag String h3 Sets the tag for the component's title.

Allowed values are h1, h2, h3, and h4
isModeRightToLeft Boolean false Controls whether or not to display the modal elements in a right to left direction.

CSS Classes

The modal has its own styles which are scoped to the component using CSS modules to prevent conflicts with existing styles on the page.

In addition to this, the modal exposes some classes which you can target in your application.

Class Description
c-megaModal Can be used to target the modal wrapper element.
c-megaModal-content Can be used to target the modal content element.
c-megaModal-content--visible Can be used to target the modal content element when it is visible.
c-megaModal-document Can be used to target the modal document element.
c-megaModal-document--scrollable Can be used to target the modal document element when it is scrollable.
c-megaModal-closeBtn Can be used to target the modal close button element.

The modal is also using utility css styles from fozzie package. You need to make sure to @include trumps-utilities(); mixin to your application styles if you use beta version of fozzie package (>= v5.0.0-beta.0). If you are using main version (v4.X.X) styles should come out of the box.

Events

Event Description
open This event is emitted when the modal is opened.
close This event is emitted when the modal is closed.

You can add event listeners for these like so

<template>
  <mega-modal
    @open="onModalOpen"
    @close="onModalClose">
    <p>Modal content</p>
  </mega-modal>
</template>

<script>
export default {
  methods: {
    onModalOpen () {
      // Do stuff here
    },

    onModalClose () {
      // Do stuff here
    }
  }
}
</script>

Development

Start by cloning the repository and installing the required dependencies:

$ git clone git@github.com:justeat/fozzie-components.git
$ cd fozzie-components
$ yarn

Change directory to the f-mega-modal package:

$ cd packages/components/molecules/f-mega-modal

Testing

Unit, Integration and Contract

To test all components, run from root directory. To test only f-form-field, run from the ./fozzie-components/packages/f-form-field directory.

yarn test

Running storybook

Storybook can be used to develop new and existing components.

To start storybook:

From the root directory run:

$ yarn storybook:serve

This will build and serve storybook at http://localhost:6006.

changelog

Changelog

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v7.7.1

April 29, 2024

Changed

  • Bump @vue/cli-plugin-babel from v5.0.0 to v5.0.8

v7.7.0

March 13, 2024

Changed

  • node engines in package.json to include all versions above 14
  • @vue/cli-plugin-babel to 5.0.0 to resolve snyk vulnerability

Added

  • node engines 18 and 20 to package.json

v7.6.0

August 8, 2023

Added

  • position: fixed; to modal to allow z-index to apply.

v7.5.0

June 13, 2023

Changed

  • Upgraded @justeat/f-button to v5.x

v7.4.1

April 28, 2023

Fixed

  • Linting warning.

v7.4.0

April 12, 2023

Added

  • Prop closeButtonStyle allows either a chevron icon chevron-left-icon or close icon close-small-icon to be used.
  • isModeRightToLeft prop to allow a chevron icon to be used in a right to left tenant.

v7.3.0

March 27, 2023

Changed

  • Handle new focus styles from fozzie v11.
    • Button positioning was specified as 'relative' by default and needed overriding in some scenarios.
  • Updated to the new pie-icons-vue beta release.

v7.2.1

August 31, 2022

Fixed

  • Flush styles

v7.2.0

July 19, 2022

Added

  • Node 16 support.

v7.1.0

July 5, 2022

Changed

  • Update f-wdio-utils to v1.1.0
  • Update component objects / specs to use ES6 syntax.

v7.0.0

June 24, 2022

Changed

  • peerDependency versions to use new major version.
  • devDependency version range to match peerDependencies.

v6.0.0

June 20, 2022

Changed

  • Update to @use and @forward SASS syntax

v5.1.1

June 9, 2022

Changed

  • Bumped wdio version and fixed breaking changes.

May 26, 2022

Changed

  • Refactor WebDriverIO tests to use async in order to support Node 16 using codemod utility.

v5.1.0

May 13, 2022

Changed

  • Icons in component

Removed

  • @justeat/f-vue-icons

Added

  • @justeattakeaway/pie-icons-vue

v5.0.0

April 11, 2022

Added

  • isTextAlignedCenter prop - this allows modal content to be center aligned (previously aligned center by default)

Changed

  • Modal content is now left aligned by default
  • Modal title and close button now sit on the same line, and the close button sites on the baseline when the title breaks to multiple lines
  • Close button inset positioning changed to stay in-line with the first line of title
  • Increased modal widths by 10%
  • Changed close button icon color to $color-interactive-primary

v4.2.0

February 11, 2022

Changed

  • box-shadow values to use the elevation token from the pie-design-tokens.

v4.1.0

February 2, 2022

Changed

  • f-button version.

v4.0.2

January 20, 2022

Added

  • prop and computed property added for ariaLabel in MegaModal.vue

v4.0.1

January 19, 2022

Added

  • aria-labelledBy to MegaModal.vue to remove violations in storybook

v4.0.0

November 26, 2021

Added

  • Breaking Change: Added f-button dependency to peer dependencies. Now f-button should be included as a dependency of the consuming componet or application.

Removed

  • Breaking Change: Removed f-button styles import from the component. Make sure to import f-button styles in your application.

v3.0.2

October 15, 2021

Republish to fix a bad previous publish.

v3.0.1

October 14, 2021

Changed

  • Updated version of f-button.

v3.0.0

October 5, 2021

Changed

  • Updated version of f-button.
  • New border radius from pie-design-tokens in line with icing phase 2.
  • Close button type from ghostTertiary to iverse.

v2.0.0

September 16, 2021

Changed

  • Updated version of f-button.

Removed

  • Normalise styles from the build. Note that now if consuming application doesn't have normalised (reset) styles, there may be some slight style differences after this update. If the consuming application uses fozzie, there shouldn't be any style differences as normalised styles should be added as part of the fozzie import.

v1.0.0

September 15, 2021

  • Return beta to master. Component has JETSansDigital font.

v1.0.0-beta.0

September 1, 2021

Changed

  • Updated version of f-button (JETSans Update)

v0.12.1

September 1, 2021

Changed

  • Fixed bug where scrolling is not re-enabled if the modal is destroyed while open for whatever reason.

v0.12.0

August 18, 2021

Changed

  • Aligned to PIE designs
  • Updated version of f-button.

v0.11.0

July 14, 2021

Changed

  • Updated version of f-button.
  • Close button now uses type ghostTertiary.

v0.10.0

May 25, 2021

Changed

  • CSS variables to use pie design tokens instead of fozzie-colour-palette vars

v0.9.0

May 19, 2021

Added

  • title and titleHtmlTag props to allow passing the title value so that we can control the default display of the title inside the component
  • Unit tests

v0.8.0

May 6, 2021

Removed

  • u-overlay css style definition as should come from fozzie

v0.7.0

May 5, 2021

Added

  • isPositionedBottom prop to allow modal to sit at the bottom of the screen for all screen widths.

v0.6.0

March 5, 2021

Changed

  • Updated npm dependencies.

v0.5.0

March 3, 2021

Added

  • Added component test file, component object file and tests
  • Added Data-test-id to elements within the MegaModal.stories.js

Changed

  • Restructured component object into page object model
  • Refactored component and accessibility tests

v0.4.0

January 28, 2021

Changed

  • Updated config for latest sass-loader.
  • Switches import in common.scss in line with fozzie v5-beta.
  • Updated npm dependencies.

Fixed

  • Readme component reference.

v0.3.0

December 9, 2020

Added

  • Stylelint added to lint styling on build.
  • f-vue-icons to use cross icon in the modal

Changed

  • 'jet' theme instead of 'je'
  • Regular close button changed to button component

Removed

  • Bracket in Storybook file
  • Hardcoded buttons from storybook file

v0.2.0

August 6, 2020

Added

  • CSS classes which can be targeted in a consuming application..

Changed

  • Tidied up close button styles.
  • Use Fozzie colour aliases where possible.

Fixed

  • Spelling mistaxe.
  • Moved config comment to correct prop.

v0.1.0

August 5, 2020

Added

  • Component structure and basic configuration (created using generator-component).
  • Component markup and core functionality.
  • Storybook config.
  • Unit tests.
  • Readme content.