Skip to content

Commit

Permalink
✨ new post
Browse files Browse the repository at this point in the history
  • Loading branch information
yuancong-liu committed Apr 25, 2024
1 parent 5e1efb1 commit a8358f7
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 365 deletions.
19 changes: 15 additions & 4 deletions src/components/common/navBarCommon/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
left: 0;
z-index: 1000;
width: min(100%, 700px);
padding: 12px;
padding: 8px;
margin: 10px auto;
font-family: utils.$font-serif;
font-size: 16px;
Expand All @@ -30,14 +30,19 @@
@extend %center-items-grid;

z-index: 100;
grid-template-columns: repeat(5, 1fr);
grid-template-columns: 1fr 1fr 40px 1fr 1fr;
gap: 8px;
padding: 0;
margin: 0 auto;
list-style: none;
}

.icons {
height: 30px;
.nav-item {
@extend %center-items-grid;

width: 100%;
height: 100%;
border-radius: 100px;
}

.c-mark-nav {
Expand All @@ -51,4 +56,10 @@

.text-link {
position: relative;

&.-active {
// layer won't work for this
text-decoration: underline;
text-underline-offset: 4px;
}
}
13 changes: 9 additions & 4 deletions src/components/common/navBarCommon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const NavBarCommon = () => {
return (
<nav className={styles['nav-bar']}>
<ul className={styles['nav-items']}>
<li>
<li className={styles['nav-item']}>
<Link
href="/blog"
className={classNames(
Expand All @@ -38,7 +38,7 @@ export const NavBarCommon = () => {
BLOG
</Link>
</li>
<li>
<li className={styles['nav-item']}>
<Link
href="/portfolio"
className={classNames(
Expand All @@ -65,6 +65,11 @@ export const NavBarCommon = () => {
clipRule="evenodd"
d="M9.58568 17.5166L-0.000732422 14.4482L2.27473 7.43875L11.8914 10.5168V0.422546H19.3081V10.4873L28.9582 7.33985L31.2727 14.3367L21.6002 17.4915L27.6016 25.6592L21.6101 30L15.6021 21.8235L9.64406 29.9451L3.64918 25.6089L9.58568 17.5166Z"
fill={fill}
whileHover={{
rotate: 360,
scale: 0.8,
transition: { duration: 1 },
}}
style={{
pathLength,
}}
Expand All @@ -73,7 +78,7 @@ export const NavBarCommon = () => {
</Link>
</li>

<li>
<li className={styles['nav-item']}>
<Link
href="/about-me"
className={classNames(
Expand All @@ -84,7 +89,7 @@ export const NavBarCommon = () => {
ABOUT ME
</Link>
</li>
<li>
<li className={styles['nav-item']}>
<Link
href="/and"
className={classNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
font-size: 4rem;
font-weight: 600;
line-height: 1;
cursor: pointer;
opacity: 0.5;
transition: all 0.3s ease-in-out;

Expand Down
131 changes: 131 additions & 0 deletions src/posts/codepen-works-review-01.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
title: Note | CodePen Works Review 01
date: 2024-04-25 11:39:00
language: English
tags:
- Programming
- Front-end
- CSS
---

I've done quite a bit of Pen this month (mostly because I just started a new job at a different company and have too much time on my hands), including some of the new CSS features mentioned in last year's [CSS Wrapped](https://developer.chrome.com/blog/css-wrapped-2023), some of the features I'm interested in, and simple copies of fancy Pens I saw someone else do online.

## `grid-template-xxx: subgrid`

Subgrid has been a highly discussed topic recently. The alignment needs to be the same within a group, but since the content is dynamically variable, developers have to put in assumptions and worse, dynamically obtain the size of the content. But subgrid solves this problem by making it easy for container components that have no way of knowing each other's content to maintain the same alignment and keep the same content aligned at all times.

Let's look at the following example first.

<PostFrame
height="500"
scrolling="no"
scrolling="no"
title="Subgrid"
src="https://codepen.io/yuancong-liu/embed/oNOyNRd?default-tab=result&theme-id=dark"
frameBorder="no"
loading="lazy"
allowFullScreen
/>

When defining column templates or row templates, as opposed to the usual practice of defining a grid for an entire container, when using the subgrid feature, we need to define the grid for each piece of content.

```scss
// parent container containing the card components
.container {
// ...
grid-template-rows: auto auto 200px auto auto;
// ...
}

// card component should take 5 grids vertically
.card {
// ...
grid-row: span 5;
// ...
}
```

## `@starting-style` and transitions for discrete attributes

Using only CSS, markup engineers can't or have a hard time defining the animations and transitions of elements entering or leaving the screen, and often need to resort to JS or animation libraries like framer-motion and GSAP (`autoAlpha` and such). But CSS's new provision of `@starting-style` and support for transition effects on discrete attributes goes some way to solving this problem as in the example below.

<PostFrame
height="500"
scrolling="no"
scrolling="no"
title="`@starting-style` and transitions for discrete attributes"
src="https://codepen.io/yuancong-liu/embed/eYoKmoK?default-tab=result&theme-id=dark"
frameBorder="no"
loading="lazy"
allowFullScreen
/>

For the element's entry effect (the transition from `display: none;`), we can now specify it with `@starting-style`.

```scss
@starting-style {
.card {
opacity: 0;
height: 0;
}
}
```

For elements leaving the page, there is also native CSS support for transitions to `display: none;`. No need for extra @rules, it's easy to write directly into the properties.

```scss
@keyframes fade-out {
100% {
opacity: 0;
display: none;
}
}
```

## Cards with glowing edges

The development of the new company's project uses nuxt.js. I was browsing through the home pages of the various nuxt.js modules and noticed that these cards with glowing edges are everywhere (is it a design guideline from the nuxt organisation...?). . So I made a simple copy.

The main idea behind this kind of card development is to use the `::after` pseudo-class of the card itself and the card container element while tracking the cursor position and assigning values to CSS variables in real time.

<PostFrame
height="500"
scrolling="no"
title="Cards with glowing edges"
src="https://codepen.io/yuancong-liu/embed/XWQPjdK?default-tab=result&theme-id=dark"
frameBorder="no"
loading="lazy"
allowFullScreen
/>

This kind of real-time assignment of values to CSS variables shows up in all sorts of fancy web effects, so why haven't I ever tried it...?

## Variable fonts

Variable fonts also seem to be a pretty popular topic these days (although it's rare to see anyone actually putting them into production).

Variable fonts give front-end engineers finer control over font-weight, slant, font width, and other font properties. For example, the control of font-weight is no longer in steps of 100 but can be in steps of 1. With this feature, the font property, which normally wouldn't do much for it, can now be used to achieve very smooth transitions.

As can be seen by the example below, the axes provided by the font itself can be controlled very granularly.

<PostFrame
height="500"
scrolling="no"
title="Variable fonts"
src="https://codepen.io/yuancong-liu/embed/yLrGEJL?default-tab=result&theme-id=dark"
frameBorder="no"
loading="lazy"
allowFullScreen
/>

Similarly, the cursor position acquisition and CSS variable assignment methods described above can be used to achieve a very stylish font distortion effect.

<PostFrame
height="500"
scrolling="no"
title="Variable fonts with cursor tracking"
src="https://codepen.io/yuancong-liu/embed/eYobKaW?default-tab=result&theme-id=dark"
frameBorder="no"
loading="lazy"
allowFullScreen
/>
116 changes: 0 additions & 116 deletions src/posts/javascript-note-class.mdx

This file was deleted.

Loading

0 comments on commit a8358f7

Please sign in to comment.