Telescope 1.8 Release
Tags: opensource, javascript, react, css
Published: 2021-03-13 02:10:47

Release 1.8 for telescope is quite of a special one, because GitHub was down in our scheduled release time. According to our experienced professor, this is the first time he has ever seen GitHub down like this. I assume I'm lucky to see this in my first year of open-source.

Therefore, we did the PR review through video call. It was surprisingly efficient. We fixed our PRs and tried to get them passed to 1.8 release.

---

The issue I want to talk about is [add the avatar component](https://github.com/Seneca-CDOT/telescope/pull/1911). The plan for avatar is to integrate with GitHub so that we can get users' profile picture. Before that, we still need a temporary avatar to replace the blank circle like the below picture.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n23gm0z6np4ufd6h7jvp.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlj4tkp4zm7ocstmfsfn.png)

Pedro suggested the [avatar component from evergreen](https://evergreen.segment.com/components/avatar/). But Dave wanted to stick with what we have, which is material-UI, there is also [avatar component from material-UI](https://material-ui.com/components/avatars/#avatar).

However, material-Ui avatar component only provide a circle, it doesn't generate initials with the given name value, we'll need to generate it by ourselves. Therefore, my task is to wrap the material-UI avatar component with customize functionalities.

We want to make our avatar component to accept author name or image value. Image value is preferred, but if there is no image value, we'll take name value instead, and generate the initials for the avatar.

I want to talk about how to generate initials. I checked evergreen's avatar component code, it actually generates initials by the first 2 words in the name. It might work for most cases since most people have 1 word for first name and 1 word for last name (e.g. Piper Chapman). However, there are still some people having more than 2 words in there name, it could be a long first name with multiple words, or middle name.

The other problem is, should we use space or hyphen to separate the words in a name? This is a comment I got in my PR. Personally, I'd use space instead of hyphen. Hyphen is more like linking words to one part of name.

My initials generator code looks like this,
```javascript
const initials = name.split(' ')
                     .map((splitName, i, arr) =>
                     i === 0 || i + 1 === arr.length ? 
                     splitName[0].toUpperCase() : null)
                     .join('');
```

This generator will separate words in names by space, and ignore the words other than first name and last name. `splitName` represents the current value, `i` represents the index of it, and `arr` represent the whole array of splitted names. `i === 0` takes care of the first word of the name, and `i + 1 === arr.length` takes care of the last word of the name. For example, my friend Abu from OSD600 has 5 words in his name (Abu Zayed Kazi Masudan Nabi). His initials will be AN, instead of AZ. And for me, my name is Yuan-Hsi Lee, there is a hyphen in my first name to link 2 syllables, therefore, my initials will be YL instead of YH.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6xrbh7os4sg0imfwn3h.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96wyqv7nep3gyzpwzhx9.png)

Above are how the name initials avatar look like.

The other PR which is related with this one is to [centre the initials text](https://github.com/Seneca-CDOT/telescope/pull/1923). Somehow, this font makes the text slightly toward the top. Thanks to Anton, Ilya and Minh's help, the puzzle is solved and the solution is made.