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

router.configureLink #6

Open
lindelwa122 opened this issue Sep 28, 2023 · 1 comment
Open

router.configureLink #6

lindelwa122 opened this issue Sep 28, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers to do Feature is required

Comments

@lindelwa122
Copy link
Owner

router.configureLink

router

The router module is responsible for registering routes, linking pages, and configuring URLs.

configureLink

Parameters/Input:

  • linkInfo: object

The configureLink() function expects an object containing specific information about the element intended to act as a link, and it adds a click event listener to it. Here's the expected object structure:

{
    name: "navigation",
    to: "home",
    host: ".sidebar",
    element: HTMLElement
}

All the properties mentioned above are required, except for host. host is a selector that determines where to (in this case, 'home') should be rendered. If host is not provided, the function should append the contents inside #root. The to property should be a valid id corresponding to objects stored in a private array within router called pages. If these constraints are not met, the function should throw an error.

The router should maintain a private array to keep track of all the links, and configureLink() should push the linkInfo object into this array after validation.

The function should then create a click event listener that, when triggered, finds a page with an id matching the value of linkInfo.to. It should use domManager(page, host) to create the element. After creating the element, the function should invoke activateLink() and deactivateLinks() with linkInfo.name as a parameter. deactivateLinks() should be invoked first.

@lindelwa122 lindelwa122 added enhancement New feature or request good first issue Good for newcomers to do Feature is required labels Sep 28, 2023
@dipesh2508
Copy link
Contributor

raised a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers to do Feature is required
Projects
None yet
Development

No branches or pull requests

2 participants