Problems with user state change - firebase

I'm using SvelteKit and trying to show and hide a link for the profile page.
When I log in the link appears, but when I log out the link doesn't hide.
I don't know if I have to use the onAuthStateChanged or do something more reactive in Svelte.
I put my code inside my component navBar.svelte:
<script>
import { getAuth } from 'firebase/auth'
$: auth = getAuth()
</script>
{#if auth.currentUser}
<a sveltekit:prefetch href="/profile">
<li class="navbarListItem">
<img src="/assets/svg/RiUser3Line.svg" alt="perfil" width="36px" height="36px"/>
<p>Profile</p>
</li>
</a>
{:else}
<a sveltekit:prefetch href="/profile" style="display: none;">
<li class="navbarListItem">
<img src="/assets/svg/RiUser3Line.svg" alt="perfil" width="36px" height="36px" />
<p>Profile</p>
</li>
</a>
{/if}

Related

nuxt page switch components change css text color and url path

i have a page that able to switch component between login and register.
how do i make the text show black after selected it and switch back and fore ?
sample like this :
https://softauthor.com/toggle-button-in-vue-js/
i need each component to change page url too, the order will be like this.
clicked on login = http://localhost:3000/login
clicked on register = http://localhost:3000/register
<template>
<div>
<div class="ps-page__content">
<div class="ps-tab-root">
<div class="ps-form--auth">
<ul class="ps-tab-list">
<li v-for="tab in tabs" :key="tab">
<a #click="selected = tab">
{{tab}}
</a>
</li>
</ul>
</div>
<component :is="selected"></component>
</div>
</div>
<!-- end Account Content -->
</div>
</template>
<script>
import Login from '#/components/MyAccountLogin.vue'
import Register from '#/components/MyAccountRegister.vue'
export default {
components: {
Login,
Register
},
data() {
return {
tabs: ["Login", "Register"],
selected: "Login"
}
},
}
</script>
here is the sample : https://stackblitz.com/edit/nuxt-starter-zuq4pe?file=pages%2Findex.vue

How to keep the side bar link active when i change the tabs using angular2

i have a side bar, where in it remains active if im on the screens first tab, if i switch to second tab, the url changes and the sidebar label wont be active.
How can this be solved. Please help.
HTML:
Side bar Code:
<a routerLink="/my-health/my-health-history" [ngClass] = "{'active' : true}" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}" class="list-group-item list-group-item-action justify-content-between"
id="nav-link-1" aria-haspopup="true" aria-expanded="false" aria-controls="nav-submenu-1">
<span><i class="icon-heart g-pos-rel g-top-1 g-mr-8"></i>{{ 'DashboardModule.MYHEALTH' | translate }}
</span>
</a>
TAbs code redirected to pages on click of side bar link:
<div class="myhealth mt7">
<ul class="nav nav-tabs menu">
<li>
<a class="active-link" routerLink="/my-health/my-health-history" routerLinkActive="active-link"
[routerLinkActiveOptions]="{exact: true}">myHealthHistory
</a>
</li>
<li>
<a routerLink="/my-health/my-lifestyle" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">myLifeStyle
</a>
</li>
<li>
<a routerLink="/my-health/my-family-health-history" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">myFamilyHistory
</a>
</li>
</ul>
</div>
If i am in myHealth History tab, then side bar will be active, if i shift to other 2 tabs then side bar wont be active
Using [ngClass] = "{'active' : true}" in tag.
The condition are:
Differ your current URL based on tab change.
ex1: http://test.com/tab1 and http://test.com/tab2
ex2:http://test.com/#tab1 and http://test.com/#tab2
Read url and find string like "tab1 or tab2"
add "Active" class based on this condition
You can check for the current active link in the sidebar component.
Sidebar html
<a routerLinkActive="active-link" [ngClass]="{'active-link': isActive()}" class="list-group-item list-group-item-action justify-content-between"
id="nav-link-1" aria-haspopup="true" aria-expanded="false" aria-controls="nav-submenu-1">
<span><i class="icon-heart g-pos-rel g-top-1 g-mr-8"></i>{{ 'DashboardModule.MYHEALTH' | translate }}
</span>
</a>
Sidebar ts
constructor(private router:Router) {
}
isActive(){
return ["/my-health/my-health-history","/my-health/my-lifestyle","/my-health/my-family-health-history"].includes(this.router.url);
}
Note : the code is written directly to Stackoverflow editor so there could be typo or syntatical error. Please correct yourself.

CSS-menu issue in angular project

I am trying to add a bootstrap menu to my angular 6 project. This is the code
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#">User</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Customer</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">OL User</a>
</div>
</li>
</ul>
The issue is, when I click customer link, URL redirect to the localhost:4200/#
and submenu is not opening. below code techniques, I used to project:
app.component.ts
import {HashLocationStrategy, LocationStrategy} from '#angular/common';
app.routing.module.ts
#NgModule({
imports: [RouterModule.forRoot(routes,{useHash: true})],
exports: [RouterModule],
})
Local redirects in Angular are usually done by using routerLink:
From the DOCS
<a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
link to user component
</a>
More information about Angular routing
You can use href if you want. But the biggest issue is that you haven't associated a component with a route.
Take a look at this example

