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

BrandLogo Component #46

Merged
merged 1 commit into from
Jan 25, 2022
Merged

Conversation

samad-yar-khan
Copy link
Contributor

@samad-yar-khan samad-yar-khan commented Jan 23, 2022

Proposed changes (including videos or screenshots)

  • I have added the Rocket.Chat logo in the NavBar in place of the text - Rocket.Chat Community

Issue(s)

This current master branch did not have the image tag at all but this should fix the below issue aswell.
Fixes : #43

Steps to test or reproduce

Mentioned in the Issue

Before :

NoHeader

After :

ficHeader

@CLAassistant
Copy link

CLAassistant commented Jan 23, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@Sing-Li Sing-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove gitpod.yml

It should not be ommitted

Copy link
Member

@Sing-Li Sing-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hacking this into the Navbar, how about creating a totally independent navbarlogo React component that is optionally composable into Navbar, in any position, and for ANY logo and branding.

Be sure to take advantage of NextJS packing and lazy loading when crafting component.

Copy link
Member

@Sing-Li Sing-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create new component

@samad-yar-khan
Copy link
Contributor Author

Instead of hacking this into the Navbar, how about creating a totally independent navbarlogo React component that is optionally composable into Navbar, in any position, and for ANY logo and branding.

Be sure to take advantage of NextJS packing and lazy loading when crafting component.

Great Idea, I will create a new component .

@samad-yar-khan
Copy link
Contributor Author

@Sing-Li Can you look into this ? I read the docs regarding NextJS packing and lazy loading , I can incorporate the feature to only load the logo image when its viewed to increase efficiency but I don't think this would be much useful for this particular component as the navbar will always be loaded first and so will the brand logo. We can surely utilize lazy loading with some of the larger graphics components which are shown as we scroll further down. Let me know if I am thinking in the right direction :)

@@ -1,16 +1,20 @@
import { useState } from 'react';
import { Navbar, Nav, NavDropdown, Container, Col, Row } from 'react-bootstrap';
import styles from '../styles/Menubar.module.css';
import BrandLogo from './brandlogo';

export default function Menubar(props) {
const [collapsed, setCollapsed] = useState(true);

return (
<Container fluid class='border-bottom '>
<Navbar expand='lg' className=' bg-white mx-4 my-2'>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please lint your code.

.brand {
font-size: clamp(16px, 2.4vw, 20px);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra lines (lint your code)

<BrandLogo
brandLink={'#home'}
logoLink={'https://global-uploads.webflow.com/611a19b9853b7414a0f6b3f6/611bbb87319adfd903b90f24_logoRC.svg'}
imageTitle={'Rocket.chat'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rocket.Chat

@RonLek
Copy link
Collaborator

RonLek commented Jan 23, 2022

@samad-yar-khan please also squash your commits into one.

@samad-yar-khan
Copy link
Contributor Author

@RonLek Sir, I have linted my code squashed the commits into one.

@Sing-Li Sing-Li changed the title Set Header Image BrandLogo Component Jan 23, 2022
@Sing-Li
Copy link
Member

Sing-Li commented Jan 23, 2022

@Sing-Li Can you look into this ? I read the docs regarding NextJS packing and lazy loading , I can incorporate the feature to only load the logo image when its viewed to increase efficiency but I don't think this would be much useful for this particular component as the navbar will always be loaded first and so will the brand logo. We can surely utilize lazy loading with some of the larger graphics components which are shown as we scroll further down. Let me know if I am thinking in the right direction :)

I've made comment in-line. When designing a NextJS component - you need to anticipate when and where it will be used. For example, some Community Builder may have complex logo image/svg that takes minutes to render and the rest of the page where the component is used may have hundreds of other images/svgs to load. You are thinking too narrowly focused on ONLY THIS use-case with our Rocket.Chat logo/branding (and only as part of the navbar).

export default function BrandLogo(props) {
return (
<Navbar.Brand href={props.brandLink} className={styles.brand}>
<img
Copy link
Member

@Sing-Li Sing-Li Jan 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the Image component from NextJS.

@samad-yar-khan
Copy link
Contributor Author

dLink} className={styles.brand}>

I understand, looking at the broader scope it does make sense to use the lazy loading feature. I will use the component , from NextJS .I just started learning NextJS today, so didn't really know that I could use that. Thanks a lot for the suggestion 💯 and thankyou for rectifying issues in the PR. I will make the requested changes 👍

@samad-yar-khan samad-yar-khan force-pushed the Fix_header_log branch 2 times, most recently from 1fbab1b to 4efd378 Compare January 23, 2022 23:11
@samad-yar-khan
Copy link
Contributor Author

@Sing-Li I have made the BrandLogo component lazy loading such that, the logo is only fetched and displayed when we scroll over the component. I have used the following package : https://www.npmjs.com/package/react-cool-inview. Let me if there are any changes.

@@ -0,0 +1,28 @@
import dynamic from "next/dynamic";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use dynamic or inview. These are pure unnecessary baggages.

Just using <Image> will get you all the benefits as stated in its docs. Please read the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, I will remove dynamic and inview and use the properties of <Image> for optimisation

@samad-yar-khan
Copy link
Contributor Author

@Sing-Li I have removed the unnecessary code. and packages I went through the documentation and figured that by default the <Image> component is Lazy Loading, so the logo will only be fetched and loaded on view. Thankyou for the suggestion :)

@Sing-Li Sing-Li merged commit 2be69ef into RocketChat:master Jan 25, 2022
@irffanasiff
Copy link
Contributor

@samad-yar-khan i was trying to remove the warnings in the console, there was this warning which is due to brandlogo component can you please look into it
image

@samad-yar-khan
Copy link
Contributor Author

@Sing-Li Sing-Li merged commit 2be69ef into RocketChat:master on Jan 25
2 checks passed

@demonicirfan I will just look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Header logo is not loading
5 participants