HomeWiki
HomeWiki
  1. Components
  • Back to home
  • 1. Themes
  • Layout
    • New Layout
    • Legacy Layout
  • Components
    • Announcement
    • Banner Carousel
    • Banner With Products Carousel
    • Blog Category List
    • Blog List
    • Brand List
    • Brands Carousel
    • Breadcrumb
    • Call To Action
    • Cart
    • Categories List
    • Change Password
    • Checkout
    • Cookie Manager
    • Filter list
    • Footer
    • Forgot Password
    • Form
    • Hero Carousel
    • Icon Block
    • Invitation
    • Last Visited Products
    • Layout
    • Login
    • Map
    • Nav Bar
    • Offer
    • Product Attachments
    • Product Attributes
    • Product Documentation
    • Product Expected
    • Product Modal
    • Products Block
    • Products Carousel
    • Product Single
    • Profile
    • Quote
    • Register
    • Related Products
    • Search
    • Stores
    • Subscribe Newsletter
    • Text with Image
    • Top Bar
    • Video
  • Reusables
    • Getting Started
  • Assets
    • Getting Started
  • SDK
    • Products
      • _findProductsByCategory
      • _findProductsByIds
      • _findProductsByTitle
      • _findProductsByFilter
      • _findProductsByCriteria
      • _findProductsAndCalculate
      • _findProductsThenCalculate
      • _getProductAttributeSet
      • _setLastVisited
    • Categories
      • _findCategoryTreeById
      • _findCategoriesByIds
      • _findCategoryByAlias
      • _findCategoryTreeByAlias
      • _getCategoryContent
    • Collections
      • _getCollectionContent
      • _findCollectionsByIds
      • _findCollectionsByIdsThenCalculate
    • Brands
      • _getBrandContent
      • _findBrandsByIds
    • Cart
      • _addToCartMulti
      • _addToCart
      • _setCart
      • _clearCart
      • _setCartListener
      • _removeFromCart
      • _calculateCart
    • Checkout
      • _startCheckout
      • _updateCheckout
      • _completeCheckout
    • Shopping Lists
      • _getShoppingLists
      • _updateShoppingList
      • _createShoppingList
      • _deleteShoppingList
      • _getShoppingListByAlias
    • Navigation
      • _getFooterMenu
      • _getHeaderMenu
    • Users
      • _getUserById
    • Utils
      • _calculateCurrency
      • _getCurrencySymbol
      • _getCulture
      • _subscribeToNewsletter
      • _findUnitsByIds
  • Vs Code
    • Getting Started
  1. Components

Announcement

Documentation: Announcement Component#

This documentation provides a comprehensive guide on how to create a custom Announcement Component using Vue.js. The component features a modal for displaying announcements, a carousel for rotating through them, and responsive design features.

Overview#

The Announcement Component is a Vue.js component designed to display announcements within a modal. The component features a carousel for rotating through announcements and handles dynamic data loading and display based on the provided model.

Model Documentation#

The Announcement Component relies on a model object that defines the structure and behavior of the announcements. Here is a detailed explanation of the properties and structure of the model object:
Model Structure#
The model object contains the following properties:
id: String
The unique identifier for the announcement component. This ID is used to target the modal and carousel elements.
cssClass: String
Optional CSS class(es) to apply to the outer container of the announcement component. This allows for custom styling.
header: String
Optional header text to display at the top of the announcement modal. This is rendered as an <h2> element.
alignment: Number
Defines the alignment of the header text within the modal. Possible values are:
1: Align left (justify-content-start)
2: Align center (justify-content-center)
3: Align right (justify-content-end)
Example Model#
Here is an example of what the model object might look like:
{
  "id": "announcement123",
  "cssClass": "custom-announcement",
  "header": "Important Update",
  "alignment": 2
}

Component Structure#

The component consists of two main parts:
1.
HTML Template: Defines the structure and layout of the modal and carousel.
2.
JavaScript: Manages the component's data, methods, and lifecycle hooks.

HTML Template#

Here is the HTML structure of the Announcement Component:

JavaScript#

The JavaScript file contains the Vue.js component logic, including data management, methods, and lifecycle hooks:

Steps to Create Your Own Announcement Component#

1.
Set Up the Vue Component:
Define the component using Vue.component() or app.component().
Specify the HTML template using the template option.
2.
Create the Template:
Structure your HTML to include the modal and carousel for displaying announcements.
Use Vue.js directives (v-if, v-for, :class, etc.) to bind data and control rendering.
3.
Implement the JavaScript Logic:
Define props to receive data from parent components.
Use data() to initialize component state.
Implement mounted() to handle initialization and lifecycle events.
Write methods for functionality such as showing modals, initializing carousels, and fetching data.
Use updated() to handle component updates and initialize carousels.
4.
Integrate External Libraries:
Use libraries like bootstrap for modal functionality and tiny-slider (tns) for carousel functionality.
Ensure you have included these libraries in your project.
5.
Testing and Debugging:
Test the component thoroughly in different scenarios to ensure it works as expected.
Debug any issues related to data binding, component rendering, or external libraries.
6.
Deploy the Component:
Once tested, deploy the component as part of your Vue.js application.
This guide provides a template for creating a custom Announcement component in Vue.js. Customize the HTML and JavaScript according to your specific requirements and integrate any additional features as needed.
Previous
Legacy Layout
Next
Banner Carousel
Built with