Daniel Sousa @TutoDS
Daniel Sousa @TutoDS
Explore posts from servers
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Sorry bad habbits from React
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Yeah is only that
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Any idea what I'm doing wrong?
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
The problem is the colors not being updated after the scroll
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
and I have variants on the navigation, like this:
const navigatioItemVariants = cva(
[
'h-14',
'px-4',
'inline-flex items-center justify-center',
'font-semibold',
'transition ease-in-out duration-300',
'relative before:content-[""] before:w-full before:h-0.5 before:bg-transparent before:absolute before:top-0 before:inset-x-0 before:rounded-b-sm',
],
{
variants: {
isActive: {
true: [],
false: [],
},
mode: {
transparent: ['text-gray-50', 'hover:text-white hover:before:bg-white'],
solid: ['text-gray-800', 'hover:text-gray-900 hover:before:bg-gray-900'],
},
},
compoundVariants: [
{
isActive: true,
mode: 'solid',
class: ['before:bg-gray-900', 'text-gray-900'],
},
{
isActive: true,
mode: 'transparent',
class: ['before:bg-white', 'text-white'],
},
],
defaultVariants: {
isActive: false,
mode: 'transparent',
},
},
);
const navigatioItemVariants = cva(
[
'h-14',
'px-4',
'inline-flex items-center justify-center',
'font-semibold',
'transition ease-in-out duration-300',
'relative before:content-[""] before:w-full before:h-0.5 before:bg-transparent before:absolute before:top-0 before:inset-x-0 before:rounded-b-sm',
],
{
variants: {
isActive: {
true: [],
false: [],
},
mode: {
transparent: ['text-gray-50', 'hover:text-white hover:before:bg-white'],
solid: ['text-gray-800', 'hover:text-gray-900 hover:before:bg-gray-900'],
},
},
compoundVariants: [
{
isActive: true,
mode: 'solid',
class: ['before:bg-gray-900', 'text-gray-900'],
},
{
isActive: true,
mode: 'transparent',
class: ['before:bg-white', 'text-white'],
},
],
defaultVariants: {
isActive: false,
mode: 'transparent',
},
},
);
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
This is my code
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
function Header({ mode = 'transparent', className = '' }: HeaderProps) {
const scroll = useWindowScrollPosition();
const deviceType = useDeviceType();

const modeAfterScroll = createMemo(() =>
scroll.y > 100 && mode === 'transparent' ? 'solid' : mode,
);

console.log(modeAfterScroll(), '<-');

return (
<header
class={twMerge(
headerVariants({
mode: modeAfterScroll(),
class: className,
}),
)}
>
<div class={twMerge(headerContainerVariants({ mode }))}>
<a href="/" class={cn([{ 'text-white': modeAfterScroll() === 'transparent' }])}>
MC Ocidente charmoso
</a>

<Switch>
<Match when={deviceType() === 'desktop'}>
<Navigation mode={modeAfterScroll()} />
</Match>

<Match when={['mobile', 'tablet'].includes(deviceType())}>
<MobileNavigation mode={modeAfterScroll()} />
</Match>
</Switch>
</div>
</header>
);
}
function Header({ mode = 'transparent', className = '' }: HeaderProps) {
const scroll = useWindowScrollPosition();
const deviceType = useDeviceType();

const modeAfterScroll = createMemo(() =>
scroll.y > 100 && mode === 'transparent' ? 'solid' : mode,
);

console.log(modeAfterScroll(), '<-');

return (
<header
class={twMerge(
headerVariants({
mode: modeAfterScroll(),
class: className,
}),
)}
>
<div class={twMerge(headerContainerVariants({ mode }))}>
<a href="/" class={cn([{ 'text-white': modeAfterScroll() === 'transparent' }])}>
MC Ocidente charmoso
</a>

<Switch>
<Match when={deviceType() === 'desktop'}>
<Navigation mode={modeAfterScroll()} />
</Match>

<Match when={['mobile', 'tablet'].includes(deviceType())}>
<MobileNavigation mode={modeAfterScroll()} />
</Match>
</Switch>
</div>
</header>
);
}
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
No description
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Hi @peerreynders Sorry to bother you
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/24/2024 in #support
Phosphor icons
How I'm using it? 1. Install the package @phosphor-icons/web; 2. On app.tsx add the import import '@phosphor-icons/web/regular/style.css'; 3. Use like <i class="ph ph-arrow-right" />
4 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Thanks again
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
function useDeviceType() {
const size = useWindowSize();
const [deviceType, setDeviceType] = createSignal<'desktop' | 'tablet' | 'mobile'>(
'desktop',
);

createEffect(() => {
if (size.width > 480 && size.width < 1024) {
setDeviceType('tablet');
return;
}

if (size.width <= 480) {
setDeviceType('mobile');
return;
}

setDeviceType('desktop');
}, size);

return deviceType;
}
function useDeviceType() {
const size = useWindowSize();
const [deviceType, setDeviceType] = createSignal<'desktop' | 'tablet' | 'mobile'>(
'desktop',
);

createEffect(() => {
if (size.width > 480 && size.width < 1024) {
setDeviceType('tablet');
return;
}

if (size.width <= 480) {
setDeviceType('mobile');
return;
}

setDeviceType('desktop');
}, size);

return deviceType;
}
This is more to hide the header if it's a mobile or tablet device
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Thanks, I'm trying to use a primitive for window size, but it's not being easy. Probably a noob mistake
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Like: - at the beginning be transparent - after the scroll rende the header with background
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
I know that I can use sticky, but I want to change the header after the scroll
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
@peerreynders sorry for the noob question, what's the best way of doing an sticky header that change the colors? I'm new on solid, sorry about that 😦
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Thanks 🙏
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
Thanks
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/22/2024 in #support
Different header for specific routes
OK, so everytime I want a specific layout I need to create the <route>.tsx for layout and the <route>/index.tsx for the page itself
25 replies
SSolidJS
Created by Daniel Sousa @TutoDS on 6/14/2024 in #support
Solid with Sanity CMS
And sorry for the noob questions
49 replies