How do I fix Zurb Foundation dropdown issue on mobile devices?

Here's the code I used:
<div style="top-buttons">
<img src="images/sandwich.gif" class="sandwich" width="30" height="30">
</div>
<ul id="tinyDrop" class="f-dropdown" data-dropdown-content>
<hr>
<li class="navitem"><img src="images/group-25.png"/> Trends / Activity</li>
<hr>
<li class="navitem"><img src="images/settings2-25.png"/> Settings</li>
<hr>
<li class="navitem"><img src="images/help-25.png"/> Help</li>
<hr>
<li class="navitem"><img src="images/star-25.png"/> Rate Clustir</li>
<hr>
<li class="navitem"><img src="images/exit-25.png"/> Logout</li>
<hr>
</ul>
I also tried specifying a class (open) which is supposed to be added when the user taps/clicks the button:
<script>
$(document).foundation({
// specify the class used for active dropdowns
active_class: 'open'
});
</script>
with the following css to see if this class can even do anything. It looks like it's not even being utilized.
.open{
display:none;
}
Any ideas how I can fix this probably with jquery or a better css. I hope this is not a Foundation bug.
Are you on Foundation 5? I noticed after upgrading from 4 to 5 that you need the "data-dropdown-init" attribute on the parent element as shown below
<img src="images/sandwich.gif" class="sandwich" width="30" height="30">
Without the above modification, I see javascript errors in the console complaining about undefined properties in foundation.dropdown.js.

Link to Specific Bootstrap Tab From Another Page Wordpress

I'm using bootstrap tab shortcodes on my Wordpress site. I want to link from another page to tab2. Can anyone advise how this is done?
My page code (chopped a bit):
[bootstrap_tab name="TAB1" link="tab1-slug" active="active"]
TAB 1 Content
[/bootstrap_tab]
[bootstrap_tab name="TAB2" link="tab2-slug"]
More content
[/bootstrap_tab]
[bootstrap_tab name="TAB3" link="tab3-slug"]
Yep. Even more content.
[/bootstrap_tab]
[bootstrap_tab name="TAB4" link="tab4-slug"]
Yep. Even more content.
[/bootstrap_tab]
[end_bootstrap_tab]
The code it produces:
<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
<li class="tabs active">
<a data-toggle="tab" href="#tab1-slug">TAB1</a>
</li>
<li class="tabs ">
<a data-toggle="tab" href="#tab2-slug">TAB2</a>
</li>
<li class="tabs ">
<a data-toggle="tab" href="#tab3-slug">TAB3</a>
</li>
<li class="tabs ">
<a data-toggle="tab" href="#tab4-slug">TAB4</a>
</li>
</ul>
<div id="my-tab-content" class="tab-content">
<div id="tab1-slug" class="tab-pane active">
<p></p>
<h2>header</h2>
<p><strong>bold</strong></p>
<p>content</p>
<p></p>
</div>
<div id="tab2-slug" class="tab-pane ">
<p></p>
<h2>TAB2</h2>
<p><strong>These are usually two day</strong></p>
</div>
<div id="tab3-slug" class="tab-pane ">
<p></p>
<h2>TAB3</h2>
<p>1 to 2 day events</p><p></p>
</div>
<div id="tab4-slug" class="tab-pane ">
<p>
<h2>TAB4</h2>
<p><strong>5 to 10 day courses</strong></p>
</div>
</div>
Though not in WordPress, this seems to be the definitive solution to linking to Bootstrap tabs:
Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink
That being said, I wrote a WordPress plugin that will do this. Activate the plugin, then you'll be able to use the tab's href as the hash.
If your tab looks like this:
<li>Profile</li>
You can link to it and activate/open it using a link like this:
Link to my tab
The plugin will also allow you to link directly to content on the tabs, using a sort of a two-step link:
Step 1 Activate the proper tab
Step 2 Scroll to the content on the tab.
It does this using only a single hash in the URL.
For example: http://www.example.com/mypage/#content
This will take you to "mypage" and the HTML element with id="content", whether it's on an active/inactive Bootstrap tab or just on the page somewhere.
Hope this helps:
Here's the plugin on GitHub: https://github.com/marinersmuseum/WP-Tab-Anchors/blob/master/wp-tab-anchors.zip
Supposing that jQuery is being loaded and that the link URL is something like
http://example.com/page-with-tabs/?tab=NUMBER
We print some conditional script at the footer:
add_action( 'wp_footer', 'active_tab_so_19576232' );
function active_tab_so_19576232()
{
# Query var not set in URL, bail out
if( !isset( $_GET['tab'] ) )
return;
# Change the active tab
$tab = '#tab'. $_GET['tab'] .'-slug';
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('div.tab-pane.active').removeClass('active');
$('<?php echo $tab; ?>').addClass('active');
});
</script>
<?php
}
Should be a plugin, but you can drop the code in your theme functions.php.

Resources