Updates on dev.to clone in Angular July 23
Tags: angular, webdev, showdev, typescript
Published: 2021-07-23 04:29:38

Github Repo - https://github.com/ajitsinghkaler/devto-clone

Deployed on Firebase - https://dev-toclone.firebaseapp.com/

Last week I added Article store and sidebar in our dev.to clone.
![Dev.to Clone July 16](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzl6ndws9g10llhqw0qt.png)

This week I added the articles section. The articles section is divided into three parts the featured article ie the first article in your feed the rest of the articles section and the top header from where I select the time interval of our feed. Right now the feed is generic not based on any tags and user but I will do that later. Most of the time went in setting up the HTML, CSS for our articles section so I was not able to complete the tags store and the articles header section.

I did some interesting things which you may find interesting. 

### Content projection in the articles-cards section

In normal articles card the font size of title is 24px and in the featured-article section it was 30px. So I thought I should add the title section via content projection but this had one problem that there is no way in Angular to give default content projection the [issue](https://github.com/angular/angular/issues/12530) is open for a long time but there is a work around you can define a ref on the template and check if has children then render the projected content or render the default content if it does not have any content projected. To see how I implemented it follow this [link](https://github.com/ajitsinghkaler/devto-clone/blob/fa6062cbaeb758328bef9afa24bfe7c96b6ac1b6/src/app/pages/home/articles/article-card/article-card.component.html#L15-L20).

### Changing styles of component

So if you put some styles of your component in the :host selector it can be easily changed in other components too. Like the article card-component as some styles but with the featured card I need to change some styles of the card component. Most of the CSS I need to be changed is global so I put it in host of the article-card component and I was easily able to change the styles to see how I implemented this check this [link](https://github.com/ajitsinghkaler/devto-clone/blob/6fbc74f35b89b3067ab7b42e44fa47b789748940/src/app/pages/home/articles/featured-article/featured-article.component.scss#L15-L22).

Which leads us here
![Updated angular dev-to clone 23-7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5hsg9m6rg2kf53fxo0f.png)

## Issues

### CSS management

[Issue](https://github.com/ajitsinghkaler/devto-clone/issues/2)
CSS is getting out of hand I had to add a new class again and again every time even to add a small padding value. Its obvious that CSS is going to balloon soon and will get out of hand. So, see some CSS management techniques.

### Content projection

[Issue](https://github.com/ajitsinghkaler/devto-clone/issues/3)
Content projection just to change the size of the title seems overkill. Should it be done via inputs.

### Header in article section

[Issue](https://github.com/ajitsinghkaler/devto-clone/issues/4)
Article section header is incomplete.

## Commits done in this update

1. [built homepage articles section](https://github.com/ajitsinghkaler/devto-clone/commit/6fbc74f35b89b3067ab7b42e44fa47b789748940)
2. [add dynamic title in article card](https://github.com/ajitsinghkaler/devto-clone/commit/fa6062cbaeb758328bef9afa24bfe7c96b6ac1b6)
3. [WIP: add header to articles section](https://github.com/ajitsinghkaler/devto-clone/commit/1a2629666a9ad652b517450f153c5f7164c874a4)

Let me know in the comments if you think something can be improved.