Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
πŸ€“ JavaScript Best Practice

#js

βœ… Article link
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ Adding Initial DOM Rendering Transitions with @starting-style

#css #startingStyle

When a DOM element gets rendered from an HTML document or JavaScript code snippet, it gets rendered without any initial transition animation. In the past, we typically implemented these initial animations with dynamically switched CSS classes via JavaScript. Nowadays, we can use CSS animations for these situations, but the initial animation concept undoubtedly belongs to the CSS transitions feature. The `starting-style` at-rule lets you set initial styles for a CSS selector, so you can build up a transition animation for the initial rendering step:

button {
padding: 12px;
border: none;
border-radius: 4px;
font-size: 16px;
background-color: #bbb;
opacity: 1;
transform: scale(1);
transition: all 1s linear;

@starting-style {
opacity: 0;
transform: scale(0.5);
}
}


The above code snippet plays a transition animation when a button element gets rendered on the viewport. This transition works even though you dynamically create a new element with JavaScript.
πŸ‘2
πŸ“„How to setup Angular + Supabase

#angular #supabase

Supabase as a Firebase alternative


πŸ”—Supabase link βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯2
πŸ“„Defining Scoped CSS with @scope

#css #scope

By default, the traditional CSS implementation styles web pages with a global scoping concept. Moreover, in the past, no CSS scoping feature was present with the style tag, every style tag was feasible for styling any HTML node, including the root regardless of the style tag position in the DOM tree. The HTML standard tried to support scoping with the scoped attribute, but it was deprecated before becoming a web standard. Now, the modern CSS specification introduced the `scope` at-rule for defining scoped CSS.

For example, you can create a scoped style tag for styling an HTML segment as follows:


<div>
<style>
@scope {
:scope {
background-color: #ddd;
padding: 12px;
}
h3 {
padding: 0 0 6px 0;
margin: 0;
border-bottom: solid 2px #eb7e3b;
}
}
</style>
<h3>Lorem ipsum dolor sit amet</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>

The above style tag defines a scoped CSS content for the parent div element with @scope. Here, we targeted the scoped element using the :scope pseudo-class.
πŸ‘1
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„Modern Component-Oriented Responsive Design with @container

#css #container

The modern CSS specification offers container queries via the @container at-rule for this requirement.

Look at the following sample:

<div class="alert">
<h3>Lorem ipsum dolor sit amet</h3>
<button>Lorem ipsum</button>
<button>Lorem ipsum</button>
</div>


.alert {
background-color: #ddd;
padding: 12px;
resize: horizontal;
overflow: hidden;
container-type: inline-size;
}

.alert h3 {
padding: 0 0 6px 0;
margin: 0 0 12px 0;
border-bottom: solid 2px #eb7e3b;
}

.alert button {
padding: 12px;
border: none;
margin-right: 6px;
}

@container (width < 400px) {
.alert button {
width: 100%;
box-sizing: border-box;
}

.alert button:not(:last-child) {
margin-bottom: 10px;
}
}
πŸ‘2
πŸ“„ Handling CSS Precedence with @layer

#css #layer

In web design scenarios, developers typically use multiple CSS selectors and often have to override styles. Even though you don’t override CSS styles with multiple selectors by yourself, every CSS block you write automatically overrides styles from the user-agent stylesheet. CSS’s style overriding process happens based on the browser’s specificity algorithm that calculates a weight for CSS selectors for handling precedence. In the past, every developer tweaked their CSS overriding-related code based on the specificity algorithm since they didn’t have a way to handle CSS precedence without using confusing !important.
πŸ‘1
πŸ“„ Angular, Docker & Nginx: Build once, Deploy anywhere

#angular #nginx #docker

In software development is quite common to have multiple environments, each with different configurations. Angular offers a built-in system for managing environment variables, allowing for the replacement of files during build time. However, this approach often requires creating separate builds for each environment, which can be time-consuming but to avoid this we have a pretty common pattern in the industry.

Build once, deploy anywhere…
So, let’s have an example where we have two environments, DEV and PROD, and for that, we want to have ONE build. For that, we use:

Angular β€” a front-end framework for building SPA applications.
Nginx β€” is a web server and reverse proxy server.
Docker β€” is a platform for developing, shipping, and running applications in containers, which are lightweight, portable, and self-sufficient environments.


βœ… Article link 🎁 Code link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM